Nickolay72: Until yesterday, my EA has only opened one order each and the next one will not open until I place an order. Now, how to make my EA open orders when the previous bar has opened above (below) the channel?
if (CountTrades()==0) CheckForOpen();
else
{
if(CountTrades()<max_trades) CheckForOpen();
}
If you analyze this code fragment, then, according to this code, if theCountTrades() functionreturns zero, the condition if (CountTrades()==0) CheckForOpen()will be executed, and the functionCheckForOpen() will be called.On the next tick, if the order has been opened, theCountTrades()functionshould return 1, and then the else condition is fulf illed
If it appears that CountTrades()<max_trades, theCheckForOpen() function will be executed once again.According to the code, value of max_tradesvariable equals 3. Thus, you will have 4 orders open.
If the EA does not open orders correctly, then check the logic, in which you define the conditions under which positions are to be opened in the function CheckForOpen(). And also check the time conditions if (CurrTime < EaStartTime || CurrTime >= EaEndTime). If I were you, I would use the function if (TimeHour(TimeCurrent()) = start hour && TimeMinute(TimeCurrent()) = start minutes ). The hour and minutes are set in variables of int or uint types.
Artyom Trishkin: If Open Bar Number 1 is above/below channel.
Damn it, I just saw that I have a trade around the lower limit of the channel, I just copied the orders and did not corrected the bottom to the top, I will try the corrected version.)
//-----Ставим ордер на покупку.if(PriceCurrentOpen<PriceLow&&PriceCurrentOpen<PriceCurrentClose&&SignalCurrent<MacdCurrent&&SignalMAPrevious<SignalMAThis)
{
ticket=OrderSend(NULL,OP_BUY,Lots,Ask,slippage,0,0,"5",magic,0,Blue);
if(ticket>0)
return;
}
//-----Ставим ордер на продажу.if(PriceCurrentOpen>PriceLow&&PriceCurrentOpen>PriceCurrentClose&&SignalCurrent>MacdCurrent&&SignalMAPrevious>SignalMAThis)
{
ticket=OrderSend(NULL,OP_SELL,Lots,Bid,slippage,0,0,"5",magic,0,Red);
if(ticket>0)
return;
If the EA does not open orders correctly, then check the logic, where you specify the conditions under which positions must be opened in the function CheckForOpen(). And also check the time conditions if (CurrTime < EaStartTime || CurrTime >= EaEndTime). If I were you, I would use the function if (TimeHour(TimeCurrent()) = start hour && TimeMinute(TimeCurrent()) = start minutes ). The hour and minute are set in variables of int or uint types.
I wanted to open 3 orders but this was not what I intended; I wanted up to three, but one order per each new bar.
There is no problem with time, it works in a strictly specified period of time.
I wanted up to three orders, but one order for each new bar. There are times when several bars in a row give positive signals.
There is no problem with time, it works in a strictly specified period of time.
The condition: if the bar of the last position opening is not equal to zero and the number of open positions is less than the maximum allowed, then a new position can be opened.
Karputov Vladimir: Actually, apart from the error text, the compiler also reports the number of the code line where the error is found and its position in the line.
This is so - in the first case on the comparison signs in turn - apparently between the "or" you must put a parenthesis, and in the second case it swears on the parenthesis in which the logical expression is written.
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.
Until yesterday, my EA has only opened one order each and the next one will not open until I place an order. Now, how to make my EA open orders when the previous bar has opened above (below) the channel?
If you analyze this code fragment, then, according to this code, if theCountTrades() functionreturns zero, the condition if (CountTrades()==0) CheckForOpen()will be executed, and the functionCheckForOpen() will be called.On the next tick, if the order has been opened, theCountTrades()functionshould return 1, and then the else condition is fulf illed
If it appears that CountTrades()<max_trades, theCheckForOpen() function will be executed once again.According to the code, value of max_tradesvariable equals 3. Thus, you will have 4 orders open.
If the EA does not open orders correctly, then check the logic, in which you define the conditions under which positions are to be opened in the function CheckForOpen(). And also check the time conditions if (CurrTime < EaStartTime || CurrTime >= EaEndTime). If I were you, I would use the function if (TimeHour(TimeCurrent()) = start hour && TimeMinute(TimeCurrent()) = start minutes ). The hour and minutes are set in variables of int or uint types.
If Open Bar Number 1 is above/below channel.
Thus, you will have 4 orders open.
If the EA does not open orders correctly, then check the logic, where you specify the conditions under which positions must be opened in the function CheckForOpen(). And also check the time conditions if (CurrTime < EaStartTime || CurrTime >= EaEndTime). If I were you, I would use the function if (TimeHour(TimeCurrent()) = start hour && TimeMinute(TimeCurrent()) = start minutes ). The hour and minute are set in variables of int or uint types.
I wanted to open 3 orders but this was not what I intended; I wanted up to three, but one order per each new bar.
There is no problem with time, it works in a strictly specified period of time.
I wanted up to three orders, but one order for each new bar. There are times when several bars in a row give positive signals.
There is no problem with time, it works in a strictly specified period of time.
.mq4 file, got the .ex4 file. But it does not work in the strategy tester. Final
was to write an EA for MT4. In MQL5, I got .mq5 and
.ex5 files. And .ex5 file opened trades. The fourth version is different from
The fourth version has some differences from the fifth one, and I'm not a good MQL programmer yet, that's why I got bad results.
I have not understood what is wrong now, the log file of the tester has been saved. Я
I will try to translate it. In the meantime I'm asking you to tell me
what's wrong with the program code? While you're answering, I'll try
to figure it out.
I was surprised to find in my fourth version of the editor a variant of writing
I was about to write it. But I didn't write it. I am attaching
tester log files and a screenshot. 05:30 MSC.


2016.01.13_05:14AM MOSCOW TIME. Hello Mr Karputov! I have written in MQL4
.mq4 file, got an .ex4 file. But it doesn't work in the strategy tester.
Where can I find error descriptions?
I don't understand what the compiler doesn't like, why it warns me?
check operator precedence for possible error; use parentheses to clarify precedence
if(Low[X]>PriceBuy && High[X]>PriceBuy ||
Low[X]<PriceBuy && High[X]<PriceBuy)
calcBarX++;
and here
expression has no effect
for(calc_day;calc_day>0; calc_day--)
{
if(iLow(Symbol(),TF_3Day,calc_day)<iLow(Symbol(),TF_3Day,calc_day+1)) calc_day_OK++;
else break;
}
Where can I find error descriptions?
I don't understand what the compiler doesn't like, why does it warn me?
Actually, apart from the error text, the compiler also reports the number of the code line where the error is found and its position in the line.