iATR in backtest for another period?

 

Hi

I'm trying to get some take profit targets using iATR in MT4, in normal charts, I can simply use

 iATR(NULL, PERIOD_M5, 14, 0)

But when I set the time frame for back test on 1 minute, this code returns 0, I am using tick data that was exported from tick story and I have 5 minute tick data in the history folder, how can I solve this for back testing?

thanks

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 
Alireza Khodakarami:

Hi

I'm trying to get some take profit targets using iATR in MT4, in normal charts, I can simply use

But when I set the time frame for back test on 1 minute, this code returns 0, I am using tick data that was exported from tick story and I have 5 minute tick data in the history folder, how can I solve this for back testing?

thanks

simple but did you use PERRIOD_CURRENT and / or PERRIOD_M1?

iATR(NULL, PERRIOD_CURRENT , 14, 0)
 
MEHMET FATIH BARUT:

simple but did you use PERRIOD_CURRENT and / or PERRIOD_M1?

That would give me the current period, I don't want the current period but the periods above the current

 
Alireza Khodakarami:

That would give me the current period, I don't want the current period but the periods above the current


input ENUM_TIMEFRAMES atrTF = PERIOD_CURRENT;

//--

iATR(NULL, atrTF , 14, 0)

Make an input

 
That won't solve anything, if you pay attention, in my first post i am mentioning that the time frame is 5 minute, but the back test is on 1 minute. It would work 100% if it was not on back testing but when I am back testing, any time frame other than the chosen time frame will not work and return 0 even though I have complete tick data
 
Alireza Khodakarami: I can simply use
 iATR(NULL, PERIOD_M5, 14, 0)
  1. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

  2. Don't use bar zero, as you won't have an accurate average. In your case you have (13 valid ranges + zero initially) / 14. Don't you want 14 valid ranges / 14?
  3. Don't use NULL.
    • You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
    • Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    • Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    • MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
 
William Roeder:
  1. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

  2. Don't use bar zero, as you won't have an accurate average. In your case you have (13 valid ranges + zero initially) / 14. Don't you want 14 valid ranges / 14?

All your suggestions are valid except :


1- Even if i get a value that not accurate, it's still acceptable because I'm defining a take profit level using it, so, if it's a point or two inacurate, that is not important.

2- Putting the symbol name did not solve the issue at all

3- As I mentioned multiple times, I have all the real tick data for all the time frames for the dates that I'm trying the back test, it looks like back test engine does not even look for those data at all !