Demosfen:
Hello,
I am trying to set initial stop at 3 times current ATR.
I want to get current ATR with:
and use it like this:
But I get "constant expected" mistake.
Can anyoune help?
double atr = iATR(_Symbol,PERIOD_CURRENT,14) * 3;
In Mql5 you need to access the indicator values with CopyBuffer like so:
input int ATR_Period=14; int ATR_Handle; double ATR_Current; double ATR_StopLevel; int OnInit() { ATR_Handle=iATR(_Symbol,PERIOD_CURRENT,ATR_Period); if(ATR_Handle==INVALID_HANDLE) { Print("error creating iATR handle: ",GetLastError()); return INIT_FAILED; } return INIT_SUCCEEDED; } void OnTick() { static double s_buffer[1]; int amount=1; int shift=0; if(CopyBuffer(ATR_Handle,MAIN_LINE,shift,amount,s_buffer)!=amount) { Print("error copying indicator buffer: ",GetLastError()); ExpertRemove(); return; } ATR_Current=s_buffer[0]; ATR_StopLevel=3.0*ATR_Current; ... }
lippmaje:
It works, thanks a lot!
In Mql5 you need to access the indicator values with CopyBuffer like so:
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I am trying to set initial stop at 3 times current ATR.
I want to get current ATR with:
and use it like this:
But I get "constant expected" mistake.
Can anyoune help?