Back testing glitch

Created at 14 Aug 2016, 04:49
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!
lec0456's avatar

lec0456

Joined 14.11.2012

Back testing glitch
14 Aug 2016, 04:49


I started to back test a cBot but there are points where it generates 100 or more trades on one single bar.  So, my profits appear to go through the roof. Whats happening?  It appear to happen with a small 10 pip take profit, increasing the TP to 20 eliminates the effect.  


@lec0456
Replies

... Deleted by UFO ...

croucrou
14 Aug 2016, 14:05

I don't know, but isn't this related to the question I have asked here:

/forum/cbot-support/10059


@croucrou

... Deleted by UFO ...

lec0456
14 Aug 2016, 20:06

why would a negative spread have anything to do with it?  it seems to me like more of a problem with the backtesting engine 


@lec0456

lec0456
14 Aug 2016, 20:10

RE:

croucrou said:

I don't know, but isn't this related to the question I have asked here:

/forum/cbot-support/10059

I looked at your thread but not sure if its the same thing.

At first this looks like an asynchronous verses synchronous issue.  but the trades stop after a period of time.  It occurs on specific days like 7/9/15 and others. 

 


@lec0456

... Deleted by UFO ...

... Deleted by UFO ...

lec0456
14 Aug 2016, 23:41

Ah!!!!! Thank you very much for that explanation.  I will do some testing and see if that's what's happening in my case.  I bet it is.

So, I would just program the robot to not trade with a negative spread during back testing, so i get more realistic results but leave it in during live trading just in case I get lucky.

   

   


@lec0456

... Deleted by UFO ...

lec0456
15 Aug 2016, 02:49

I would have never in a million years thought the platform backtesting engine would be producing negative spreads as large as 10 pips, but yes you were correct.

I just threw these lines of code in to stop the behavior while backtesting. 

if(!Account.IsLive && Symbol.Spread/Symbol.PipSize<=-10)
        	{
        	   //Print(MarketSeries.OpenTime[MarketSeries.Close.Count - 1].ToString("MM/dd/yyyy HH:mm")+" Neg Spread: "+Math.Round(Symbol.Spread/Symbol.PipSize,2));
        	   return;
        	}

 


@lec0456

Balena
15 Aug 2016, 05:01

This scenario can happen a lot in certain markets when someone crosses the market to pile out or load up quickly... usually happens very quickly and at times of information release or session open/close


@Balena

lec0456
15 Aug 2016, 06:25

RE:

lec0456 said:

I would have never in a million years thought the platform backtesting engine would be producing negative spreads as large as 10 pips, but yes you were correct.

I just threw these lines of code in to stop the behavior while backtesting. 

if(!Account.IsLive && Symbol.Spread/Symbol.PipSize<=-10)
        	{
        	   //Print(MarketSeries.OpenTime[MarketSeries.Close.Count - 1].ToString("MM/dd/yyyy HH:mm")+" Neg Spread: "+Math.Round(Symbol.Spread/Symbol.PipSize,2));
        	   return;
        	}

 

Correction !Account.IsLive should be IsBacktesting.


@lec0456

... Deleted by UFO ...

davidp13
27 Nov 2016, 20:08

Hi. I also picked up something funny. Could not figure out if it was -ve spread. I posted what I found here - /forum/calgo-support/10976

For some reason using null in the TakeProfit filed while calling ModifyPosition caused issues. Does not make sense to me.


@davidp13