help code - different behavior from backtest

Questions about MultiCharts and user contributed studies.
auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

help code - different behavior from backtest

Postby auato » 27 Jan 2020

The weird thing that happes is described below.
This code triggers the entries on the main stream "Data1" (regular bars 4H) taking care of two Supertrend indicators on the main stream Data1 (but you cal also consider other indicators like ma and so on) and looking constanltly at a second data stream (Data2) with a lower time resolution (15 minutes) that is the same instrument but in heikin-ashi. IOG is true. It enters at market with a buy when the close of Data1 bar is over both STs (or if lower it sells contracts at market) and if the current heikin-ashi bar and the last two heikin-ashi bars have their close higher than their open. The backtest looks very nice but it doesn't reflect what happens in the real world because in the reality it never enters. And from the chart you can see the entries but they didn't occur in the reality. It looks like it runs the trades over the heikin ashii bars instead of the regular bars. Please can you check the code below that I am using if has incorrect parts?

Code: Select all

[IntrabarOrderGeneration=True] .... st1 = SuperTrend(ATRLength1, ATRMult1, Strength1, strend1); st2 = SuperTrend(ATRLength2, ATRMult2, Strength1, strend2); if marketposition = 0 and close > st1 and close > st2 and Close of data2>Open of data2 and C[1] of data2>O[1] of data2 and C[2] of data2>O[2] of data2 then buy ("L") 1 contracts next bar at market;
Untitled.png
(37.24 KiB) Not downloaded yet
Untitled2.png
(27.82 KiB) Not downloaded yet
Thank you

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: help code - different behavior from backtest

Postby TJ » 27 Jan 2020

As a practice, you should always use the fastest resolution as data1.

For more assistance, see post #18
[FAQ] Multiple Time Frame, Multi-Data Analysis
viewtopic.php?t=10811

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: help code - different behavior from backtest

Postby auato » 27 Jan 2020

Thanks TJ, is this rule mandatory?

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: help code - different behavior from backtest

Postby auato » 27 Jan 2020

if so I could move the Data1 from 240minutes (4H) to 5m (just to have the main stream lower than Data2 as TJ suggest me) but I need to change and translate the SuperTrend parameters to fit them on the new time frame. I'm using the Supertrend indicator from Big Mike (.ela code imported from futures.io) and the current setting are 1-1-1 (ATRLength, ATRMult, Strength) for the fastest and ATRLength=10, ATRMult=3, Strength=1 for the lowest. How can I change these parameters moving from 240minutes to 5 minutes? can anybody -math expert- help me in this conversion? Thanks

User avatar
Anna MultiCharts
Posts: 560
Joined: 14 Jul 2017
Has thanked: 42 times
Been thanked: 141 times

Re: help code - different behavior from backtest

Postby Anna MultiCharts » 16 Mar 2020

Hello auato,

You could run optimization of your strategy with the new timeframes, analyze the results and apply those inputs with which the strategy results are mostly the same compared to your previous setup.


Return to “MultiCharts”