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;