"Array out of range in 'dowgap_2.mq4' (210,27)".
Your error is at line 210, position 27.
Line 210 in the MetaEditor is this: POrder pOrder = pOrders[0];
Position 27 is the [0]
What could be wrong/missing there?
Line 210 in the MetaEditor is this: POrder pOrder = pOrders[0];
Position 27 is the [0]
What could be wrong/missing there?
You created the array on line 204:
But it has no size.
So when you try to access the first index with pOrders[0] you are out of range.
This page may help you work with arrays.
Play video | Please edit your
post. For large amounts of code, attach it. |
You created the array on line 204:
But it has no size.
So when you try to access the first index with pOrders[0] you are out of range.
This page may help you work with arrays.If it gets over 9 it will again cause the out of range error so you either must be sure it does not go over 9 or increase it's size before writing or reading from the non existent location.
So if you want to increase it by one for example:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have an EA made for me by a coder who I've lost contact with.
It works fine until I place a separate trade, whether on the same chart or different chart, whether from another EA or a manual trade, I get the error on the MT4 platform that says: "Array out of range in 'dowgap_2.mq4' (210,27)".
There seems to be some sort of clash between the EA functionality and placing other trades within the MT4 platform, but I'm at a loss. Any ideas?
}// Go through orders and check points profit..
POrder pOrders[];
int num = pTradeManager.Val.AllTradesAndOrders(Magic,pOrders);
if (!_takeHalfDone && (num > 0))
{
// Only expecting one order at posn 0
POrder pOrder = pOrders[0];
if (pOrder.Val.Active && (pOrder.Val.PipsProfit() >= TakeHalfPoints))
{
// We need to realise a proportion of the profits.
pOrder.Val.Size = TradeSizeCalculator::NormaliseSize(pOrder.Val.Size * TakeHalfAmount / 100.0);
_log.Write(INFO,"Trade has reached ",LOGLEVEL(TakeHalfPoints)," pnts profit, closing £",LOGSIZE(pOrder.Val.Size)," of the trade.");
pTradeManager.Val.CloseTrade( pOrder);
_takeHalfDone = true;
}
if (_takeHalfDone)
{
// The a new trade will have been created after partial close - so we need to fetch it again.
ArrayFree(pOrders);
num = pTradeManager.Val.AllTradesAndOrders(Magic,pOrders);
if (num > 0)
{
pOrder = pOrders[0];
_log.Write(INFO,"Moving stop of remaining amount to ", LOGLEVEL(TakeHalfStop), " points");
pOrder.Val.StopPoints(MathAbs(TakeHalfStop));
pTradeManager.Val.AmendTrade(pOrder);
}
}
}