Download MetaTrader 5

miscellaneous questions

To add comments, please log in or register
Articles have already helped many traders. Come and read them!
Max Enrik
816
Max Enrik 2016.11.17 12:03 

Hi,

#Broker Time

 

I spent few hours for reading some comments, but I did not figure out how can I set my Broker Time to my indicators / how can I set my indicators to my Broker Time. (maybe I confused)

My Broker Time starts from 01:00, but all my indicators works from 00:00.

So how can I solve my issue?

 

Please help me.

Thanks.

(English is not my native language.) 

Max Enrik
816
Max Enrik 2016.11.17 13:50  

#Broker Time - Closed for now.

I solve my issue.
 

Max Enrik
816
Max Enrik 2016.11.18 16:07  

#Month OBJ_VLINE

I need to create Months lines, but I struggle.

int _prd = PERIOD_MN1;
int _cnt_MN1 = iBarShift( Symbol(), 0, iTime( Symbol(), PERIOD_MN1, 0 ) );
for ( int i = 0; i < _cnt_MN1; i++ )
{
    //---date & time
    datetime _time          = Time[i]                                               ;
    datetime _prd_time      = iTime( Symbol(), _prd, 0 )                            ;
    datetime _timeCvrt_MN1  = _time + ( _time % _prd_time ) - PeriodSeconds( _prd ) ;
    //---name
    string   _vlineName_MN1 = _prefix + "PERIOD_MN1 - " + TimeToStr( _timeCvrt_MN1, TIME_DATE )    ;

    if ( _Period < PERIOD_MN1 )
    {
        ObjectCreate( _vlineName_MN1, OBJ_VLINE     , 0, _time, 0 )                 ;
        ObjectSet   ( _vlineName_MN1, OBJPROP_COLOR , C'180,160,080'  )             ;
    }   //---if Close
}   //---for Close

Can someone, please me?

Best 

whroeder1
14457
whroeder1 2016.11.18 16:49  
You know when the month began: iTime(_Symbol, PERIOD_MN1, 0) No need for the loop, or all the rest. Just draw the line.
datetime BOM = iTime( Symbol(), PERIOD_MN1, 0 ); // Beginning of the month.
string   _vlineName_MN1 = _prefix + "PERIOD_MN1 - " + TimeToStr( BOM, TIME_DATE )    ;
ObjectCreate( _vlineName_MN1, OBJ_VLINE     , 0, BOM, 0 )                 ;
ObjectSet   ( _vlineName_MN1, OBJPROP_COLOR , C'180,160,080'  )             ;
Marco vd Heijden
Moderator
4680
Marco vd Heijden 2016.11.18 20:32  
int _cnt_MN1 = 12; // 12 lines for a year 24 for two years and etc.
for ( int i = 0; i < _cnt_MN1; i++ )
{
   ObjectCreate(0,"PERIOD_MN1-"+IntegerToString(i),OBJ_VLINE,0,iTime(Symbol(),PERIOD_MN1,i),0);
   ObjectSetString(0,"PERIOD_MN1-"+IntegerToString(i),OBJPROP_TOOLTIP,TimeToString(iTime(Symbol(),PERIOD_MN1,i),TIME_DATE));
   ObjectSetInteger(0,"PERIOD_MN1-"+IntegerToString(i), OBJPROP_COLOR , C'180,160,080'  );
   //ObjectSetInteger(0,"PERIOD_MN1-"+IntegerToString(i),OBJPROP_STYLE,STYLE_DOT);
   //ObjectSetInteger(0,"PERIOD_MN1-"+IntegerToString(i),OBJPROP_WIDTH,1);
}
Max Enrik
816
Max Enrik 2016.11.18 20:45  
whroeder1:
You know when the month began: iTime(_Symbol, PERIOD_MN1, 0) No need for the loop, or all the rest. Just draw the line.
datetime BOM = iTime( Symbol(), PERIOD_MN1, 0 ); // Beginning of the month.
string   _vlineName_MN1 = _prefix + "PERIOD_MN1 - " + TimeToStr( BOM, TIME_DATE )    ;
ObjectCreate( _vlineName_MN1, OBJ_VLINE     , 0, BOM, 0 )                 ;
ObjectSet   ( _vlineName_MN1, OBJPROP_COLOR , C'180,160,080'  )             ;

