How to import bid/ask from another currency pair? - page 2

To add comments, please log in or register
Simone Gill
22
Simone Gill  

Ok I have read through the Market Info documentation and realised you can only pull bid/ask prices. How would I attempt to pull the price data(HLOC) from say 6 bars ago ?


To be honest I have spent allot of time reading through the documentation and it is not as helpful as say other languages like Python or PRT so was just looking for some guidance 

 Kind Regards,

Keith Watford
Moderator
16564
Keith Watford  
Simone Gill:

Ok I have read through the Market Info documentation and realised you can only pull bid/ask prices. How would I attempt to pull the price data(HLOC) from say 6 bars ago ?


To be honest I have spent allot of time reading through the documentation and it is not as helpful as say other languages like Python or PRT so was just looking for some guidance 

 Kind Regards,

Use iOpen(),iClose(),iHigh() and/or iLow()

HosseinKOGO
46
HosseinKOGO  

Hi Pros,

I really got mad when reading this topic, sorry for bringing it up. But since I've had the same issue, I decided comment here.

Here is my code:

double Ask2,Bid2;

----------------------------

void start()

{

Ask2=MarketInfo("GBPUSD",MODE_ASK);
Bid2=MarketInfo("GBPUSD",MODE_BID);
Comment(Ask2, Bid2);

}


The comment shows 00

Why couldn't it import Ask and Bid from another Symbols?


Any advice is appreciated,
Hossein

William Roeder
18697
William Roeder  
HosseinKOGO: Why couldn't it import Ask and Bid from another Symbols?
On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing prices.
          Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
          Timeseries and Indicators Access /  Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
          Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum

HosseinKOGO
46
HosseinKOGO  
William Roeder:
On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing prices.
          Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
          Timeseries and Indicators Access /  Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
          Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum

Thank you for your help.

I use Tick Data Suite from eareview.net and I've downloaded history of my target pairs including GBPUSD before backtesting. In addition, Journal doesn't give me any error. Is it something about integration? Should I look for solution by contacting Tick Data Suite support?

(I use MQL4 for coding)
HosseinKOGO
46
HosseinKOGO  

Can someone try this code while backtesting on GBPAUD -4H chart? I'm really stuck :(
Do you get 00 as comment?

double Ask2,Bid2;

----------------------------

void start()

{

Ask2=MarketInfo("GBPUSD",MODE_ASK);
Bid2=MarketInfo("GBPUSD",MODE_BID);
Comment(Ask2, Bid2);

}
William Roeder
18697
William Roeder  
HosseinKOGO: I use Tick Data Suite from eareview.net and I've downloaded history of my target pairs including GBPUSD before backtesting. In addition, Journal doesn't give me any error. Is it something about integration? Should I look for solution by contacting Tick Data Suite support?(I use MQL4 for coding)

It has nothing to do with TDS. You have to get the terminal to read in the data before accessing it. What part of "before accessing prices" was unclear?

HosseinKOGO: I'm really stuck :( Do you get 00 as comment?

You going to stay that way when you ignore the help you receive. What part of "must handle" was unclear?

HosseinKOGO
46
HosseinKOGO  
William Roeder:

It has nothing to do with TDS. You have to get the terminal to read in the data before accessing it. What part of "before accessing prices" was unclear?

You going to stay that way when you ignore the help you receive. What part of "must handle" was unclear?

Sorry I'm newbie coder and it seems I could not understand what you mean. Actually what I figured out by your advice is "waiting to download history and current price data of the second currency pair before doing anything."

Could you please give me further details about what should I do with this code you had posted?

#define HR2400 PERIOD_D1 * 60    // 86400 = 24 * 3600
int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return( when % HR2400 );            }
datetime DateOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return( when - TimeOfDay(when) );   }
#define SYMBOL string
#define THIS_SYMBOL ""
bool  download_history(ENUM_TIMEFRAMES period=PERIOD_CURRENT){
   return download_history(_Symbol, period); 
}
bool  download_history(
      SYMBOL            symbol=THIS_SYMBOL,     ///< The symbol required.
      ENUM_TIMEFRAMES   period=PERIOD_CURRENT   /**< The standard timeframe.*/){
   if(symbol == THIS_SYMBOL)     symbol = _Symbol;
   if(period == PERIOD_CURRENT)  period = _Period;
   datetime today = DateOfDay();
   ResetLastError();
   datetime other = iTime(symbol, period, 0);
   if(_LastError == 0 
   && today == DateOfDay(other)) return true;   
   if(_LastError != ERR_HISTORY_WILL_UPDATED
   && _LastError != ERR_NO_HISTORY_DATA
      Print(StringFormat("iTime(%s,%i) Failed: %i", symbol, period,_LastError));
   return false;
}

I have copied the upper code into my global area and it gives me error and warnings.

I've copied this line of code into my start function as well:

while(!download_history(PERIOD_M15) ){ Sleep(1000); RefreshRates(); }

Could you please advice me what and where should I insert sufficient information and punctuation?

Again sorry for my low level skill...

William Roeder
18697
William Roeder  
  1. HosseinKOGO: and it gives me error and warnings.

    HosseinKOGO: Could you please give me further details about what should I do with this code you had posted?

    1. You couldn't figure out such minor corrections?
      int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                                return( int(when % HR2400) );            }
      
        if(_LastError != ERR_HISTORY_WILL_UPDATED
         && _LastError != ERR_NO_HISTORY_DATA
         )  Print(StringFormat("iTime(%s,%i) Failed: %i", symbol, period,_LastError));
      

    2. You already posted it for an EA.
      while(!download_history(PERIOD_M15) ){ Sleep(1000); RefreshRates(); }
HosseinKOGO
46
HosseinKOGO  
William Roeder:
    1. You couldn't figure out such minor corrections?

    2. You already posted it for an EA.

Thank you for your response,

In fact I'm not coder however I've tried coding some EAs. My job is connected with creativity and strategy so I brain stormed 600-700 ideas for making EAs and built them till now. I just can code very easy EAs and I'm unaccustomed to your high level coding...

I've put those codes into my EA but it returns just this error:  2019.05.06 15:37:56.586    2018.01.02 00:00:07   MyEA! GBPAUD,H4: iTime(GBPUSD,240) Failed: 0

I'm trying GBPAUD as my opened chart and GBPUSD as my second pair.

What is the problem?

To add comments, please log in or register