Download MetaTrader 5

iTime for negative shift

To add comments, please log in or register
Add our channel to friends and follow the news!
richo
191
richo 2014.01.27 16:12 

Hi


Can someone please help me how to find the time if the shift value being negative.

Basically I am trying to draw a trendline based on the existing trendline

I am getting objprice1 correctly but the objtime1 always return 0.


Thanks


    datetime objtime1 =  iTime(Symbol(),Period(), shift);
    double objprice1  =  ObjectGetValueByShift(objname, shift);   //shift is a negative value
Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2014.01.27 16:25  
richo:


Hi


Can someone please help me how to find the time if the shift value being negative.

Basically I am trying to draw a trendline based on the existing trendline

I am getting objprice1 correctly but the objtime1 always return 0.

Try something like . . .

if(shift < 0)
   objtime = iTime(Symbol(),Period(), 0) + (Period() * 60 * -1 * shift);
richo
191
richo 2014.01.27 16:44  
RaptorUK:

Try something like . . .


Thanks. It works. I should have asked this before, I was breaking my head for the past 3 hours for this.

richo
191
richo 2014.01.28 17:18  

Hi RaptorUK


I was wondering what will happen if a week end falls in between? should I have to add any further codes.


Thanks

Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2014.01.28 17:27  
richo:

Hi RaptorUK


I was wondering what will happen if a week end falls in between? should I have to add any further codes.

A weekend and holidays with mess with it . . . you can either live with it or try and address the issue.
richo
191
richo 2014.01.28 17:32  
okay, thanks.
To add comments, please log in or register