SmartQuant Discussion
http://www.smartquant.com/forums/

stop loss problem in simulation
http://www.smartquant.com/forums/viewtopic.php?f=42&t=8520
Page 1 of 1

Author:  jamesbond [ Sun Nov 07, 2010 10:41 am ]
Post subject:  stop loss problem in simulation

Hi,
I am backtesting on my multi time frames strategy.
For example, if the price on 60 min, 30 min and 5 min cross above moving avg (60,30,5 min), go long on 5 min bar.
But for some reason, I got filled on my stop loss (limit order) at a price which it doesn't even exist in that particular bar. I enter the trade at 12208 and set my set loss at 25 ticks below which is 12183. And I got filled on stop loss limit order but the stop loss price (12183) never existed in the bar.. my low price on that bar is 12206 which is not even near my stop price..
Could you please help me why it is happening ? Thanks.

Attachments:
stop_loss.jpg
stop_loss.jpg [ 83.14 KiB | Viewed 8433 times ]

Author:  Dr. Anton Fokin [ Sun Nov 07, 2010 12:06 pm ]
Post subject:  Re: stop loss problem in simulation

Hi,

do you also use trades and quotes in your simulations?

Regards,
Anton

Author:  Dr. Anton Fokin [ Sun Nov 07, 2010 12:13 pm ]
Post subject:  Re: stop loss problem in simulation

Also, if you use multiple time frames in your strategy (bars with different sizes), you can set the execution simulator to use just 5 min bars to simulate fills. Go to Providers window, select Simulatior(execution), go to Properties window, enable Bar Filter and add 5 min bars to the collection of bar sizes.

Please tell us if this helps.

Regards,
Anton

Author:  jamesbond [ Sun Nov 07, 2010 1:26 pm ]
Post subject:  Re: stop loss problem in simulation

Dr. Anton Fokin wrote:
Hi,

do you also use trades and quotes in your simulations?

Regards,
Anton


No. I only use OnBar.

Author:  jamesbond [ Sun Nov 07, 2010 1:32 pm ]
Post subject:  Re: stop loss problem in simulation

Dr. Anton Fokin wrote:
Also, if you use multiple time frames in your strategy (bars with different sizes), you can set the execution simulator to use just 5 min bars to simulate fills. Go to Providers window, select Simulatior(execution), go to Properties window, enable Bar Filter and add 5 min bars to the collection of bar sizes.

Please tell us if this helps.

Regards,
Anton


Hi, I don't get any performance result after I enabled Bar filter in the properities and ran my code.
Could you tell me how to add 5 min bars to the collection of bar sizes ?

Attachments:
stop_loss2.jpg
stop_loss2.jpg [ 46.53 KiB | Viewed 8430 times ]

Author:  Dr. Anton Fokin [ Sun Nov 07, 2010 3:07 pm ]
Post subject:  Re: stop loss problem in simulation

Click on (Collection) ... and then a dialog window will pop up.

Regards,
Anton

Author:  kkkwj [ Tue Nov 09, 2010 9:04 pm ]
Post subject:  Re: stop loss problem in simulation

I don't know exactly if your issue is the same as the one I had in the past, but I recognize the symptoms--you get filled on prices that are not possible after you place your stop. In my case(s), I was getting filled on prices that occurred (in time) before I even placed my stop, a situation that would be impossible in real life.

After some very deep digging into the simulator and how it works, I can say that the problem occurs because of how the simulator determines the most recent price range. If I remember correctly, immediately after you place your stop, the simulator starts checking your stop price against the High Low bounds of each new bar that is constructed.

Suppose you set your stop at the end of a 5 minute bar, when you are also running 30 and 60 minute bars in the simulator. Maybe you've just set the stop halfway through the 30 min or 60 min bar, when the high/low price that will trigger your stop has already occurred in the front half of the 30 or 60 minute bars. Even if future prices do not trigger your stop, the simulator will trigger the stop when the 30 or 60 min bars arrive, since they have a High or Low price that will trigger the stop.

Thus you should do what Anton suggested, and tell the simulator to only use 5 min bars for fills if you are setting stops on 5 minute intervals (or 30/30min, etc).

The same problem occurs when you are building bars from trades, since you have both trades and bars (different time intervals) at work. Good luck.

Author:  jamesbond [ Mon Nov 15, 2010 11:43 pm ]
Post subject:  Re: stop loss problem in simulation

It works now. Thank you Anton and kkkwj !

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/