iHigh from other pairs

 

Hi,

I am simply using iHigh() and iLow() to get information from other pairs 

iHigh(Currency[i], 15, 1)-iLow(Currency[i], 15, 1);

where Currency[i] is array of defined currencies and I am accessing them one by one using loop, 15 is the time frame, and 1 is the last closed candle.

These pairs are closed on my chart, hence I got iHigh(Currency[i], 15, 1) and iLow(Currency[i], 15, 1) of previous candles, not the last closed one.

Can you help about this please ?

 
ehsanalrawie:

Hi,

I am simply using iHigh() and iLow() to get information from other pairs 

iHigh(Currency[i], 15, 1)-iLow(Currency[i], 15, 1);

where Currency[i] is array of defined currencies and I am accessing them one by one using loop, 15 is the time frame, and 1 is the last closed candle.

These pairs are closed on my chart, hence I got iHigh(Currency[i], 15, 1) and iLow(Currency[i], 15, 1) of previous candles, not the last closed one.

Can you help about this please ?



please clarify.

can you attach screenshot?

 
Mohammad Soubra:


please clarify.

can you attach screenshot?


Ok, I am using the following function to detect hammers on other charts and time frames (which are already closed).

This line (TimeToStr(iTime(Currency[i], 15, 1), TIME_MINUTES)) must print the time of the previously closed candle if it has the conditions, but unfortunately I am getting the time of very previous candles which has the same conditions, but I want that only for the last closed candle. May be I need to refresh or update the chart before testing its candles.


void M15()
  {
      for(int i=0; i<ArraySize(Currency); i++)
      {
         double Length1, Length2, Length3, Tail1, Body1, Head1;
         Length1 = iHigh(Currency[i], 15, 1)-iLow(Currency[i], 15, 1);
         Length2 = iHigh(Currency[i], 15, 2)-iLow(Currency[i], 15, 2);
         Length3 = iHigh(Currency[i], 15, 3)-iLow(Currency[i], 15, 3);
         
         if(iOpen(Currency[i], 15, 1)> iClose(Currency[i], 15, 1))
         {
            Tail1 = iHigh(Currency[i], 15, 1)-iOpen(Currency[i], 15, 1);
            Body1 = iOpen(Currency[i], 15, 1)-iClose(Currency[i], 15, 1);
            Head1 = iClose(Currency[i], 15, 1)-iLow(Currency[i], 15, 1);
         }
         else
         {
            Tail1 = iOpen(Currency[i], 15, 1)-iLow(Currency[i], 15, 1);
            Body1 = iClose(Currency[i], 15, 1)-iOpen(Currency[i], 15, 1);
            Head1 = iHigh(Currency[i], 15, 1)-iClose(Currency[i], 15, 1);
         }
         
         if(Length1>Length2 && Length1>Length3 && Length1>0.00050)
         {
            if(Tail1>(1.5*Body1) && Tail1>(2*Head1) && Body1>(0.25*Tail1))
            {
               long ID = ChartOpen(Currency[i], 15);
               ChartApplyTemplate(ID, "initial");
               ChartSetString(ID, CHART_COMMENT, "Time ="+TimeToStr(iTime(Currency[i], 15, 1), TIME_MINUTES));
               b=true;
            }
         }
      }
  }
 

Hi, 

See this chart. it detects the very previous candle (with red arrow) but my code was about only the last closed one:

iOpen(Currency[i], 15, 1) ... iLow(Currency[i], 15, 1) ...iClose(Currency[i], 15, 1) ... etc
 
 

I found this article:

Obtaining Data on a Necessary Timeframe out of Intermediate Data

Intermediate HCC files are used as the data source for building price data for requested timeframes in the HC format. Data of HC format are timeseries that are maximally prepared for a quick access. They are created upon a request of a chart or a MQL4 program. The volume of data should not exceed the value of the "Max bars in charts" parameter. Data are stored for further using in files with hc extension.

To save resources, data on a timeframe are stored and saved in RAM only if necessary. If not called for a long time, they are released from RAM and saved into a file. For each timeframe, data are prepared regardless of whether there are ready data for other timeframes or not. Rules of forming and accessing data are the same for all timeframes. I.e., despite the fact that the unit data stored in HCC is one minute (M1), the availability of HCC data doesn't mean the availability of data on M1 timeframe as HC in the same volume.

Receipt of new data from a server calls automatic update of used price data in HC format of all timeframes. It also leads to the recalculation of all indicators that implicitly use them as input data for calculations.

on this link: 

https://docs.mql4.com/series/timeseries_access

Organizing Data Access - Timeseries and Indicators Access - MQL4 Reference
Organizing Data Access - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
Before price data become available in the MetaTrader 4 terminal, they must be received and processed. To receive data, connection to the MetaTrader 4 trade server must be established. Data are received in the form of packed blocks of minute bars from the server upon the request of a terminal. The mechanism of server reference for data doesn't...
 
ehsanalrawie:

Ok, I am using the following function to detect hammers on other charts and time frames (which are already closed).

This line (TimeToStr(iTime(Currency[i], 15, 1), TIME_MINUTES)) must print the time of the previously closed candle if it has the conditions, but unfortunately I am getting the time of very previous candles which has the same conditions, but I want that only for the last closed candle. May be I need to refresh or update the chart before testing its candles.

  1. Length1 = iHigh(Currency[i], 15, 1)-iLow(Currency[i], 15, 1);
    There are no such functions in MT5. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. The article you mention is for MT5. On MT4: Unless the current chart is the specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. if(Length1>Length2 && Length1>Length3 && Length1>0.00050)
    Don't hard code 5 pips. Fails on JPY pairs. Using Points means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
              How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum

  4. You are not looking at other timeframes, only M15. Your M15 function has no context, we can't know wether you are calling it per tick or when the current symbol's bar completes. Just because the current bar completes, does not mean the other pair's has. Use iBarShift and verify (after № 2.)

  5. Your Currency[] has no context.  Broker's use a variety of naming patterns: EURUSD, EURUSDc, EURUSDct, EURUSDi, EURUSDm, EURUSDecn, EURUSDpro, "EUR.USD", "EUR/USD", "EURUSD.", "EURUSD..", "EURUSD.G", "EURUSD.SBe", "EURUSD.stp", "EURUSD+", "EURUSD-sb", etc. Does your array match your pattern.

  6. Why over complicate this with other symbols and opening new charts. Just write it to detect on the current chart only and then place it of other charts and your done.

 

Ok, 

My main question is that : 

When I am executing  iHigh(EURUSD, 15, 1) ;

I am not getting the High of the last closed candle (shift=1), but I am getting the High of the previous 5th or more candle

Note: This EA is running on EURUSD chart and I am trying to get iHigh of last closed candle (shift=1) on GBPUSD (which is closed chart).

 
ehsanalrawie: I am not getting the High of the last closed candle (shift=1), but I am getting the High of the previous 5th or more candle
Asked and answered. #6.2
 

Hi, whroeder1

this exactly what I need, when dealing with other chart how to load history before testing the bars. I do not know how to do that.


 
ehsanalrawie: I do not know how to do that.
Asked and answered. #6.2 Do you know how to click your mouse on a link?
Reason: