Questions from Beginners MQL5 MT5 MetaTrader 5 - page 418
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
Hello, got this error - from strategy tester log :
2015.08.26 14:09:47.704 2001.08.29 16:15 array out of range in 'Kamikadze_MA_V_04_42_Fibo_03.mq4' (929,29)
(929,29) - is this a string and the sequence number of the character in the string?
Hello, got this error - from strategy tester log :
2015.08.26 14:09:47.704 2001.08.29 16:15 array out of range in 'Kamikadze_MA_V_04_42_Fibo_03.mq4' (929,29)
(929,29) - is this a string and the sequence number of the character in the string?
Hello, got this error - from strategy tester log :
2015.08.26 14:09:47.704 2001.08.29 16:15 array out of range in 'Kamikadze_MA_V_04_42_Fibo_03.mq4' (929,29)
(929,29) - is this a string and the sequence number of the character in the string?
Yes.
Two years it works, and then bang and error - I think there are a lot of orders at that point. Here is the code, what is wrong here (highlighted in bold) - advise - please
if(!CloseOk)
{
if(OrderType()==OP_BUY)
{
//Print("BUY=",OrderTicket());
nBuy++;
if(lastTimeBuy<1 || lastTimeBuy<OrderOpenTime())lastTimeBuy=OrderOpenTime();
//if (TP_Error<stplvl/Point)TP_Error=stplvl/Point;
//if (OrderOpenPrice()+stplvl>MAT)NewTP=Ask+TP_Error*Point;else NewTP=MAT;
//if (TP_Error==0)NewTP=MAT;
NewTP=NormalizeDouble(MAT,Digits);
if(MathAbs(NewTP-OrderTakeProfit())>1*Point)
{//модифицируем ТП
if(swCommentary)
Print("Модификация Тейк-Профита BUY "+DoubleToStr(NewTP,Digits)+" OPEN="+OrderOpenPrice());
ModifyStopTake(0,stpls,NewTP);takepr=NewTP;
}
if(BU!=0 && OrderStopLoss()!=(OrderOpenPrice()+BU*Point) && //безубыток
Bid>BUbuy && Ask>(OrderOpenPrice()+BU*Point+stplvl) &&
(Levl_Zerro==0 || (maMirrorOBuy<(OrderOpenPrice()-Levl_Zerro*Point))))
{
if(swCommentary)Print("Безубыток BUY "+DoubleToStr(OrderOpenPrice()+BU*Point,Digits));
if(maMBlock!=1){Print("BUY 2");ModifyStopTake(0,OrderOpenPrice()+BU*Point,takepr);stpls=OrderOpenPrice()+BU*Point;}
OrderBU[NorderBU]=OrderTicket();NorderBU++;
}//maMBlock!=1&&
if(BarSL!=0 && iBarShift(NULL,0,OrderOpenTime())>=BarSL)
{
if(swCommentary)Print("BARSL BUY");ClosePosBySelect();
if(blockBarSL>0)
{
YesBarSLBuy=0;if(swCommentary)Print("blockBARSL BUY");
//ClosePositions("NULL",OP_BUY,Magic);
ClosePosBySelect();
}
}//BARSL
}
if(OrderType()==OP_SELL)
{
//Print("SELL=",OrderTicket());
nSell++;
if(lastTimeSell<1 || lastTimeSell<OrderOpenTime())lastTimeSell=OrderOpenTime();
//if (TP_Error<stplvl/Point)TP_Error=stplvl/Point;
//if (OrderOpenPrice()-stplvl<MAT)NewTP=Bid-TP_Error*Point;else NewTP=MAT;
//if (TP_Error==0)NewTP=MAT;
NewTP=NormalizeDouble(MAT,Digits);
if(MathAbs(NewTP-OrderTakeProfit())>1*Point)
{//модифицируем ТП
if(swCommentary)
Print("Модификация Тейк-Профита SELL "+DoubleToStr(NewTP,Digits)+" OPEN="+OrderOpenPrice()+
" STOP="+OrderStopLoss());
ModifyStopTake(0,stpls,NewTP);takepr=NewTP;
}
if(BU!=0 && OrderStopLoss()!=(OrderOpenPrice()-BU*Point) && Bid<BUsell && //безубыток
Bid<(OrderOpenPrice()-BU*Point-stplvl) &&
(Levl_Zerro==0 || ((OrderOpenPrice()+Levl_Zerro*Point)<maMirrorOSell)))
{
if(swCommentary)Print("Безубыток SELL "+DoubleToStr(OrderOpenPrice()-BU*Point,Digits));
if(maMBlock!=1){Print("SELL 2");ModifyStopTake(0,OrderOpenPrice()-BU*Point,takepr);stpls=OrderOpenPrice()-BU*Point;}
OrderBU[NorderBU]=OrderTicket();NorderBU++;
} // maMBlock!=1&&
if(BarSL!=0 && iBarShift(NULL,0,OrderOpenTime())>=BarSL)
{
if(swCommentary)Print("BARSL SELL");
ClosePosBySelect();
if(blockBarSL>0)
{
YesBarSLSell=0;if(swCommentary)Print("BARSL SELL");
//ClosePositions("NULL",OP_SELL,Magic);
ClosePosBySelect();
}
}//BARSL
}
}
Two years it works, and then bang and error - I think there are a lot of orders at that point. Here is the code, what is wrong here (highlighted in bold) - advise - please
You are going outside of the OrderBU array.
Added: use styling - this will help make the code readable.
Two years it works, and then bang and error - I think there are a lot of orders at that point. Here is the code, what is wrong here (highlighted in bold) - advise - please
if(!CloseOk)
{
if(OrderType()==OP_BUY)
{
//Print("BUY=",OrderTicket());
nBuy++;
if(lastTimeBuy<1 || lastTimeBuy<OrderOpenTime())lastTimeBuy=OrderOpenTime();
//if (TP_Error<stplvl/Point)TP_Error=stplvl/Point;
//if (OrderOpenPrice()+stplvl>MAT)NewTP=Ask+TP_Error*Point;else NewTP=MAT;
//if (TP_Error==0)NewTP=MAT;
NewTP=NormalizeDouble(MAT,Digits);
if(MathAbs(NewTP-OrderTakeProfit())>1*Point)
{//модифицируем ТП
if(swCommentary)
Print("Модификация Тейк-Профита BUY "+DoubleToStr(NewTP,Digits)+" OPEN="+OrderOpenPrice());
ModifyStopTake(0,stpls,NewTP);takepr=NewTP;
}
if(BU!=0 && OrderStopLoss()!=(OrderOpenPrice()+BU*Point) && //безубыток
Bid>BUbuy && Ask>(OrderOpenPrice()+BU*Point+stplvl) &&
(Levl_Zerro==0 || (maMirrorOBuy<(OrderOpenPrice()-Levl_Zerro*Point))))
{
if(swCommentary)Print("Безубыток BUY "+DoubleToStr(OrderOpenPrice()+BU*Point,Digits));
if(maMBlock!=1){Print("BUY 2");ModifyStopTake(0,OrderOpenPrice()+BU*Point,takepr);stpls=OrderOpenPrice()+BU*Point;}
OrderBU[NorderBU]=OrderTicket();NorderBU++;
}//maMBlock!=1&&
if(BarSL!=0 && iBarShift(NULL,0,OrderOpenTime())>=BarSL)
{
if(swCommentary)Print("BARSL BUY");ClosePosBySelect();
if(blockBarSL>0)
{
YesBarSLBuy=0;if(swCommentary)Print("blockBARSL BUY");
//ClosePositions("NULL",OP_BUY,Magic);
ClosePosBySelect();
}
}//BARSL
}
if(OrderType()==OP_SELL)
{
//Print("SELL=",OrderTicket());
nSell++;
if(lastTimeSell<1 || lastTimeSell<OrderOpenTime())lastTimeSell=OrderOpenTime();
//if (TP_Error<stplvl/Point)TP_Error=stplvl/Point;
//if (OrderOpenPrice()-stplvl<MAT)NewTP=Bid-TP_Error*Point;else NewTP=MAT;
//if (TP_Error==0)NewTP=MAT;
NewTP=NormalizeDouble(MAT,Digits);
if(MathAbs(NewTP-OrderTakeProfit())>1*Point)
{//модифицируем ТП
if(swCommentary)
Print("Модификация Тейк-Профита SELL "+DoubleToStr(NewTP,Digits)+" OPEN="+OrderOpenPrice()+
" STOP="+OrderStopLoss());
ModifyStopTake(0,stpls,NewTP);takepr=NewTP;
}
if(BU!=0 && OrderStopLoss()!=(OrderOpenPrice()-BU*Point) && Bid<BUsell && //безубыток
Bid<(OrderOpenPrice()-BU*Point-stplvl) &&
(Levl_Zerro==0 || ((OrderOpenPrice()+Levl_Zerro*Point)<maMirrorOSell)))
{
if(swCommentary)Print("Безубыток SELL "+DoubleToStr(OrderOpenPrice()-BU*Point,Digits));
if(maMBlock!=1){Print("SELL 2");ModifyStopTake(0,OrderOpenPrice()-BU*Point,takepr);stpls=OrderOpenPrice()-BU*Point;}
OrderBU[NorderBU]=OrderTicket();NorderBU++;
} // maMBlock!=1&&
if(BarSL!=0 && iBarShift(NULL,0,OrderOpenTime())>=BarSL)
{
if(swCommentary)Print("BARSL SELL");
ClosePosBySelect();
if(blockBarSL>0)
{
YesBarSLSell=0;if(swCommentary)Print("BARSL SELL");
//ClosePositions("NULL",OP_SELL,Magic);
ClosePosBySelect();
}
}//BARSL
}
}
Your error "Out of array" means that the EA asks for a value greater than the array is initialized or the array is processed,
For example, if the array processes 6 parameters, in the initialisation should be 6 (from 0 to 5 what we are processing), counting is from zero and the initialisation is from 1.
You are going outside the OrderBU array.
Added: use styling - this will help make the code readable.
Thanks for the tip, the array window is decent ArrayResize(OrderBU,1000); how come...
You pay people - they write it, and then you sit and puzzle over it.
Thanks for the tip, the array window is decent ArrayResize(OrderBU,1000); how come...
You pay people - they write it, and then you sit and puzzle over it.
Since "two years has been working", it means that the code was written for old mql4, where array overruns were "allowed", now they are not, now it's an error. You're right.