Download MetaTrader 5

Indicator Miscellaneous Questions

To add comments, please log in or register
Max Enrik
988
Max Enrik  

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
988
Max Enrik  

#Broker Time - Closed for now.

I solve my issue.
 

Max Enrik
988
Max Enrik  

#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
15924
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'  )             ;
Marco vd Heijden
Moderator
5560
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);
}
Max Enrik
988
Max Enrik  
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
988
Max Enrik  
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
5560
Marco vd Heijden  
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
5560
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.
Max Enrik
988
Max Enrik  
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
5560
Marco vd Heijden  

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.

To add comments, please log in or register