Hi, was just wondering if anyone has come across this same problem and how the resolved it. im basically trying to set a breakeven but with a lower threshold value which wont be surpassed. the breakeven is set using the average true range. the first pic i have attached shows the atr values and the corresponding trades and trades 7-9 are showing no run up or dd. Any ideas?????
the easy language code is below
inputs: price(close),length1(2),length2(6), length3(20),x(10),starttime(0701),endtime(1701);
vars:timeok(0),mp(0),cangolong(false),cangoshort(false),condition1(false),condition2(false),expav1(0),expav2(0);
{ == misc == }
mp=marketposition;
if rightstr(getsymbolname,3)="jpy" then value42=100 else value42=10000;
{ == time condition == }
if (t>=starttime and t<endtime ) then timeok=1 else timeok=0;
expav1=xaverage(price,length1);
expav2=xaverage(price,length2);
condition1=expav1 > expav2;
condition2=expav1 < expav2;
if mp[1]=0 then cangolong=true;
if mp[1]=0 then cangoshort=true;
if timeok=1 then begin;
if cangolong and condition1 then buy("mybuy") 1 contract next bar at market;
end;
if timeok=1 then begin;
if cangoshort and condition2 then sell("mysell") 1 contract next bar at market;
end;
if ((AvgTrueRange(Length3))*value42) >= x then begin
SetStopPosition;
SetBreakEven((AvgTrueRange(Length3))*value42);
end;
if ((AvgTrueRange(Length3))*value42) < x then begin
SetStopPosition;
SetBreakEven(x);
end;
{print("Date - ",ELDateToString(date),"Avg1 ",plot1:3:3,"Avg2 ",Plot2:3:4);}
the easy language code is below
inputs: price(close),length1(2),length2(6), length3(20),x(10),starttime(0701),endtime(1701);
vars:timeok(0),mp(0),cangolong(false),cangoshort(false),condition1(false),condition2(false),expav1(0),expav2(0);
{ == misc == }
mp=marketposition;
if rightstr(getsymbolname,3)="jpy" then value42=100 else value42=10000;
{ == time condition == }
if (t>=starttime and t<endtime ) then timeok=1 else timeok=0;
expav1=xaverage(price,length1);
expav2=xaverage(price,length2);
condition1=expav1 > expav2;
condition2=expav1 < expav2;
if mp[1]=0 then cangolong=true;
if mp[1]=0 then cangoshort=true;
if timeok=1 then begin;
if cangolong and condition1 then buy("mybuy") 1 contract next bar at market;
end;
if timeok=1 then begin;
if cangoshort and condition2 then sell("mysell") 1 contract next bar at market;
end;
if ((AvgTrueRange(Length3))*value42) >= x then begin
SetStopPosition;
SetBreakEven((AvgTrueRange(Length3))*value42);
end;
if ((AvgTrueRange(Length3))*value42) < x then begin
SetStopPosition;
SetBreakEven(x);
end;
{print("Date - ",ELDateToString(date),"Avg1 ",plot1:3:3,"Avg2 ",Plot2:3:4);}