Thanks for the quick response and your comment.

Also I tried your code, but I see only one previous month 2016/10

But I need to create Months Lines from currently year and future one.

example: Month starts from - January 2016 - February 2016 - March 2016 - ... till December 2016

 

I hope you clearly understand me now.

So, what can I do for it, please?

Thanks in advance.

Max Enrik
816
Max Enrik 2016.11.18 20:50  
Marco vd Heijden:
int _cnt_MN1 = 12; // 12 lines for a year 24 for two years and etc.
for ( int i = 0; i < _cnt_MN1; i++ )
{
   ObjectCreate(0,"PERIOD_MN1-"+IntegerToString(i),OBJ_VLINE,0,iTime(Symbol(),PERIOD_MN1,i),0);
   ObjectSetString(0,"PERIOD_MN1-"+IntegerToString(i),OBJPROP_TOOLTIP,TimeToString(iTime(Symbol(),PERIOD_MN1,i),TIME_DATE));
   ObjectSetInteger(0,"PERIOD_MN1-"+IntegerToString(i), OBJPROP_COLOR , C'180,160,080'  );
   //ObjectSetInteger(0,"PERIOD_MN1-"+IntegerToString(i),OBJPROP_STYLE,STYLE_DOT);
   //ObjectSetInteger(0,"PERIOD_MN1-"+IntegerToString(i),OBJPROP_WIDTH,1);
}

You clearly understand me what I am thinking, and I did not see your great comment (while I wrote reply for previous comment)

Much appreciate.

Marco vd Heijden
Moderator
4680
Marco vd Heijden 2016.11.18 20:53  
Max Enrik:

You clearly understand me what I am thinking, and I wrote reply for previous comment (while I did not see your great comment.)

Much appreciate.

Just keep it simple
Marco vd Heijden
Moderator
4680
Marco vd Heijden 2016.11.18 21:07  
    ObjectCreate(0,"Future-H4-",OBJ_VLINE,0,0,0);
    ObjectMove(0,"Future-H4-",0,iTime(Symbol(),PERIOD_H4,0)+PERIOD_H4,0);

MN1 is a bit too far away but here's one for H4.

Also you can use

TimeCurrent()
And move your line in OnTick() or OnTimer() function then it will move along with time.
Max Enrik
816
Max Enrik 2016.11.18 23:18  
Marco vd Heijden:
    ObjectCreate(0,"Future-H4-",OBJ_VLINE,0,0,0);
    ObjectMove(0,"Future-H4-",0,iTime(Symbol(),PERIOD_H4,0)+PERIOD_H4,0);

MN1 is a bit too far away but here's one for H4.

Also you can use

TimeCurrent()
And move your line in OnTick() or OnTimer() function then it will move along with time.

Wow! Big thanks for your comment.

I use below code (which one you mentioned) in my Period Lines Indicator, so that works good for me till 'PERIOD_MN1'.

iTime(Symbol(),PERIOD_*,0)+PERIOD_*

---

I read a bit more about 'Event Handling Functions', but I need advice from professional coder.

Which Function is useful for my this (Hour 4, Day, Week, Month Lines) Indicator?

example: init(), start(), OnTick() or OnTimer() 

Thanks in advance. 

Marco vd Heijden
Moderator
4680
Marco vd Heijden 2016.11.19 01:53  

Well you can draw all lines in OnInit() and then draw new whenever the opentime from the last bar changes you will know there was a new bar.

But i am not sure what exactly you are wanting to do.

123456789
To add comments, please log in or register