Sample trend robot

Created at 07 Sep 2012, 12:27
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MI

misado

Joined 31.08.2012

Sample trend robot
07 Sep 2012, 12:27


Hi,

I've tried to backtest the robot with the cross of SMA 3 and 30 but the the results are wrong.

It has nothing to do with the real cross and its creates and closes the positions always at the same minute.

Thanks

Mike


@misado
Replies

daemon
11 Sep 2012, 12:29 ( Updated at: 21 Dec 2023, 09:20 )

Hey,

I'm trying the same robot but with a little modification and it seems to work fine.

 

Try  OnBar instead with a previous index like:

        protected override void OnBar ()
        {
            if (Trade.IsExecuting) return;
            
            int lastIndex = slowMa.Result.Count - 2;
            int prevIndex = slowMa.Result.Count - 3;
// etc.


@daemon

misado
11 Sep 2012, 18:45

Hi,

it works, thanks

Mike


@misado