Download MetaTrader 5
To add comments, please log in or register
Register at MQL5.community and leave your comments!
Sidy
15
Sidy 2014.09.26 11:16 
hello, I would like to draw trend lines with line segments. These are static trend line, they will be fixed on a specific period. With your help, I would like to know how to set the start time of the period and the end time. If you have any leads let me know! Kind regards.
Keith Watford
Moderator
7869
Keith Watford 2014.09.26 12:15  
Galsen:
hello,I would like to draw trend lines with line segments.These are static trend line, they will be fixed on a specific period.With your help, I would like to know how to set the start time of the period and the end time.If you have any leads let me know!Kind regards.
Maybe you will be lucky and somebody will understand what you are asking for
Sidy
15
Sidy 2014.09.30 07:36  
I hope so because I do not speak English. I'll try to make me understand.
Sidy
15
Sidy 2014.09.30 07:45  
Avec l'aide de translate.google, je reformule ma question: I want to know how to use the x-axis to time on a trend line to two points?
honest_knave
947
honest_knave 2014.09.30 11:02  

Uncompiled / untested, but it should be something like this:

 

      if(!ObjectCreate(0,LineName,OBJ_TREND,0,StartTime,StartPrice,EndTime,EndPrice))
         {
          Print("ERROR CREATING LINE ", LineName);
         }
      else
         {
          ObjectSetInteger(0, LineName, OBJPROP_RAY, false);
         }
Sidy
15
Sidy 2014.09.30 11:55  
Thank you for your reply. I understand the structure to create a line. But my problem is that I can not use the datetime format. exemple : I want to create a line that covers the day today. ObjectCreate(0,LineName,OBJ_TREND,0,StartTime(00:00AM),StartPrice,EndTime(23:59PM),EndPrice)) . How to write 00:00 AM and 11:59 PM in datetime format ?? thank you.
Keith Watford
Moderator
7869
Keith Watford 2014.09.30 12:09  

Well the simplest way for the start time would be by using iTime on PERIOD_D1. Not infallible as if the D1 chart is updating, you may get an error

You can find midnight today with 

datetime Midnight=TimeCurrent()-(TimeCurrent()%(PERIOD_D1*60));

 (I learnt that from RaptorUK)

and you can then add the number of seconds in a day-60 to get to 11:59 

Sidy
15
Sidy 2014.09.30 14:24  
thank you very much. I think that , I found my answer.
/
To add comments, please log in or register