Errors, bugs, questions - page 1028

 
tol64:

Then a) why does it work for the object b) if you replace it, it starts crumbling

'0x00000008' - can't convert enum

Not all of them, only 18 out of 21 lines...

I'll try to rewrite them all, it's still not clear. It seems to be one type.

 
Silent:

Then a) why does it work for the object b) if you replace it, it starts crumbling

Not all of them, only 18 out of 21 lines...

I'll try to rewrite them all, it's still not clear. It seems to be one type.

ENUM_TIMEFRAMES current_period_tf=PERIOD_CURRENT;
   string n="";
   if(_Period==PERIOD_M1)  {current_period_tf=PERIOD_M1;};
   if(_Period==PERIOD_M2)  {current_period_tf=PERIOD_M2;};
   if(_Period==PERIOD_M3)  {current_period_tf=PERIOD_M3;};
   if(_Period==PERIOD_M4)  {current_period_tf=PERIOD_M4;};
   if(_Period==PERIOD_M5)  {current_period_tf=PERIOD_M5;};
   if(_Period==PERIOD_M6)  {current_period_tf=PERIOD_M6;};
   if(_Period==PERIOD_M10) {current_period_tf=PERIOD_M10;};
   if(_Period==PERIOD_M12) {current_period_tf=PERIOD_M12;};
   if(_Period==PERIOD_M15) {current_period_tf=PERIOD_M15;};
   if(_Period==PERIOD_M20) {current_period_tf=PERIOD_M20;};
   if(_Period==PERIOD_M30) {current_period_tf=PERIOD_M30;};
   if(_Period==PERIOD_H1)  {current_period_tf=PERIOD_H1;};
   if(_Period==PERIOD_H2)  {current_period_tf=PERIOD_H2;};
   if(_Period==PERIOD_H3)  {current_period_tf=PERIOD_H3;};
   if(_Period==PERIOD_H4)  {current_period_tf=PERIOD_H4;};
   if(_Period==PERIOD_H6)  {current_period_tf=PERIOD_H6;};
   if(_Period==PERIOD_H8)  {current_period_tf=PERIOD_H8;};
   if(_Period==PERIOD_H12) {current_period_tf=PERIOD_H12;};
   if(_Period==PERIOD_D1)  {current_period_tf=PERIOD_D1;};
   if(_Period==PERIOD_W1)  {current_period_tf=PERIOD_D1;};
   if(_Period==PERIOD_MN1) {current_period_tf=PERIOD_MN1;};
   ChartSetSymbolPeriod(ChartID(),_Symbol,PERIOD_M1);
   ObjectSetInteger(0,n,OBJPROP_TIMEFRAMES,current_period_tf);
   ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);
 
tol64:
Yes, I did, thank you, it's ticking ).
 
Silent:
Yes, I did, thank you, it's ticking ).

Now try it like this:

   string n="";
   ENUM_TIMEFRAMES current_period_tf=_Period;
   ChartSetSymbolPeriod(ChartID(),_Symbol,PERIOD_M1);
   ObjectSetInteger(0,n,OBJPROP_TIMEFRAMES,current_period_tf);
   ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);

 
MetaDriver:

Now try it like this:

Tried it, I can't get back from M1 automatically. If I enumerate as above

if(_Period==PERIOD_M1)  {current_period_tf=PERIOD_M1;};

I can return every once in a while, but if I assign _Period at once, I fall to M1 and stay there.

upd does not save even if I moved to the end of the indicator

     if(_Period==PERIOD_M1) {ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);};

I don't know why it clogs, I'm trying to figure it out.

 

This is a crutch instead of synchronisation (on an output when there are no ticks). The idea is like a tank - there is an error - switch to M1 and return.

   if(_LastError!=0)
     {
      ChartSetSymbolPeriod(ChartID(),_Symbol,PERIOD_M1);
      ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);
     };
   if(_LastError==0)
     {
      ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);
     };
// и контрольный
   if(_Period==PERIOD_M1) {ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);};
only from M1 it very much does not always release.
 
Silent:

Tried it, from M1 I can't go back automatically. If I enumerate as above

I can go back every once in a while, but if I assign _Period at once, I fall to M1 and stay there.

Your case is cured by a small slip.

   string n="";
   ENUM_TIMEFRAMES current_period_tf=_Period;
   ChartSetSymbolPeriod(ChartID(),_Symbol,PERIOD_M1);
   Sleep(150);
   ObjectSetInteger(0,n,OBJPROP_TIMEFRAMES,current_period_tf);
   ChartSetSymbolPeriod(ChartID(),_Symbol,current_period_tf);

Mine is worse. (By the way, your case used to work without Slip, it stopped working a few weeks ago.)

Same scheme stopped working without creepy slips on other (not current) charts:

void cChartReInit::Run() // Scanning all charts and reinit if button is pushed
  {
   for(long i=ChartNext(0);i>0;i=ChartNext(i))
    {
     if(!ChartGetInteger(i,CHART_WINDOW_IS_VISIBLE)) continue;
     long wc = ChartGetInteger(i,CHART_WINDOWS_TOTAL);
     long wi = ObjectFind(i, pButtonName);
     if(--wc!=wi) { CreateReinitButton(i); ChartRedraw(i); continue;}
     if(ObjectGetInteger(i,pButtonName,OBJPROP_STATE))
       {
        ObjectSetInteger(i,pButtonName,OBJPROP_STATE,false);
        ENUM_TIMEFRAMES cp = ChartPeriod(i);
        Sleep(1350);  // раньше это было не нужно
        ChartSetSymbolPeriod(i, ChartSymbol(i), ((cp==PERIOD_M1) ? PERIOD_M5 : PERIOD_M1));
        Sleep(1350);  // раньше это было не нужно
        ChartSetSymbolPeriod(i, ChartSymbol(i), cp);
       }
     ChartRedraw(i);
    } // for(Charts)
  }
Code from here: https://www.mql5.com/ru/code/224
ChartReinit
ChartReinit
  • votes: 7
  • 2010.11.29
  • Vladimir Gomonov
  • www.mql5.com
Кнопочная переинициализация чарта с перерасчетом всех индикаторов, а также простенький и прозрачный объектно-ориентированный пример обработки всех чартов из одного эксперта.
 
MetaDriver:

Your case is treated with a small slip.

Mine is worse. (By the way, your case without a Slip used to work, stopped a few weeks ago.)

But the same scheme stopped working without creepy slips on other (not current) charts:

Code from here: https://www.mql5.com/ru/code/224/10323

Slip doesn't work in indicators, does it?

Link to 404 page throws

 
Silent:

Slip doesn't work in indicators, does it?

It's a 404 page link.

Yeah.

Try some kind of costly loop...

You could do it with a timer, but I don't like all that.

// Corrected the link. First through "my codes", now through a common login in kodobaza. // Does it work now? Or do I need to unlogin to get a public link?

 
MetaDriver:

Yeah. :(

Try some kind of costly cycle...

I can do it through a timer, but I don't like all this.

I tried to attach OnTimer with ChartRedraw instead of switching to another timeframe - no response, it updates, but the error hangs.

I'll have another look.

Update has a suspicion that all this is related to the threads. Somewhere, they do not match, one hangs with an error, the other ticks by itself. Ras-synchronization, however. And there is no command for full recalculation.

I've also tried

#define   RESET 0

   if(_LastError!=0)
     {
     return(RESET);
     };
it doesn't seem to be working at all. Took it in the kodobase though.