Hello,
I have been an active READER on this site and this is my first post! I have worked on this simple script to COUNT number of 1-min bars that have no movement and low-volume. Below is my code. I need help to:
a) improve with better ways to accurately identify first-Bar and last-Bar of an intraday (1-min) instead of blindly using 390 bars for 390 minutes of a day
b) Able to calculate the same not just for TODAY, but for last say 5 days of intraday.
c) Expand to limit to COUNT calculation to only certain HOURS of the INTRADAY, example 11:30am EST to 2:30pm EST only, (basically during the mid-day).
Thank you all in advance.
-Jay
----------------------------
I have been an active READER on this site and this is my first post! I have worked on this simple script to COUNT number of 1-min bars that have no movement and low-volume. Below is my code. I need help to:
a) improve with better ways to accurately identify first-Bar and last-Bar of an intraday (1-min) instead of blindly using 390 bars for 390 minutes of a day
b) Able to calculate the same not just for TODAY, but for last say 5 days of intraday.
c) Expand to limit to COUNT calculation to only certain HOURS of the INTRADAY, example 11:30am EST to 2:30pm EST only, (basically during the mid-day).
Thank you all in advance.
-Jay
----------------------------
Code:
# Filter : Intraday Liquidity threshold filter
# Description: In the smallest possible intraday timeframe (1-min), there should not be too many quiet (low-volume or no volume) bars that are flat (high==low==open==close). NOTE: Intraday time in minutes: 1-day = 390mins
INPUT displacement = 0;
INPUT IGNORE_VOLUME = { _YES, default _NO};
INPUT QUIET_VOLUME = 100;
def LL_Threshold = 60;
def o = open;
def c = close;
def l=low;
def h=high;
def boolQuietBar;
switch (IGNORE_VOLUME) {
case _YES:
boolQuietBar = (high == low);
case _NO:
boolQuietBar = (high == low) and (volume <= QUIET_VOLUME);
}
#def QuietBar_Count = if boolQuietBar then QuietBar_Count[1]+1 else QuietBar_Count[1];
def QuietBar_Count = sum(boolQuietBar, 390);
AddLabel (yes, "LL #: " + QuietBar_Count, Color.WHITE);
#plot myplot = if QuietBar_Count[displacement] > LL_Threshold then QuietBar_Count[displacement] else Double.NaN ;
#plot myplot = boolQuietBar;