I have written a code with the condition "buy" when MA(20) crosses MA(50) from bottom to top
But in fact it is done like this
Gross error: You create two indicator handles on every tick. The correct way to do it is to
int SmallMovingAverageDefinition = iMA(_Symbol,_Period,SmallMovingAverage,0,MODE_SMA,PRICE_CLOSE);
int BigMovingAverageDefinition = iMA(_Symbol,_Period,BigMovingAverage,0,MODE_SMA,PRICE_CLOSE);
move to OnInit, add a check of the handle correctness.
Also arrays that take values from IMA must be made
Идея автоматической торговли привлекательна тем, что торговый робот может без устали работать 24 часа в сутки и семь дней в неделю. Робот не знает усталости, сомнений и страха, ему не ведомы психологические проблемы. Достаточно четко формализовать торговые правила и реализовать их в виде алгоритмов, и робот готов неустанно трудиться. Но прежде...
I understand that we create only the indicator handle in the OnInit function and perform all other manipulations with the arrays in the OnTick function and check it on every tick?
В языке MQL5 предусмотрена обработка некоторых предопределенных событий. Функции для обработки этих событий должны быть определены в программе MQL5: имя функции, тип возвращаемого значения, состав параметров (если они есть) и их типы должны строго соответствовать описанию функции-обработчика события. Именно по типу возвращаемого значения и по...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good afternoon!
I'm trying to understand arrays and have the following question.
Why useArraySetAsSeries in this example and set flag true, if inCopyRates counting is made from present to the past?
I understand, that theArraySetAsSeries function is necessary to search the array from the present to the past.
I want to understand the purpose of this function in this example.
After
rates[0] will correspond to the RIGHT BAR in the chart. This is the simplest explanation, without the confusing terms "present" and "future".
After
rates[0] will correspond to the RIGHT BAR on the graph. This is the simplest explanation, without the confusing terms "present" and "future".
Thanks for the answer!
But if we don't useArraySetAsSeries, thenCopyRates will also assign rates[0] to the rightmost bar on the chart.
Just trying to understand what isArraySetAsSeriesfunction for when it works the same without it?
Or it's just an accepted form of writing code?
Thanks for the answer!
But if we don't useArraySetAsSeries, thenCopyRates will also assign rates[0] to the rightmost bar on the chart.
Just trying to understand whyArraySetAsSeriesfunction is needed when it works the same without it?
Or it's just an accepted form of writing code?
you're wrong, CopyRates assign rate[0] to the oldest value due to the size of rate[] array.
Thank you!
Now I get it, I was wrong)
Good afternoon!
Once again I am asking for help!
I have written a code with the condition "buy" when MA(20) crosses MA(50) from bottom to top
But in fact it executes like this
Good afternoon!
Once again I am asking for help!
I have written a code with the condition "buy" when MA(20) crosses MA(50) from bottom to top
But in fact it is done like this
Gross error: You create two indicator handles on every tick. The correct way to do it is to
move to OnInit, add a check of the handle correctness.
Also arrays that take values from IMA must be made
Thank you very much for your prompt reply!
I understand aboutArraySetAsSeries.
I will try to figure out how to move indicator to OnInit, and check the handle.
***
Thank you very much for your prompt reply!
I understand aboutArraySetAsSeries.
I will try to figure out how to move indicator to OnInit, and check the handle.
***
Everything is there from the beginning
It's all there from the beginning.
Thanks, I will study
Fixed it, everything seems to be working!)
I transferred two MA indicators to the OnInit function.
I understand that we create only the indicator handle in the OnInit function and perform all other manipulations with the arrays in the OnTick function and check it on every tick?