models used in strategy tester (all ticks seems inconsistent)

 

I've written a very basic MACD indicator that returns 1 when the MACD crossed upwards through the MACD signal in the PRECEDING sample period (be it 1H, 4H etc), -1 when the MACD crossed downwards through the MACD signal and 0 otherwise. The indicator fires off correctly when I just plot a normal chart (say EURUSD) and add MACD and this macdCross indicator (you can see the 1s, -1s and 0s appear as expected).


I adapted this indicator to a simple EA where I buy when the indicator would have returned +1, sell when the indicator would have returned -1. The EA works correctly when I run it through the strategy tester using "open prices only" as the data model. However, when I change the model to "use every ticks" then the EA no longer works; none of the previous trades appear, and more strangely, even though the MACD charts and the price chart itself look the same, my macCross indicator no longer shows crossovers even when the MACD lines clearly intersect! In both instances, my time period is set to "H1"


This makes me wonder; does "use every tick" use the most granular data avaiable in MT4 (tick by tick, or minute-wise OHLC) to create an equivalent hourly OHLC bar (so the open is literally the first minute's open, the low is the lowest low, the high the highest high etc)? Or does the time period become moot once I select "use every tick" (so the EA is evaluated on a tick-by-tick basis, not H1 anymore)? I'm looking to test an EA that enters on an hourly basis (i.e. uses only completed hourly MACD bars/whatever other indicator) but can T/P, S/L or exit at a more granular level. Even though I've set explicit T/P and S/L levels in the trades I create, the chart produced by the strategy tester suggests those exits are only executed at the next hour once the levels have been breached, rather than at the T/P or S/L levels themselves


Appreciate any advice.

Files:
 

Hi

Use this around the entry code then on back tester there should be no difference in entry positions between tester modes.


if (timeold!=Time[0]){
timeold=Time[0];


Entry code here ------


}


The back tester uses minute data as every tick data at higher timescales. Your TP & SL should work when hit. You can check when they occur by slowing down the visual mode at the trade and see if they happen at the start or in the middle of the candle. So long as they are within the H & L of the candle they are probably working correctly. Check if there are any errors in the journal because I have found the back tester trades even if it doesn't manage to find the indicators it requires due to code typing mistakes.