The tester does not report any errors, just no orders are placed.
Please, point out the error, the logic: if the value of MA [0] of the bar is higher than MA [1] you have to buy, on the contrary - sell (this code was written as an example to try to understand a simple condition and create a more complicated one).
This code does not use MA[0] and MA[1] but MA[j] and MA[j+1];
After a small revision of the code (very small), error 4107 appeared
I can make it work, but it will be a totally different EA. I am simplifying it to the maximum. And here the code can be more than halved.
If Stops and Takeovers are set equal to zero, the Expert Advisor starts to open trades
Vinin: I can make it work, but it will be a completely different EA. I am simplifying it as much as possible. And here the code can be reduced by more than half.
Vinin, if you can make it work with closing at stop or take profit, the main thing for me is to feel the philosophy of mql in addressing different bars in the array.
Craft: Vinin, if you can make it work with closing at stop or take profit, the main thing is to feel the philosophy of mql in addressing different bars in an array.
I have checked it. It works. The signal is a change of direction
Craft: Nice, but how does it work in code (logic): If MA150+20 > MA5 > MA150-20 and MA150+20 > MA21 > MA150-20 Then flat else Trend.
The logic is somewhere around here... I made it fast, so sorry, if anything...
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж//------------------------------- Функция определения тренда по МАшкам ----------------------------//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж// Возврвщает 1 = тренд вверх, -1 = тренд вниз, 0 = флэт...//------------------------------------------------------------// -------------- Внешние переменные -------------//============================================================externstring MATrendDetectorParameters = "Параметры детектора тренда";
externdouble Limit150 =20;
externdouble Limit21 =20;
externdouble Limit5 =20;
// ===============================================================// ---------------------- Собственно сама функция ----------------// ===============================================================int TrendDetectorMA (string sy, int tf)
{
double MA150, MA150UP, MA150DN,
MA21, MA21UP, MA21DN,
MA5, MA5UP, MA5DN,
pt;
// ---------------------------------------
pt=Point;
if (sy=="" || sy=="0") sy=Symbol();
MA150 =iMA(sy,tf,150,0,MODE_SMA, PRICE_MEDIAN,1);
MA21 =iMA(sy,tf,21,0,MODE_SMA, PRICE_MEDIAN,1);
MA5 =iMA(sy,tf,5,0,MODE_SMA, PRICE_MEDIAN,1);
MA150UP =MA150+Limit150*pt;
MA150DN =MA150-Limit150*pt;
MA21UP =MA21+Limit21*pt;
MA21DN =MA21-Limit21*pt;
MA5UP =MA5+Limit5*pt;
MA5DN =MA5-Limit5*pt;
// --------------------------------------// ------------- Рассчёт данных ---------if (
MA5DN>MA21UP && // Если нижняя граница быстрой МАшки выше верхней границы средней МАшки и...
MA21DN>MA150UP // нижняя граница средней МАшки выше верхней границы медленной МАшки,
)
return(1); // значит тренд вверх, возвращаем 1if (
MA5UP<MA21DN && // Если верхняя граница быстрой МАшки ниже нижней границы средней МАшки и...
MA21UP<MA150DN // верхняя граница средней МАшки ниже нижней границы медленной МАшки,
)
return(-1); // значит тренд вниз, возвращаем -1elsereturn(0); // В остальных случаях у нас флэт, возвращаем 0
}
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
The challenge goes something like this:
int tr=TrendDetectorMA (NULL, 5); // NULL, 0 = текущий символ, либо явно, напр. EURUSD
// 5 = таймфрейм, можно 15, 30, 60, 240, 1440, 10080, 43200, хотя можно было
// и красивее сделать.
Comment ("\n","Тренд = ", tr);
return;
my system is set up to always want to open an order and I limit it by forbidding signals, only signals give me permission to trade = order
I have a small problem now - there are no late trades, but there are problems with random orders in the night flat - so far I dream of teaching the EA to distinguish the flat, and not limiting it to the time of day to work. For the estimation of the trend I am using higher TF in the EA logic, so I am able to put it at night on an hourly TF and it seems to be less stubborn than on M15
Why restrict? You may use separate strategies for trend and flat. Let it always work, as long as it works ... ;)
The tester does not report any errors, just no orders are placed.
Please, point out the error, the logic: if the value of MA [0] of the bar is higher than MA [1] you have to buy, on the contrary - sell (this code was written as an example to try to understand a simple condition and create a more complicated one).
This code does not use MA[0] and MA[1] but MA[j] and MA[j+1];
After a small revision of the code (very small), error 4107 appeared
I can make it work, but it will be a totally different EA. I am simplifying it to the maximum. And here the code can be more than halved.
If Stops and Takeovers are set equal to zero, the Expert Advisor starts to open trades
reply
The thing is, advisors work and indicators do not work at all!
Vinin, if you can make it work with closing at stop or take profit, the main thing is to feel the philosophy of mql in addressing different bars in an array.
I have checked it. It works. The signal is a change of direction
Nice, but how does it work in code (logic): If MA150+20 > MA5 > MA150-20 and MA150+20 > MA21 > MA150-20 Then flat else Trend.
The challenge goes something like this:I want to use Ramus volumes in MT4, they seem to have more realistic volumes.
my system is set up to always want to open an order and I limit it by forbidding signals, only signals give me permission to trade = order
I have a small problem now - there are no late trades, but there are problems with random orders in the night flat - so far I dream of teaching the EA to distinguish the flat, and not limiting it to the time of day to work. For the estimation of the trend I am using higher TF in the EA logic, so I am able to put it at night on an hourly TF and it seems to be less stubborn than on M15
Good evening, I do not work with MQL4 indicators, and nothing at all! Please help!
reply
The fact that advisors work, and indicators do not work at all!
F1 help - technical indicators section
How do I use object crate and object set to draw a horizontal line in a stochastic window, for example?