Download MetaTrader 5

MQL4 Horizontal Object (specific time)

To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
mostafalotfi
185
mostafalotfi 2014.01.29 08:46 

Hello Guys

im using the below code to draw horizontal lines

 ObjectCreate("حد بالا", OBJ_HLINE, 0, Time[0], TL_d, 0, 0);
 ObjectSet("حد بالا", OBJPROP_TIMEFRAMES, OBJ_PERIOD_D1 | OBJ_PERIOD_H1);
 

it works fine and it draw line for whole chart, now i want to change it to draw it for specific time .... how can i make it ? i want to draw it for one week only, or one day only.

Thanks

Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.29 08:52  
mostafa:

Hello Guys

im using the below code to draw horizontal lines

it works fine and it draw line for whole chart, now i want to change it to draw it for specific time .... how can i make it ? i want to draw it for one week only, or one day only.

Thanks

Use a trend line instead . . . OBJ_TREND
mostafalotfi
185
mostafalotfi 2014.01.29 09:14  
RaptorUK:
Use a trend line instead . . . OBJ_TREND


Hi Simon

something like this?

 ObjectCreate("حد بالا", OBJ_TREND, 0, TIME 1, TL_d, TIME 2, 0);

Imagine today is Sunday and i want to draw a line for coming week, what should i put int he Time 1 and Time 2?

Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.29 09:42  
mostafa:


Hi Simon

something like this?

Imagine today is Sunday and i want to draw a line for coming week, what should i put int he Time 1 and Time 2?

TimeCurrent() + (PERIOD_W1 * 60) maybe ? in a hurry, gotta run . . .
Tjipke de Vries
6314
Tjipke de Vries 2014.01.29 10:08  
mostafa:


Hi Simon

something like this?

Imagine today is Sunday and i want to draw a line for coming week, what should i put int he Time 1 and Time 2?


Time1 is same as iTime(Symbol(),PERIOD_W1,0)

Time2 is 60*60*24*7 seconds more then time1

mostafalotfi
185
mostafalotfi 2014.01.29 10:56  
deVries:


Time1 is same as iTime(Symbol(),PERIOD_W1,0)

Time2 is 60*60*24*7 seconds more then time1


Hi

when i put the parameter you mentioned, i can manage the end of HLine but i cannot fix the start of HLINE ( by analyzing the previous Week i want to put a HLINE for current week. do we have a parameter that show the start time/end time of a candle?

c

Simon Gniadkowski
Moderator
17999
Simon Gniadkowski 2014.01.29 11:02  
mostafa:


Hi

when i put the parameter you mentioned, i can manage the end of HLine but i cannot fix the start of HLINE ( by analyzing the previous Week i want to put a HLINE for current week. do we have a parameter that show the start time/end time of a candle?

c

There is no end time for a candle, only a start time.
Keith Watford
Moderator
9620
Keith Watford 2014.01.29 11:38  

As Raptor has already told you, use a trend line.

Although you have to input a time parameter when drawing a horizontal line, only the price is used and so the line will be the full width of your chart.

If you want your line to start and end at certain times, use OBJ_TREND

mostafalotfi
185
mostafalotfi 2014.01.29 11:39  

Hi

iTime(NULL,PERIOD_W1,0)

im using the above code for Time1 but its not working,

ObjectCreate("حد بالا", OBJ_TREND, 0,iTime(NULL,PERIOD_W1,0),TL, 60*60*24*7, TL);
Keith Watford
Moderator
9620
Keith Watford 2014.01.29 11:57  

60*60*24*7

is not a time, it is the amount of seconds in a week

iTime(NULL,PERIOD_W1,0) + (60*60*24*7)

might do what you want

mostafalotfi
185
mostafalotfi 2014.01.29 12:02  

Hello Guys

this one worked for me :) thank you all

Thank you GumRai, Simon, DevRies

but i think i should be careful about those weeks that has holidays i guess :)

ObjectCreate("حد بالا", OBJ_TREND,0,iTime(NULL,PERIOD_W1,q),TL,iTime(NULL,PERIOD_W1,q)+60*60*24*7,TL);
12
To add comments, please log in or register