Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 599

 
artmedia70:
Use the sys variable. If you enter a value of sys less than zero in the settings, it will correct to zero


tried it, unfortunately it didn't work... Still doesn't change the value
 
peace1984:

tried it, unfortunately it didn't work... Still doesn't change the value

Have you noticed that there are two different variables in my example?

In your code, always check the value of the sys variable, while the external variable has the name Sys. After it is declared, its value is immediately assigned and the sys variable is corrected.

 
artmedia70:

Have you noticed that there are two different variables in my example?

In code, always check the value of the sys variable, while the external variable has the name Sys. After it is declared, its value is immediately assigned and the sys variable is corrected.



Yes, I got that... I did as you did in the variable declaration... but if the user changes the value to 1, it still leaves 0...
 
peace1984:

Yes, I got that... did as you did, in the variable declaration... but if the user changes the value to 1, it still leaves 0...

Is#property strict in the code? Although... but give it a try.

How did you check the sys value? Not sys, specifically sys - it needs to be used in further calculations.

 
artmedia70:

Is #property strict in the code? Although... But give it a try.

How did you check sys value? Not sys, exactly sys - it should be used in further calculations.



Inserted strict (it wasn't there), but the result didn't change...

The value of sys determines the parameter for atr (0 is 20 days, 1-55 days)... 20... if you change the value to 1 in the code, the value is 55...

 
peace1984:

inserted a strict (it wasn't there), but the result didn't change...

sys value defines the parameter for atr (0 is 20d, 1-55d)... it takes 20... if you change the value to 1 in the code, it takes 55...

//------------------------------------------------------
enum atrSys
  {
   atr0=20,   // 20
   atr1=55,   // 55
  };
input atrSys AtrSys   =  atr0;       // Период ATR
//------------------------------------------------------

So try it. In the code, check the value of AtrSys.

ZS. Do not remove comments from the code - they are also needed.

 
artmedia70:
Try it. Check the value of AtrSys in the code.

I already tried this one too, at the very beginning... from it I switched to 0 and 1...
 
peace1984:
I tried that one too, in the very beginning... that's where I went from 0 and 1...

There are no miracles. Show me the code.
 
artmedia70:
There are no miracles. Show me the code.
This is my first experience, don't judge too harshly:)
Files:
11.mq4  8 kb
 

Greetings! :)

I have roughly the same indicator code:

bool busy=false;

int start()
{
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   limit=Bars-counted_bars+1;
   limit=MathMin(bBars-1, limit);
   if(IndicatorCounted()>0) limit=1;
   
   FileWrite(han, TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS), Bars, IndicatorCounted());
   FileFlush(han);
   //if(busy=false) return(0);
   for (i=0; i<limit; i++)
   { 
      busy=true;
      FileWrite(han, TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS), DoubleToStr(i, 0), DoubleToStr(IndicatorCounted(), 0));
      FileFlush(han);
      Здесь идут сложные вычисления которые занимают минуты 3
   }

   busy=false;
}

I drop it on the M1 chart. The indicator hangs together with the terminal, allegedly performing calculations.
I forcefully close it in 15 minutes and open its log:

Pic1

It turns out that the indicator does not react to newly arrived ticks (it is logical) until it calculates the first time. But it forgets to tell the terminal during the evaluation that IndicatorConted() must be already assigned a value different from 0.
So it turns out that incoming ticks ordered for evaluation remember the current value of IndicatorCounted()?

I tried to control it via busy variable (commented out string - same result).

I tried it this way too:

int start()
{
   FileWrite(han, TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS), Bars, IndicatorCounted());
   FileFlush(han);
   return(0);
   .
   .
   .
}

Naturally, this time everything worked correctly:

Pic2

What do we have here? The system has no time to write a new value into IndicatorCounted()? In other words, I need to do something like sleep()? I know that this is not possible in the indicator)
Or, when a new tick comes, because the old tick has not finished its calculations, it remembers that IndicatorCounte() is still equal to zero and when its time comes, it starts calculating from the old value IndicatourCounted()=0?

What to do? )

Reason: