Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1325

 
DanilaMactep:

you cannot change the value of an external variable within an mql4 program

F1 helps

 
Iurii Tokman:

you cannot change the value of an external variable within an mql4 program

F1 in help

Iurii Tokman:

you cannot change the value of an external variable inside an mql4-program

F1 help

I have seen many video tutorials where such variables were changed without any problems. So it's not decent to tell me to F1;)))))). So please give me a really clear and sensible advice on how to run this grail machine)))))))))))))))))))

 
DanilaMactep:

More than once I have seen in video tutorials how such variables were changed without any problems. So to send me to F1 is somehow not decent or something;)))))) So please give real clear and practical advice on how to run this grail machine)))))))))))))))))))

if you think youtube is more authoritative than the developers help, you won't run anything
it's easy - you just have to follow the rules

 
DanilaMactep:

More than once I have seen in video tutorials how such variables were changed without any problems. So to send me to F1 is somehow not decent or something;)))))) So please give real clear and practical advice how to run this grail machine)))))))))))))))))))

Do it this way:

 extern   ENUM_TIMEFRAMES   PeriodForWork_sl        =  PERIOD_H4;           // ТФ РАСЧЁТА ЗНАЧЕНИЙ СТОП ЛОСА ПО АТР
 extern int per= 14; // ПЕРИОД АТR СТОП ЛОССА


//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
double sl=iATR( NULL,PeriodForWork_sl,per,1);// ПОЛУЧЕНИЕ ЗНАЧЕНИЙ АТР ДЛЯ ВЫСТАВЛЕНИЯ СТОПЛОССА

Comment("  sl = ",DoubleToString(sl,_Digits));
   
  }
//+------------------------------------------------------------------+

And check the help more often.

 
Iurii Tokman:

If you think YouTube is more authoritative than the developers' help, you won't run anything
it's simple - you have to follow the rules

Normally for a stop loss I need to create a local variable in the on tick and assign an atr value to it?
 
DanilaMactep:
Normally for a stop loss I need to create a local variable in the on tick and assign an atr value to it?

yes, as in the example above
+ prices need to be normalised

 
Iurii Tokman:

you cannot change the value of an external variable within an mql4 program

F1 is a help.

You can't change input variables, but extern variables it applies can.

 
DanilaMactep:

Afternoon. I am trying to attach a stop loss read from atr indicator to my EA. The input variables are as follows.

I am adding the atr values to a variable for a stop loss.

Then I try to open orders like this.


But nothing works. I print the value of Stop Loss variable but it says its value is 0. What I am doing wrong and where I should correct my settings to make it work?

In the input parameters, you set the ATR period in the sl variable, not the stop size. Then you enter the stop size into this variable. And then the mess begins. Make separate variables for ATR period of int type and for indicator value of double type.

Another error is that after getting the indicator value, you again multiply this value by _Point

 
Alexey Viktorov:

Make separate variables for the ATR period int type


double


 
Iurii Tokman:

double


double is the value of the indicator and the period of the indicator is int type
Reason: