[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening Range Breakout



PureBytes Links

Trading Reference Links

> I would think that most of the time DayOpen would be zero in this
> instance. An opening trade would have to occur after the end of the
> session Close and before the calculations are begun. Am I missing
> something? 
> 
> : vars:  DayOpen(0);
> : if Time = Sess1Endtime then DayOpen = Open of next bar;
> : if DayOpen <> 0 then buy at DayOpen + ATR(10)*X;

DayOpen is initialized to zero **on the first bar only**, and stays 
that way through the first day on the chart.  Then, at the end of the 
first (and each subsequent) day, when Time = Sess1EndTime, DayOpen 
gets set to the Open of the next bar.  Since this is supposedly the 
last bar of the day (assuming you are only charting RTH data), the 
next bar should be the first bar of the new day, so the Open of that 
bar is the opening tick of the next day.

DayOpen retains that opening-tick value throughout the day, until it 
gets set to the *next* day's open.  DayOpen NEVER gets set back to 
zero.

Actually, though, you might want to set it to zero if your buy stop 
ever gets hit, so you don't keep re-issuing the buy order.

Also, I realized my code will fail on any day that is missing the 
final bar, since Time will never = Sess1EndTime.  The following code 
works for that situation.

vars:  BuyStop(0);
if Date of next bar <> Date 
  then BuyStop = Open of next bar + ATR(10)*X ;
if High > BuyStop then BuyStop = 0;
if BuyStop <> 0 then buy at BuyStop stop;

Gary