MarketInfo not working on Strategy Tester [SOLVED]

 

Hello,


My EA is working fine on live testing on demo accounts, is opening closing and managing trades.

Most of the trades it opens has tp and sl based on the daily pips range.

I check the daily pips range with: 

Range = (NormalizeDouble((MarketInfo(NULL,MODE_HIGH) - MarketInfo(NULL,MODE_LOW)),4));

This works perfectly on live testing, but is always returning 0 on the strategy tester.

Any clue?

 
arimbur:
Range = (NormalizeDouble((MarketInfo(NULL,MODE_HIGH) - MarketInfo(NULL,MODE_LOW)),4));
  1. Be careful with NULL.

    1. On MT4, 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.
    2. 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.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
    5. Cloud Protector Bug? - MQL4 programming forum (2020)

  2. Perhaps you should read the manual. In what calls are MODE_HIGH and MODE_LOW used? Series Array Identifiers - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
William Roeder #:
  1. Be careful with NULL.

    1. On MT4, 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.
    2. 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.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
    5. Cloud Protector Bug? - MQL4 programming forum (2020)

  2. Perhaps you should read the manual. In what calls are MODE_HIGH and MODE_LOW used? Series Array Identifiers - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

This fixed the problem, thank you very much William!