Questions from Beginners MQL5 MT5 MetaTrader 5 - page 411
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
Started studying arrays .
I have written a pro-order function with arrays , 3 arrays = 0 buy, 1= sell, 2= total buy and sell trades.
Then I wrote a condition to buy if ( the first condition && array [0] == 0 )then we open a buy
and on sale if ( the first condition && array [1]== 0) then we open a Sell position.
But the tester throws an error and the test stops, what is the problem? ( error " array exit " )
It means that the index you are addressing is outside the array layout. For example, if array[ 3 ]; you may address only items from 0 to 2. Check your code.
Another possibility is that you don't partition the array (with ArrayResize()), but try to access some of its elements.
code...
Try to figure it out yourself, the tester should indicate in which line and position in the line the error occurred.
o_oops didn't know the terminal also pokes where the error is, first time I hit a critical error.
It spits on it.
Please advise how to check how the indicator works.
The idea is the following: when the EA forms a new bar it calls the indicator, but the indicator has no data at this moment and I get the data of the previous bar (it has not had time to calculate).
How to avoid this problem. Moreover, everything is OK in the Strategy Tester. I get either fine or not at all on the demo!
That is it, it is not relevant. Resolved.
Hello, I have a beginner's problem...
I can't get the system to compare the last bar close value with the highs and lows of a certain period, e.g.
last 20 bars. What am I doing wrong?
Checked with Alert and for some unknown reason tester gives the maximum value from the calculation from the very last tick, but it gives this value
It is the same number of times as the ticks, so the order does not open.
The second issue is how to make my EA wait until the next bar opens (30m period)? When I test using control points everything is fine, but if I use ticks,
then EA opens in the same bar right after it closed at stop loss...
Also, how can I close a deal, regardless of whether it was a tick or not? For example, on a period of 30m I want to close the order 5 seconds before the end of the bar (29.55, 59.55)
Based on all the data at that moment. At this stage the problem is that if a tick does not occur within 5 seconds, therefore no
(In theory this is bullshit, but in reality the next tick might appear in a few candlesticks for some reason.
may turn out to be in a few candles for some reason.
Thanks in advance!Help with the comments. On each bar, comments are generated. On every tick I want to add more text to the existing comment.
I call the code:
void UserMarketComment( )
{
string com=ChartGetString(0,CHART_COMMENT); // Получаем текст существующего комментария
string st="Целевой убыток="+DoubleToStr(-inpTargetLoss,2)+" "+AccountCurrency()+" Текущ";
if(AccountProfit()<0) st=st+"ий убыток=";
else st=st+"ая прибыль=";
st=st+DoubleToStr(AccountProfit(),2)+" "+AccountCurrency()+" Целевая прибыль="+DoubleToStr(inpTargetProfit,2)+" "+AccountCurrency();
Comment(com+"",TimeToStr(TimeCurrent(),TIME_SECONDS)," Spread = ",MarketInfo(Symbol(),MODE_SPREAD),
"\n ",st);
}
Adds new comment and on every tick in a new line and text slides down.
How to make it delete last few lines before outputting?
Help with the comments. On each bar, comments are generated. On every tick I want to add more text to the existing comment.
I call the code:
void UserMarketComment( )
{
string com=ChartGetString(0,CHART_COMMENT); // Получаем текст существующего комментария
string st="Целевой убыток="+DoubleToStr(-inpTargetLoss,2)+" "+AccountCurrency()+" Текущ";
if(AccountProfit()<0) st=st+"ий убыток=";
else st=st+"ая прибыль=";
st=st+DoubleToStr(AccountProfit(),2)+" "+AccountCurrency()+" Целевая прибыль="+DoubleToStr(inpTargetProfit,2)+" "+AccountCurrency();
Comment(com+"",TimeToStr(TimeCurrent(),TIME_SECONDS)," Spread = ",MarketInfo(Symbol(),MODE_SPREAD),
"\n ",st);
}
Adds new comment and on every tick in a new line and text slides down.
How to make it delete last few lines before outputting?
It seems to me that you can only completely replace Comment()
And consequently, to change a part of the comment on every tick, you have to change the comment completely on every tick.
Help with the comments. On each bar, comments are generated. On every tick I want to add more text to the existing comment.
I call the code:
void UserMarketComment( )
{
string com=ChartGetString(0,CHART_COMMENT); // Получаем текст существующего комментария
string st="Целевой убыток="+DoubleToStr(-inpTargetLoss,2)+" "+AccountCurrency()+" Текущ";
if(AccountProfit()<0) st=st+"ий убыток=";
else st=st+"ая прибыль=";
st=st+DoubleToStr(AccountProfit(),2)+" "+AccountCurrency()+" Целевая прибыль="+DoubleToStr(inpTargetProfit,2)+" "+AccountCurrency();
Comment(com+"",TimeToStr(TimeCurrent(),TIME_SECONDS)," Spread = ",MarketInfo(Symbol(),MODE_SPREAD),
"\n ",st);
}
Adds new comment and on every tick in a new line and text slides down.
How to make it delete last few lines before outputting?