Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Strange behaviour with SetStopLoss during backtest
I'm test a strategy with IOG true over an year period.
I have a stop loss like this:
As I'm testing it over the mini DAX basically a bigpoint value is 5 so the stoploss should be 50 euro like
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
Can you help answer these questions from other members on NexusFi?
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.
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?
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.
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:
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.
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.
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
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?
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).
"....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.
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.
--------- 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...
-----------------------------
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:
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:
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 )?
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?