Dealing with 2 couples, like EURGBP && USDJPY at different times

 

Hello freinds,

I need your help:

If I have an open position of EURGBP, and I have also its openning time ( By OrderOpenPrice() ) (f.e. 2009.6.28 13:07:33 ),

and I want to know NOW what was the value of USDJPY at this time (means at 2009.6.28 13:07:33 ) ?

I will appriciate your kind help.

Crossy

 
crossy:

[...] and I want to know NOW what was the value of USDJPY at this time (means at 2009.6.28 13:07:33 ) ?

You can't get the information historically with that degree of precision. iBarShift() and other timeseries functions will let an EA on one chart see price data for a different symbol, but you're limited to M1 bars. You can see the open, high, low, and close for the minute at 2009.6.28 13:07:00 to 2009.6.28 13:07:59, but you can't get an exact price at 33 seconds into the minute.


(And, strictly speaking, the timeseries functions give you bid prices. If you need ask prices you have to assume that the spread now is the same as the spread historically.)

 

You can also use OrderOpenPrice() to get the value.

Here is the reference on how to use it properly: OrderOpenPrice

 
jirimac:

You can also use OrderOpenPrice() to get the value.

Here is the reference on how to use it properly: OrderOpenPrice

I think crossy meant OrderOpenTime(), not OrderOpenPrice(). It looks as though he/she has the open time of an EURGBP trade, and wants to get the price on USDJPY retrospectively at that open time. If so, OrderOpenPrice() isn't going to help.

 

Dammit, just woke up. I should get a shower before trying to think, he he. Was working late night yesterday on my trading EA..

Thanks jjc!

 
jjc wrote >>

You can't get the information historically with that degree of precision. iBarShift() and other timeseries functions will let an EA on one chart see price data for a different symbol, but you're limited to M1 bars. You can see the open, high, low, and close for the minute at 2009.6.28 13:07:00 to 2009.6.28 13:07:59, but you can't get an exact price at 33 seconds into the minute.

(And, strictly speaking, the timeseries functions give you bid prices. If you need ask prices you have to assume that the spread now is the same as the spread historically.)

Thankes JJC, I see,

If you can help me with another small thing, How can I transfer OpenOrdertime() of EURGBP to the M1 chart of USDJPY, Thankes

 
jjc wrote >>

I think crossy meant OrderOpenTime(), not OrderOpenPrice(). It looks as though he/she has the open time of an EURGBP trade, and wants to get the price on USDJPY retrospectively at that open time. If so, OrderOpenPrice() isn't going to help.

Yes jjc, I ment OrderOpenTime() not OrderOpenPrice(). I'm Sorry.

 
crossy:

If you can help me with another small thing, How can I transfer OpenOrdertime() of EURGBP to the M1 chart of USDJPY, Thankes

Assuming that "transfer" means the same thing as your previous question, you can get the index of the M1 bar for USDJPY using the following:


int idxBar = iBarShift("USDJPY", PERIOD_M1, OrderOpenTime(), false);


idxBar can contain -1 if MT4 hasn't yet downloaded the requested historical data. Otherwise, you can then get OHLC for that minute using iOpen("USDJPY", PERIOD_M1, idxBar), iHigh("USDJPY", PERIOD_M1, idxBar) etc. 


These timeseries functions give you historic bid prices. If you need ask prices then you have to make an assumption about the spread. For example, you can add the current spread to a historic price using something like:


double vSpread = MarketInfo("USDJPY", MODE_SPREAD) * MarketInfo("USDJPY", MODE_TICKSIZE);

double vOpenAsk = iOpen("USDJPY", PERIOD_M1, idxBar) + vSpread;

 
jjc wrote >>

Assuming that "transfer" means the same thing as your previous question, you can get the index of the M1 bar for USDJPY using the following:

int idxBar = iBarShift("USDJPY", PERIOD_M1, OrderOpenTime(), false);

idxBar can contain -1 if MT4 hasn't yet downloaded the requested historical data. Otherwise, you can then get OHLC for that minute using iOpen("USDJPY", PERIOD_M1, idxBar), iHigh("USDJPY", PERIOD_M1, idxBar) etc.

These timeseries functions give you historic bid prices. If you need ask prices then you have to make an assumption about the spread. For example, you can add the current spread to a historic price using something like:

double vSpread = MarketInfo("USDJPY", MODE_SPREAD) * MarketInfo("USDJPY", MODE_TICKSIZE);

double vOpenAsk = iOpen("USDJPY", PERIOD_M1, idxBar) + vSpread;

Thankes, You are great

Reason: