Hi All,
Can anyone of you please help me with the below script.
The purpose of this script to fetch only those stocks at respective period of time which meets the volume condition of that period for eg. between 9:45 am to 10:59 am EST I only want those stocks who volume is greater than equal to 1.5M, between 11 am to 12 noon I only want those stocks whose volume is greater than equal to 2.5M and so on.
The problem I am facing with this script is that it always takes the highest volume condition i.e. in the below script it skips all stocks with volume 1.5M or 2.5M and only takes into consideration the highest which is 3.5M and above for all the time periods defined, that means I miss all the stocks of 1.5M volume between 9:45 am to 10:59 am EST and only get notified for stocks greater than 3.5M.
Please let me know in case there is any difficulty in understanding, I can try to explain again. Thanks for all the help and inputs.
Can anyone of you please help me with the below script.
The purpose of this script to fetch only those stocks at respective period of time which meets the volume condition of that period for eg. between 9:45 am to 10:59 am EST I only want those stocks who volume is greater than equal to 1.5M, between 11 am to 12 noon I only want those stocks whose volume is greater than equal to 2.5M and so on.
The problem I am facing with this script is that it always takes the highest volume condition i.e. in the below script it skips all stocks with volume 1.5M or 2.5M and only takes into consideration the highest which is 3.5M and above for all the time periods defined, that means I miss all the stocks of 1.5M volume between 9:45 am to 10:59 am EST and only get notified for stocks greater than 3.5M.
Please let me know in case there is any difficulty in understanding, I can try to explain again. Thanks for all the help and inputs.
Rich (BB code):
# ************************ INCREMENTING VOLUME PERIODICALLY ********************************* #
input alertPeriodStart1 = 0945; # Alert Start
input alertPeriodEnd1 = 1059;
input alertPeriodStart2 = 1100;
input alertPeriodEnd2 = 1159;
input alertPeriodStart3 = 1200;
input alertPeriodEnd3 = 1235; # Alert End
def startCounter1 = SecondsFromTime(alertPeriodStart1);
def endCounter1 = SecondsTillTime(alertPeriodEnd1);
def startCounter2 = SecondsFromTime(alertPeriodStart2);
def endCounter2 = SecondsTillTime(alertPeriodEnd2);
def startCounter3 = SecondsFromTime(alertPeriodStart3);
def endCounter3 = SecondsTillTime(alertPeriodEnd3);
def alertPeriod1 = if startCounter1 >= 0 and endCounter1 >= 0 then 1 else 0;
def alertPeriod2 = if startCounter2 >= 0 and endCounter2 >= 0 then 1 else 0;
def alertPeriod3 = if startCounter3 >= 0 and endCounter3 >= 0 then 1 else 0;
def volCondition1 = if volume("period" = AggregationPeriod.DAY) >= 1500000 then 1 else 0;
def volCondition2 = if volume("period" = AggregationPeriod.DAY) >= 2500000 then 1 else 0;
def volCondition3 = if volume("period" = AggregationPeriod.DAY) >= 3500000 then 1 else 0;
plot scan = if (alertPeriod1 and volCondition1 and !alertPeriod2 and !alertPeriod3) then 1
else if (alertPeriod2 and volCondition2 and !alertPeriod3) then 1
else if (alertPeriod3 and volCondition3) then 1 else 0;