I have created a strategy, that trades the breakout from a certain range (I use two variables: RangeMax, RangeMin).
For example, I trade a long position by stop order, if the market breaks over "RangeMax", the StopLoss is at "RangeMin", and the profit target is as far as the Stoploss.
It works, as long as the strategy doesn`t find another Range (new "RangeMax" and "RangeMin") during an open trade.
In this case, the strategy changes StopLoss from the first "RangeMin" to the new "RangeMin".
I`ve tried the following code:
if (.....)
{
EnterLongStopMarket(0, true, KontraktzahlLong, RangeMax, @"Long");
SetStopLoss(@"Long", CalculationMode.Price, RangeMin, false);
SetProfitTarget(CalculationMode.Ticks, RangeTicks);
}
I`ve tried to write
SetStopLoss(@"Long", CalculationMode.Price, RangeMin, false);
in the OnStateChange() method (when the current market position is long or short). After compiling I couldn`t find the strategy in Strategy Analyzer.
Unfortunately I`m not a programmer (learning by doing), but I hope we will find a solution.
Best regards
Comment