NexusFi: Find Your Edge


Home Menu

 





Strange behaviour with SetStopLoss during backtest


Discussion in MultiCharts

Updated
    1. trending_up 3,715 views
    2. thumb_up 7 thanks given
    3. group 4 followers
    1. forum 15 posts
    2. attach_file 6 attachments




 
Search this Thread

Strange behaviour with SetStopLoss during backtest

  #1 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25

Hello Everyone,

I'm test a strategy with IOG true over an year period.
I have a stop loss like this:

 
Code
SetStoploss(stopLossPoint * bigpointvalue);
As I'm testing it over the mini DAX basically a bigpoint value is 5 so the stoploss should be 50 euro like

 
Code
setstoploss(50);
Now according to the Multichart guidelines setstoploss are executed INTRABAR in any case ( IOG true or false doesn't matter) as long as the loss condition are confirmed. So I suppose that after I'm losing 50 euros it should fire a market exit order and of course I can accept a slippage but What is happened in this case?? How can it wait for 154 point BEFORE exit?? it's aroung 800 euro of loss... it doesn't make sense...




I want to believe that during real time strategy automation this things cannot happen because the setstoploss should send an order to the broker immediately after the entry position so it should have been executed almost around 50 euros of loss.
Am I correct?

So how can you explain the behaviour in the screenshot? Is it a simple BUG of multichart? Of course it's not so common to see so "just" one error like this will not be a problem but I want to be sure that with REAL signal automation this cannot happen.

Regards,

DAvid

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

David,

what resolution did you use for the bar magnifier? Keep in mind at what without the bar magnifier your code will be computed four times per bar and your fills could be displayed at either the Open, High, Low and Close only.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25



ABCTG View Post
David,

what resolution did you use for the bar magnifier? Keep in mind at what without the bar magnifier your code will be computed four times per bar and your fills could be displayed at either the Open, High, Low and Close only.

Regards,

ABCTG

I have 1 tick resolution ( I supposed the lowest resolution I have then the accurate will be the backtest):



I still don't understand why it suppose to sell after 158 points intead of 10 (the actual stoploss points). Could it be a real bug?

Anyway I should't have any problem in real auto trading because with IOG true all the code are processed every tick , included the SetStopLoss. Is that correct?

Thanks and Regard,

David

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

David,

do you have the 1 tick data for that date in question? Try plotting a tick chart on that date.

I would check the symbol settings in Quotemanager to make sure that they are correct. Wrong settings there could result in the stop being placed at different locations than you would expect it, too.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #5 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


ABCTG View Post
David,

do you have the 1 tick data for that date in question? Try plotting a tick chart on that date.

I would check the symbol settings in Quotemanager to make sure that they are correct. Wrong settings there could result in the stop being placed at different locations than you would expect it, too.

Regards,

ABCTG

I'm currently using the Iq feed trial ,I don't think that I can use tick data so many day ago... I can only have around a month of tick data during the trial. In the screenshot I was using minutes bar (3 or 5 minutes as I remember correctly) so I have minute data.
BTW: But I didn't receive any error about bar magnifier during backtesting so I suppose it has downloaded some tick data for intrabar precision testing.


I checked the symbol in the quote manager and it seems all correct (minidax):





Something similar also happen TODAY but with setbreakeven:
I was actually searching a way to move the stoploss close to the entryprice (or even above) when the position of an entry is having more than 20 tick of gain ( with 5euro of bigpointvalue it's 100$) and I decided to test the setBreakeven by this way:


 
Code
if (openpositionprofit = 100) then setbreakeven(50);
and this is another screenshot of the backtesting of my strategy applied to the miniDax today:



Now the signal made a short at 12015 then the price dropped down to 11976 and then up. As you can see the strategy buyToCover has been filled almost at the same price as the entry (12015). With the setbreakeven(100), that is about 20 tick of gain, the exit should have been triggered at 10 points less than 12015... so arount 12005, but nothing happened.
The exit that you see in the screenshot is correct for my strategy but it should have been anticipated by the breakeven.

Another mistery...

What do you think?

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

David,

if you don't think you have tick data for that day and assuming that there is none, the testing would have been done without the bar magnifier on that day, which in turn would explain your results.

You have configured your symbol to move in .01 intervals (the tick movement is determined by multiplying price scale and min. movement).

I would suggest checking the definition of the SetBreakEven reserved word in the documentation. It's not designed to move the stop to any other place than your entry price.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


ABCTG View Post
David,

if you don't think you have tick data for that day and assuming that there is none, the testing would have been done without the bar magnifier on that day, which in turn would explain your results.

ABCTG

That's an interesting point and it probably explane the fact. So multichart doesn't alert you if you have barmagnifier active AND you don't have tick data.... Maybe it was my assumption to have tick data wrong.

Anyway I think I Can assume that in Automated real trading the Stop loss would be triggered and I'll never see it skipped like in the backtest


ABCTG View Post
David,

You have configured your symbol to move in .01 intervals (the tick movement is determined by multiplying price scale and min. movement).

ABCTG

That configution was the DEFAULT configuration came from the option: "use Exchange settings" and I only put the bigpointvalue at 5€.
The trades list in backtest is showing correct values for any trade so I supposed it was ok. Plus the chart work correctly and I only see entries and exits at integer values , also bid and ask are integer values like for example 12300,00 as it should be.
Can you confirm that the configuration of the symbol is ok?



ABCTG View Post
David,

I would suggest checking the definition of the SetBreakEven reserved word in the documentation. It's not designed to move the stop to any other place than your entry price.

Regards,

ABCTG

I'm confused here. Accordingly to the link and general multichart guideline the setbreaken should generate a stop order when a profit value is reached allowing to exit the position without lose and even with gain (so far from the entryprice, that's the purpose).

from https://www.multicharts.com/features/entry-and-exit-strategies/:

"....Define the profit needed to trigger this order, and once it triggers it will become active. If the price is reached, then the order will be executed."


Supposed I'm shorting at 12015 and then after the price drop below 11995 I want to be sure to earn AT LEAST 10 points. So when I reach 11995 I should generate a SetBreakeven(100) (100 is 10 * bigpointvalue in my case minidax).

I would like to understand how to protect my gain when a succesfull entry is generating for example 20 tick of profit and then set a condition that guarantee at least 10 tick in my pocket in case of drop down. I thought that breakeven would be a solution but maybe I'm wrong.

Thanks and Regards,

Reply With Quote
  #8 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

David,

in my opinion the symbol configuration is not correct, as the Mini Dax doesn't move in 0.01 increments. One of the benefits of Multicharts is that you can use a variety of different data feeds. The downside is that it requires the user to make some configurations. You should always check the symbol settings and confirm them with the exchange website (for example) to ensure they are correct. In your case it might not matter, but as soon as you are trying to compute the value of one tick or something along that lines it will matter.

Regarding the SetBreakEven reserved word it "Closes out the entire position or the entry if it is at the break even point after the profit has reached the specified value" (this is the first sentence from the wiki link.
It will not place a stop at X ticks profit. The amount you set it's one input is the amount of profit at which this order will be placed, but the stop will always be placed at the break even price.
You would have to code your own exit at break even + x ticks in case you want such an exit.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #9 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25

--------- EDIT UPDATE---------
After some test the pyramidal percentTrailing is PARTIALLY working but I still have to verify what's wrong. So I'll edit later the post to correct it. I don't want to leave wrong questions on the forum thanks...
-----------------------------



ABCTG View Post
David,

in my opinion the symbol configuration is not correct, as the Mini Dax doesn't move in 0.01 increments. One of the benefits of Multicharts is that you can use a variety of different data feeds. The downside is that it requires the user to make some configurations. You should always check the symbol settings and confirm them with the exchange website (for example) to ensure they are correct. In your case it might not matter, but as soon as you are trying to compute the value of one tick or something along that lines it will matter.

ABCTG

I thought about this a lot because even if my backtest are showing correct prices into the list of trades I'm really GETTING MAD to use some basic function of multichart like the entryprice, the setPercentTrailing, and the openPositionProfit.
At the beginning I thought it was due an error of mine during the strategy code writing. But now I'm thinking that it is possible that the funtions mentioned above are actually calculating wrong values due to wrong symbol setting. Would it be possible ?

Let me show an example. I've printed inside the block "if marketposition = -1" the openPositionProfit for my strategy over the minidax and as you can see those values are not correct because the minimum movement is 5 euro so they all should be multiples of 5 euro and not those kind of values:


 
Code
openpositionprofit is :   -6.00
openpositionprofit is :  -11.00
openpositionprofit is :  -11.00
openpositionprofit is :    4.00
openpositionprofit is :    9.00
openpositionprofit is :    4.00
openpositionprofit is :   14.00
openpositionprofit is :   -1.00
openpositionprofit is :   -6.00
openpositionprofit is :   -1.00
openpositionprofit is :   -6.00
openpositionprofit is :  -11.00
openpositionprofit is :  -16.00
openpositionprofit is :  -26.00
openpositionprofit is :  -31.00
openpositionprofit is :  -36.00
openpositionprofit is :  -41.00
openpositionprofit is :  -46.00
openpositionprofit is :  -51.00
openpositionprofit is :  -46.00
openpositionprofit is :  -41.00
openpositionprofit is :  -51.00
openpositionprofit is :  -41.00
openpositionprofit is :  -46.00
openpositionprofit is :  -41.00
openpositionprofit is :  -46.00
openpositionprofit is :  -51.00

Please note that the strategy has a lot of open positions with more than 10 , 20 even 50 points of earning with respectively should match a profit of 50, 100 even 250 euro of earning. The list above should have many many HIGHER vaues so there must be something wrong.

This would also explane why my attemp to create a sort of pyramidal percentTrailing like this is not working as it should:

 
Code
if marketposition = -1 then 
begin	 
	 if ( openpositionprofit >= 50  and openpositionprofit < 99 ) then SetPercentTrailing(50, 90);
	 if ( openpositionprofit >= 100 and openpositionprofit < 149) then SetPercentTrailing(100, 55);
	 if ( openpositionprofit >= 150 and openpositionprofit < 199 ) then SetPercentTrailing(150, 35);
	 if openpositionprofit >= 200  then SetPercentTrailing(200, 20);

....
Sometimes with my strategy I had very good earning positions that was gaining 40 points and then closed in stoploss.
So something like the serPercentTrailing would be useful to avoid those things to happen.

Anyway something around the openpositionprofit calculation must be wrong. Would you suggest me what kind of values should I set for the MINI DAX symbol? ( it is DXM# on iqfeed )?

Thanks as always,

Regards

Reply With Quote
  #10 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


David,

Multicharts will compute some metrics based on the symbol settings. This means wrong symbol settings can result in wrong results. I would suggest studying the help files regarding the symbol configuration, as it makes sense to understand what settings will affect the outcome. Otherwise you might run into the same issue again with different symbols.
This should get you going: https://www.multicharts.com/trading-software/index.php/Setting_Properties

Based on the description in the link, what settings would you suggest for the mini Dax in the MC Quotemanager?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on April 7, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts