Replies

ialhamdazeez
30 Oct 2023, 19:17

RE: How to define Stop loss

PanagiotisChar said: 

Hi there,

There is no magical solution to this. This is how martingales work and eventually they blow up the account

Thanks, I read about martingales Strategy. It is exactly what I do in my cbot. It seems there is no solution


@ialhamdazeez

ialhamdazeez
29 Oct 2023, 10:20 ( Updated at: 30 Oct 2023, 06:23 )

Bars is an array beginning from the oldest price to current price. So you should first reverse it to begin from the current price, then skip the current price using skip function, then take the bars that you want to check for highest price using take function. Use the following code:

var bars = Bars.Reverse().Skip(1).Take(5).Where(b => b.High == Bars.Reverse().Skip(1).Take(5).Max(a => a.High));

// print the result 
foreach (var b in bars)
            {
                Print("time: " + b.OpenTime.ToString() + ", price: " + b.Close.ToString());
            }

@ialhamdazeez