Bar values

Back to topics list To post a new topic, please log in or register
avatar
15
N22 2015.06.22 03:43
 
Hi, is it possible to get bar values (open,close,high,low) of a bar at which a position was opened.
avatar
Moderator
3406
GumRai 2015.06.22 09:31 #
 

Yes.

iBarshift with OrderOpenTime() will give you the shift of the bar

then get  the OHLC values

avatar
15
N22 2015.06.25 07:38 #
 

Thanks for the response GumRai. I have another question is there a way to change the value of the date to be comprehendible instead of (in this example) 1424690100 when using OrderOpenTime(). I was able to use the OrderOpenPrice() successfully but I am having issues with OrderOpenTime().

avatar
484
avatar
Moderator
3406
GumRai 2015.06.26 00:21 #
 
N22:

Thanks for the response GumRai. I have another question is there a way to change the value of the date to be comprehendible instead of (in this example) 1424690100 when using OrderOpenTime(). I was able to use the OrderOpenPrice() successfully but I am having issues with OrderOpenTime().

I believe that if you use #property strict all prints of a datetime variable will be readable as a date, not an integer.

Otherwise, use TimeToStr() 

avatar
15
N22 2015.06.26 04:40 #
 

Ok , I was able to sort out the date issue , but now as seen on the attached images of my Journal  and chart window, my iBarShift doesn’t correspond with my Date. Is there any solution for this? 

{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists)
    {
        Print("Index of the bar for the time ",TimeToStr(OrderOpenTime(),TIME_DATE|TIME_SECONDS)," is ",iBarShift(0,0,TimeToStr(OrderOpenTime(),TIME_DATE|TIME_SECONDS)));
        
    }
}

 

 

  

 

 

avatar
Moderator
3406
GumRai 2015.06.26 04:50 #
 

You don't use a string in iBarShift

iBarShift(Symbol(),0,OrderOpenTime())

 just use OrderOpenTime()

avatar
15
N22 2015.06.26 22:43 #
 
ydrol and GumRai thanks for your time and information it was helpful. 
Back to topics list  

To add comments, please log in or register