Download MetaTrader 5

MQL4 Horizontal Object (specific time)

To add comments, please log in or register
mostafalotfi
185
mostafalotfi  

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
18056
Simon Gniadkowski  
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  
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
18056
Simon Gniadkowski  
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
6433
Tjipke de Vries  
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  
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
18056
Simon Gniadkowski  
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
10533
Keith Watford  

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  

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
10533
Keith Watford  

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  

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