The trade_on variable doesn't seem to be resetting, so after an entry, buy stops are still placed even though the long condition is false.
Code: Select all
if long_condition then begin
bar_number = BarNumber;
entryprice = high;
trade_on = true;
end;
if trade_on and (BarNumber - bar_number) <=Bars_valid then
buy next bar at entryprice stop;
if marketposition = 1 then trade_on = false;
if (BarNumber - bar_number) > Bars_valid then trade_on= false