mt4 - ChartSetSymbolPeriod - slow down - page 2

 
Max-Enrik: Right now I have not any warnings.
What part of
eddie: Clear up yor code. You are mixing start ( ) and OnCalculate ( )
was unclear? Either use the old init/start/deinit or the new OnInit/OnCalculate/OnDeinit. Not both.
Warnings are irrelevant. They are warnings, not errors.
 
WHRoeder:
What part of
eddie: Clear up yor code. You are mixing start ( ) and OnCalculate ( )
was unclear? Either use the old init/start/deinit or the new OnInit/OnCalculate/OnDeinit. Not both.
Warnings are irrelevant. They are warnings, not errors.

Thanks William for the once again for your same question.

I did not mind 'Case Sensitive'.

So I try like below code.

//+------------------------------------------------------------------+
//|                                             Custom Indicator.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property       copyright "Copyright 2016, MetaQuotes Software Corp."
#property       link      "https://www.mql5.com"
#property       version   "1.00"
#property       strict
#property       indicator_chart_window

int             lookback = 1;

//string          ChangeSP        = "Where I go?";
string          ChangeSP        = Symbol();
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
    {
//---
    ObjectCreate     ( 0, ChangeSP, OBJ_BUTTON,           0, 0, 0                  );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_XDISTANCE,    1600                     );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_YDISTANCE,    200                      );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_XSIZE,        200                      );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_YSIZE,        40                       );
    ObjectSetString  ( 0, ChangeSP, OBJPROP_TEXT,         "Go to GBPUSD M15"       );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_COLOR,        White                    );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_BGCOLOR,      Red                      );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_BORDER_COLOR, Red                      );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_BORDER_TYPE,  BORDER_FLAT              );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_BACK,         false                    );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_HIDDEN,       true                     );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_STATE,        false                    );
    ObjectSetInteger ( 0, ChangeSP, OBJPROP_FONTSIZE,     12                       );
//---
    return(INIT_SUCCEEDED);
    }
//+------------------------------------------------------------------+
//| OnCalculate function                                             |
//+------------------------------------------------------------------+
int OnCalculate(const int      rates_total     ,
                const int      prev_calculated ,
                const datetime &time[]         ,
                const double   &open[]         ,
                const double   &high[]         ,
                const double   &low[]          ,
                const double   &close[]        ,
                const long     &tick_volume[]  ,
                const long     &volume[]       ,
                const int      &spread[]       )
{
    for( int iBar = Bars - 1 - MathMax( lookback, prev_calculated ); iBar >= 0; --iBar )
    {
        int ChangeSP_action = rates_total - 1 - MathMax( lookback, prev_calculated);
        int iLast = MathMax( 0, ChangeSP_action - 1 );
    }
    return rates_total - 1;
}
//+------------------------------------------------------------------+
//| deinitialization function                                        |
//+------------------------------------------------------------------+
int OnDeinit()
{
//----
    ObjectsDeleteAll(0, ChangeSP);
//----
    return(0);
}
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(  const int      id     ,
                    const long   & lparam ,
                    const double & dparam ,
                    const string & sparam )
{
//---
    if( sparam == ChangeSP )
    {
        ChangeSPClick   ( ChangeSP );
        ObjectSetInteger( 0, ChangeSP, OBJPROP_STATE, false );
    }
    return;
}
//+------------------------------------------------------------------+
void ChangeSPClick(bool ChartSetSymbolPeriod)
{
    bool ChangeSP_action = ChartSetSymbolPeriod(0, "GBPUSD", 15 );
}

Still same thing. I think I did not understand clearly or what, sorry about that.

(Also 'eddie' said 'Check the value of ChangeSP' - but I do not have any ideas, what I could do.)

 
    for( int iBar = Bars - 1 - MathMax( lookback, prev_calculated ); iBar >= 0; --iBar )
On a chart change you are calculating all bars. Previously answered.
 

I already asked your question to myself.

But I am still doing something wrong, I can't figure out what.

//  First define your maximum lookback.
#define lookback 1
//  New way, counting up, not a TimeSeries.
for( int iBar = MathMax( lookback, prev_calculated ); iBar < Bars; ++iBar )
{
    // --- I copied this from your comment
    int ChangeSP_action = rates_total - 1 - MathMax( lookback, prev_calculated );
    int iLast = MathMax( 0, ChangeSP_action - 2000 );
    // --- I check what happen...
    Print(
          " |iBar "            + iBar,
          " |ChangeSP_action " + ChangeSP_action,
          " |iLast "           + iLast
         );
}
return rates_total - 1;

Please, pull me from this jungle.

 

Mr. William, I waiting good reply from you, please. (Really I need it.)

Thanks.