Hello Preston and other gurus
I am having some issues with the PREV function (I think) in developing a
trailing stop ratchet (short side). The “BearStop” function gives me a zero for
all cases everything else above checkout as I expect it to. I cannot see the
flaw in my logic. Any help would be appreciated.
Code:
Day:=Input("Day Entered Trade",1,31,19);
Mnth:=Input("Month Entered Trade",1,12,4);
Yr:=Input("Year Entered Trade",1985,2100,2004);
HoldingDays:=BarsSince(Day=DayOfMonth() AND Mnth=Month() AND Yr=Year());
InitStop:=Input("Initial Stop",0,100000,1.52);
Index := 100-(100/(1+( PDI(21)/ MDI(21)+0.0001)));
OS:=30-Index;
Bearish:= CLOSE-(CLOSE*(OS/100));
Stop:= If(Bearish>=CLOSE,HIGH +(Bearish-CLOSE),HIGH);
BearStop :=
If(Stop<PREV AND Stop< InitStop,Stop,
If(Stop<PREV AND Stop> InitStop, InitStop,
If(Stop>=PREV,PREV,Stop*Holdingdays)));
{Plot} Bearstop;
Kind Regards,
Ed
.