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

Re: PREV function



PureBytes Links

Trading Reference Links

Dave

> TradePosition:=If(BarsSince(EnterLong)<=BarsSince(EnterShort),1,-1);
>
> is very similar to the above statement, but misses the first Long or Short trade, whichever
> happens first.

Using an initialisation variable (Init) with the above TradePosition solves the missed first trade,
as used in Trade Binary posted a few days ago. Also note that <= is changed to >= (and the polarity
of values is reversed) to better manage buy and/or sell signals that are active (true) as they
become valid.

Init:=Cum(EnterLong<>2 AND CloseLong<>2 AND EnterShort<>2 AND CloseShort<>2 )=1;
Trade:=Ref(If(BarsSince(EnterLong OR Init)>= BarsSince(CloseLong OR Init),0,2) +
 If(BarsSince(EnterShort OR Init)>= BarsSince(CloseShort OR Init),0,-1),-0);

Roy