automatic 15 minute range

#Altered script from
#by elvis = opening 15 minute range, best used on multiples of 5
def na=double.nan;
input ORBegin = 0930;
input OREnd = 0945;
input ShowTodayOnly={"No", default "Yes"};
def s=ShowTodayOnly;
Def ORActive = if secondstilltime(OREnd)>0 AND secondsfromtime(ORBegin)>=0 then 1 else 0;
def today=if s==0 OR getday()==getlastday() AND secondsfromtime(ORBegin)>=0 then 1 else 0;
Rec ORHigh = if ORHigh[1]==0 or ORActive[1]==0 AND ORActive==1 then high else if ORActive AND high>ORHigh[1] then high else ORHigh[1];
Rec ORLow = if ORLow [1] ==0 or ORActive [1] ==0 AND ORActive ==1 then low else if ORActive AND low < orlow [1] then low else ORLow [1];
Def ORWidth = ORHigh - ORLow;
Plot ORH=if ORActive OR today<1 then na else ORHigh;
Plot ORL=if ORActive OR today<1 then na else ORLow;

1 comment :

Nicholas Lemp said...

This is great, it helps a great deal auto generating with my strategy. Is there any way to pull the information and provide trends for the OPEN and CLOSE of the first 15 min candle instead of the total range?

Post a Comment