PureBytes Links
Trading Reference Links
|
Hi,
I am trying to write an exit routine that will do the following:
Exit at a certain percentage retracement of the swing low and high that
contains the buy or sell. If you of a routine that will do this please
let me know or critque what I am doing wrong..
Thanks in advance.
Don
for the long side:
Once a buy has been made the lowest low for the time of the buy to the
start of the previous day is determined.
I have gotten this far but I get an error message informing me that I
need to reset my maximum number of bars for referance.
CV = 1 is a crossover signal comparing two time intervals is a cross
over occurs its 1 else its 0.
{===========Entry======================}
If CV1= 1 Then Buy 3 Contracts at Market;
end;
{=========Determining the 1 day lowest low for the swing low.=======}
If MarketPosition =1 then begin
If CV1 = 1 then BuyPTLO = CurrentBar; {CV =1 is entry signal}
If CV1 = 1 then BDTIME = ( Time - Sess1StartTime)/Barinterval;
BPDAY{bars per day} = 390/BarInterval;
TOTBARS = BPDAY + BDTIME;
CVBPLO = Lowest(low,TOTBARS);
{=================}
{Determining the BarNumber of the lowest low needed to calculate the
highest high from that low point }
CVBPLOBAR = Lowestbar(Low,TOTBARS);
HILEN = CurrentBar - CVBPLOBAR;
CVBPHIGH = Highest(High,HiLen);
{This calculates the swing length}
SwingLength = CVBPHIGH - CVBPLO;
{===========Exit routine Trailing Stop==============}
If Low < CVBPHIGH - XVar1*(Swinglength) then Sell("CV1") on close data1
stop;
|