Code: Select all
Input:
[....]
Afterprofitpercentage1(0.9),
Afterprofitpercentage2(0.1),
averagetruerangelength(14),
Stoplosspercentage(2),
Variables:
[....]
averagerange=averagetruerange(averagetruerangelength);
Stoploss=ENTRYPRICE-(Stoplosspercentage*averagerange);
[....]
if(Close> EntryPrice +Afterprofitpercentage1*averagerange)
then
longLiqPoint = EntryPrice-(Afterprofitpercentage2*averageRange); {BreakEven trade}
begin
sell("MA Corss Exit4") numContracts shares total next bar at longLiqPoint stop;
end;
if Close<Stoploss then sell("MA Corss Exit5") numContracts shares total this bar at close;
For the setting a StopLoss or Break Even as seen above when in a SHORT position, I thought the opposite should work:
Code: Select all
Input:
[....]
Afterprofitpercentage1(0.9),
Afterprofitpercentage2(0.1),
averagetruerangelength(14),
Stoplosspercentage(2),
Variables:
[....]
averagerange=averagetruerange(averagetruerangelength);
Stoploss=ENTRYPRICE+(Stoplosspercentage*averagerange);
[....]
if(Close< EntryPrice -Afterprofitpercentage1*averagerange)
then
shortLiqPoint = EntryPrice+(Afterprofitpercentage2*averageRange); {BreakEven trade}
begin
buytocover("MA Corss Exit4") numContracts shares total next bar at shortLiqPoint stop;
end;
if Close>Stoploss then buytocover("MA Corss Exit5") numContracts shares total this bar at close;
Does anybody know where the mistake in the short Breakeven/SL code is?