Questions from Beginners MQL5 MT5 MetaTrader 5 - page 553
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
Instead of Close[2] put the indicator value on the second bar (for example iRSI(.......,2) ) and instead of Close[1] put the indicator value on the first bar. And uroven is the value of the level.
And the rest you have already been told above.
Prerequisite:
ProfitSellDBL is calculated here
Profit_Upgr = 0.01
Tral_Start__Upgr is equated to an external variable of int type and equals to 5.
Tral_Size__Upgr is similarly equal to 4
TV - tick value, =10
SumLotSellDBL = 0.04
Read. Saw how it would work if Tral_Start__Upgr, Tral_Size__Upgr and their external variables were defined as double. I.e. when everything is of the same type without any conversion and data loss. The result is the same. What did I get wrong?
A blind man talking to a deaf man. If you want someone to test it, you need the minimum possible code that can be compiled on another machine and tested. No code - nothing to talk about.
Added: Use debugging(Debugging):
-Preconfiguration
-Stoppoints
-Startdebugging
-Observableexpressions
-Call StackView
-Step-by-stepdebugging
-Stop, Resume and End Debugging
-Historydebugging
Forum on trading, automated trading systems and trading strategy testing
Bugs, bugs, questions
comp, 2016.04.03 18:21
Runtime error
In four it worked fine! In five it's a bummer. Is this another architectural limitation compared to quad? Give me a link to a discussion on this, couldn't find it myself.
Do I understand correctly, that something can be assigned to indicator buffers only after the first call of the terminal (not manually) OnCalculate?
Indicator buffers can be accessed after OnCalculate() has been called. At the same time, the indicator buffer itself should be declared in the global variables area:
I think I found what I was looking for, but the antiquity of the code gives an error
Help me fix it ...... if it's not too much trouble.
and if you can help me turn it to the right side of the screen that would be great.
The indicator buffers can be accessed after OnCalculate() has been called.
As it turns out, you are wrong. You can apply only when the terminal calls OnCalculate. In this case, the condition in MT4 is more flexible, because it's enough to call OnCalculate only once. But in MT5, you must wait for the call of OnCalculate by the terminal itself every time after the SetIndexBuffer. Proof
In MT4 this indicator will work without problems, in MT5 it will crash with an error. As it turned out, in MT4 you just need to wait for the first call of OnCalculate by the terminal and do whatever you want with the buffers, including their redefining using SetIndexBuffer. But in MT5 after EVERY SetIndexBuffer it is necessary to wait for the first call of OnCalculate by the terminal.
This peculiarity is not documented anywhere. And it does not seem to fit the definition of a "beginner".
Can we expect that in MT5 this behaviour will be the same as in MT4? I.e. after the first call of OnCalculate by the terminal itself it would be possible to call SetIndexBuffer without problems?
As it turns out, you are wrong. You can only call it when OnCalculate is called by the terminal itself. In this case, in MT4 the condition is more flexible, because you only need to call OnCalculate once. But in MT5, you must wait for the call of OnCalculate by the terminal itself every time after the SetIndexBuffer. Proof
In MT4 this indicator will work without problems, in MT5 it will crash with an error. As it turned out, in MT4 you just need to wait for the first call of OnCalculate by the terminal and then do whatever you want with the buffers, including their redefining using SetIndexBuffer. But in MT5 after EVERY SetIndexBuffer it is necessary to wait for the first call of OnCalculate by the terminal.
This feature is not documented anywhere. And it does not seem to fit the definition of a "beginner".
Can we expect that in MT5 this behaviour will be the same as in MT4? I.e. after the first call of OnCalculate by the terminal itself it will be possible to call SetIndexBuffer without problems?