Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1513

 
Please help. I want to write a function for an Expert Advisor, which would look at whether there are divergences or not. I'm trying it this way:

bool divergetion()
{
int lastFractalHigh = iFractals(NULL, 0, MODE_UPPER, 1); // last upper fractal
int prevFractalHigh = iFractals(NULL, 0, MODE_UPPER, 2); // previous upper fractal

if (lastFractalHigh > 0 && prevFractalHigh > 0)
{
double rsiLast = iRSI(NULL, 0, 14, PRICE_CLOSE, lastFractalHigh);
double rsiPrev = iRSI(NULL, 0, 14, PRICE_CLOSE, prevFractalHigh);

if (rsiLast < rsiPrev)
{
return true; // there is divergence
}
}

int lastFractalLow = iFractals(NULL, 0, MODE_LOWER, 1); // last lower fractal
int prevFractalLow = iFractals(NULL, 0, MODE_LOWER, 2); // previous lower fractal

if (lastFractalLow > 0 && prevFractalLow > 0)
{
double rsiLast = iRSI(NULL, 0, 14, PRICE_CLOSE, lastFractalLow);
double rsiPrev = iRSI(NULL, 0, 14, PRICE_CLOSE, prevFractalLow);

if (rsiLast > rsiPrev)
{
return true; // there is divergence
}
}

return false; // no divergence
}



This function first finds two upper fractals or two lower fractals depending on the conditions and then compares RSI values on the fractal bars. If the divergence condition is met, the function returns true, otherwise it returns false.
 
I have three robots on the same financial instrument, but in different timeframes. Now I have a condition to start working if(!PositionSelect(Symbol())) && magic != Magic_m). The idea is to open positions if there are no open positions on the instrument of this particular robot, with its magic. But they still do not open positions together. Only one by one. What condition should I write so that they can work simultaneously?
 
maxvoronin74 #:

It's not quite clear when you get the position majic, especially if the first part of the condition is fulfilled when there is no position...

 
maxvoronin74 !PositionSelect(Symbol())) && magic != Magic_m). The idea is to open positions if there are no open positions on the instrument of this particular robot, with its magic. But they still do not open positions together. Only one by one. What condition should I write so that they can work simultaneously?
And don't shout like that again. I have corrected the formatting of your message to an acceptable one.
 
Artyom Trishkin #:
And don't shout like that again. I have corrected the formatting of your post to an acceptable format.
Thank you. I copied just from another application. As is.
 
Aleksey Vyazmikin #:

It's not quite clear when you get the position majic, especially if the first part of the condition is fulfilled when there is no position...

It's clear that it's not logical. How to make it logical is not clear.
 
maxvoronin74 #:
It's clear that it's not logical. I don't understand how to make it logical.

It is logical to select a position not by symbol, but in a loop through all positions. We received a ticket of the next position, checked the magik and made a decision.

 
Comrades tell me how to upload the best results of optimisation testing to SET settings file for EA?
 
Gaiatsu results of optimisation testing to the SET file of settings for an Expert Advisor?

Double click on the row with the best result of optimisation, starts a single run with the settings from the optimisation.

Then you can save this set on the tab with settings, or there in the settings ctrl+c and paste it into a text document, then you can change the extension from .txt to .set.

 
thanks, I'll try, but how to optimise the Expert Advisor correctly if the author has not specified the settings to be tested? I choose genetic algorithm, tick all parameters in the parameters, but in the optimisation window not all parameters are visible from the marked ones.... and another thing, what period do you usually choose for full optimisation, it is just unrealistic to test on one computer at home from the 70s, it will take a hundred years to optimise.
Reason: