Indicator Miscellaneous Questions - page 6

 
He did answer look closer.
 
Marco vd Heijden:

Well if it is about switching timeframes then the timer is not a good option because the timer get's destroyed upon switching frame.

You can create your lines in the OnInit() function, and update them in either the OnTick() or OnTimer() functions.

Also note the ObjectsDeleteAll() in OnDeint() function this will make sure everything gets removed before it is created again on your new frame.

--- 

And additionally if you want to update the lines whenever a new candle arises you can combine the example on previous page with the last one to give you this:

...

If there are any more problems, please show some code. 

I researched your latest comments.

Another 2 great comments. It looks like that code similar (your #18 comment) but that is very different for me.

So, yeah I was feel 'Timer' destroy when I switch frame. But that is very useful for me because my indicator update once in a PERIOD_**'s.

Yeah! I already create main lines in the init() special function, and them updates in OnTimer() function.

(you can understand me more clearly from below code)

...new candle arises you can combine...

If there are any more problems...

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

As I said there is one problem it takes more time. Right now I need to show you some of my indicator code. And I do not use 'switch operator & ObjectMove()' in my indicator.

@Marco

Please let me know is below code is good or what?

What is your advice could I start research widely your latest two comments and could I involve 'switch() and ObjectMove()' to my indicator? (Why I am asking before I do? - because it take a long time.)

(as you see I got more benefit from your #18 commment - and now I am faced dilemma between my below code and your latest two great comments)

//|+--------------------------------------------------------------------------------+
int  init()
{
    EventSetMillisecondTimer( 1250 );
    _CreateLines_M5();

    return(INIT_SUCCEEDED);
}
//|+--------------------------------------------------------------------------------+
int  start()
{
    return(0);
}
//|+--------------------------------------------------------------------------------+
int  deinit()
{
    ObjectsDeleteAll( 0, _prefix );
    return(0);
}
//|+--------------------------------------------------------------------------------+
void OnTimer()
{
    //---
    if ( _dt_Prd_M5 != iTime( Symbol(), _prd_M5, 0 ) )
    {
         _dt_Prd_M5  = iTime( Symbol(), _prd_M5, 0 );
         _CreateLines_M5();
    }
    return;
}
//|+--------------------------------------------------------------------------------+
void _CreateLines_M5( )
{
    //---
    int _dayCnt_M5 = _prd_cnt + 0;
    int    _cnt_M5 = iBarShift( Symbol(), 0, iTime( Symbol(), PERIOD_W1, _dayCnt_M5 ) );
    for ( i = 0; i < _cnt_M5; i++ )
    {
        _time_M5     = Time[i];
        _prdCvrt_M5  = PeriodSeconds( _prd_M5 );
        _timeCvrt_M5 = _time_M5 - ( _time_M5 % _prdCvrt_M5 ) + _prdCvrt_M5;

        _vlineName_M5 = _prefix + "PERIOD_M5 - " + TimeToStr( _timeCvrt_M5, TIME_DATE|TIME_MINUTES );

        if ( _Period < PERIOD_M15 )
        {
            if (
                    ...
                    TimeHour( _timeCvrt_M5 ) == 12
               )
            {
                ObjectCreate ( _vlineName_M5, OBJ_VLINE, 0, _timeCvrt_M5, 0  );
            }
        }
    }
    return;
}

All the best to you man. 

 
Keith Watford:

I don't knpw about anyone else, but I find your mix of font, colours, bold and italic etc distracting and annoying. In fact I couldn't be bothered to read this post.

Completely agree, from the start of the topic I am "jumping" above all these comments.
 
Max Enrik:

I researched your latest comments.

Another 2 great comments. It looks like that code similar (your #18 comment) but that is very different for me.

So, yeah I was feel 'Timer' destroy when I switch frame. But that is very useful for me because my indicator update once in a PERIOD_**'s.

Yeah! I already create main lines in the init() special function, and them updates in OnTimer() function.

(you can understand me more clearly from below code)

...new candle arises you can combine...

If there are any more problems...

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

As I said there is one problem it takes more time. Right now I need to show you some of my indicator code. And I do not use 'switch operator & ObjectMove()' in my indicator.

@Marco

Please let me know is below code is good or what?

What is your advice could I start research widely your latest two comments and could I involve 'switch() and ObjectMove()' to my indicator? (Why I am asking before I do? - because it take a long time.)

(as you see I got more benefit from your #18 commment - and now I am faced dilemma between my below code and your latest two great comments)

//|+--------------------------------------------------------------------------------+
int  init()
{
    EventSetMillisecondTimer( 1250 );
    _CreateLines_M5();

    return(INIT_SUCCEEDED);
}
//|+--------------------------------------------------------------------------------+
int  start()
{
    return(0);
}
//|+--------------------------------------------------------------------------------+
int  deinit()
{
    ObjectsDeleteAll( 0, _prefix );
    return(0);
}
//|+--------------------------------------------------------------------------------+
void OnTimer()
{
    //---
    if ( _dt_Prd_M5 != iTime( Symbol(), _prd_M5, 0 ) )
    {
         _dt_Prd_M5  = iTime( Symbol(), _prd_M5, 0 );
         _CreateLines_M5();
    }
    return;
}
//|+--------------------------------------------------------------------------------+
void _CreateLines_M5( )
{
    //---
    int _dayCnt_M5 = _prd_cnt + 0;
    int    _cnt_M5 = iBarShift( Symbol(), 0, iTime( Symbol(), PERIOD_W1, _dayCnt_M5 ) );
    for ( i = 0; i < _cnt_M5; i++ )
    {
        _time_M5     = Time[i];
        _prdCvrt_M5  = PeriodSeconds( _prd_M5 );
        _timeCvrt_M5 = _time_M5 - ( _time_M5 % _prdCvrt_M5 ) + _prdCvrt_M5;

        _vlineName_M5 = _prefix + "PERIOD_M5 - " + TimeToStr( _timeCvrt_M5, TIME_DATE|TIME_MINUTES );

        if ( _Period < PERIOD_M15 )
        {
            if (
                    ...
                    TimeHour( _timeCvrt_M5 ) == 12
               )
            {
                ObjectCreate ( _vlineName_M5, OBJ_VLINE, 0, _timeCvrt_M5, 0  );
            }
        }
    }
    return;
}

All the best to you man. 

Well if it works and if it doesnt just keep trying.

 
Marco vd Heijden:

Well if it works and if it doesnt just keep trying.

Big thanks!
 

#Broker Time - ReOpen

I read few forums here and there. Maybe my solution either of them. But I did not figure out.

Before this comment - I tried once again. But I can't find solution.
So, I have 2 broker, A and B.

  • A: Vline objects places correct time. Which one I want.    eg: Time 2017.02.18 0:00 also vline object placed same time.
  • B: Vline object placed wrong time ( maybe I am wrong ). eg: Time 2017.02.18 1:00 but vline object place 0:00.
So if someone understand my concern, any comment would be better for me.

Have nice weekend. 

 
Max Enrik:

#Broker Time - ReOpen

I read few forums here and there. Maybe my solution either of them. But I did not figure out.

Before this comment - I tried once again. But I can't find solution.
So, I have 2 broker, A and B.

  • A: Vline objects places correct time. Which one I want.    eg: Time 2017.02.18 0:00 also vline object placed same time.
  • B: Vline object placed wrong time ( maybe I am wrong ). eg: Time 2017.02.18 1:00 but vline object place 0:00.
So if someone understand my concern, any comment would be better for me.

Have nice weekend. 

Would need to see the code
 

Below code gives me different results in two different Brokers.
( My previous comment could help you to understand me )

Thanks in advance. 

void PerioDay()
  {
// High

   ObjectSet("PeriodHigh",OBJPROP_PRICE1,iHigh(Symbol(),PERIOD_D1,0));
   ObjectSet("PeriodHigh",OBJPROP_PRICE2,iHigh(Symbol(),PERIOD_D1,0));

   ObjectSet("PeriodHigh",OBJPROP_TIME1,TimeCurrent());
   ObjectSet("PeriodHigh",OBJPROP_TIME2,TimeCurrent() -(TimeCurrent()-iTime(Symbol(),PERIOD_D1,0)));

// Low

   ObjectSet("PeriodLow",OBJPROP_PRICE1,iLow(Symbol(),PERIOD_D1,0));
   ObjectSet("PeriodLow",OBJPROP_PRICE2,iLow(Symbol(),PERIOD_D1,0));

   ObjectSet("PeriodLow",OBJPROP_TIME1,TimeCurrent());
   ObjectSet("PeriodLow",OBJPROP_TIME2,TimeCurrent() -(TimeCurrent()-iTime(Symbol(),PERIOD_D1,0)));
  }
 

If you mean the values of iHigh and iLow differ between brokers, that is quite common.

2 reasons:

1. Prices vary slightly between brokers, and

2. If the brokers' servers have different GMT offsets, the bars start at different times.

 
honest_knave:

If you mean the values of iHigh and iLow differ between brokers, that is quite common.
2 reasons:
1. Prices vary slightly between brokers, and
2. If the brokers' servers have different GMT offsets, the bars start at different times.

I mean only different Time.

So, there is no chance to solve this issue, please?

Thanks a lot. 

Reason: