Eaglehawk:
while creating an indicator, reason has arisen to convert a distance between two datetime variable into a number of bars
while creating an indicator, reason has arisen to convert a distance between two datetime variable into a number of bars
Try this:
int NumBars = MathRound((EndTime - StartTime)) / (Period*60));
[/PHP]
Or maybe more precise in some cases:
[PHP]
int StartShift = iBarShift(NULL,0,StartTime,false);
int EndShift = iBarShift(NULL,0,EndTime,false);
int NumBars = StartShift - EndShift;
Michel:
Try this:
Try this:
int StartShift = iBarShift(NULL,0,StartTime,false);
int EndShift = iBarShift(NULL,0,EndTime,false);
int NumBars = StartShift - EndShift;
this looks precise, and it makes sense,
thanks again for the help!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
i've been away from metrader 4 for a while, so my coding is a little rusty, while creating an indicator, reason has arisen to convert a distance between two datetime variable into a number of bars, i think i may have it, but i'm not so sure about subtraction of datetimes, will these expressions do the trick?
datetime center_time = ObjectGet(line,OBJPROP_TIME1);//horizontal refrence to center, or left point of line
double center_height = ObjectGet(line,OBJPROP_PRICE1);//vertical refrence to center, or left point of line
datetime radius_time = ObjectGet(line,OBJPROP_TIME2);//horizontal refrence to outer, or right point of line
double radius_height = ObjectGet(line,OBJPROP_PRICE2);//vertical refrence to outer, or right point of line
double Distance_g = (radius_time - center_time)/Period();line is a variable that represents a line already drawn.
thanks in advance for any and all help.