- When you post code please use the CODE button (Alt-S)!
(For large amounts of code, attach it.)
Please edit
your (original) post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor double ArrayUp[][100000],ArrayDown[][100000],ArrayCompare1[]; ArrayUp[0][0] = PreviousAsk;
Your array has no size, yet you try to assign to it. What part of "out of range" is unclear?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 everybody,
I've tested the EA there :
#include<Trade\Trade.mqh>
CTrade trade;
double PreviousAsk = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
double PreviousBid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
int m = 0;
int n = 1;
int e = 0;
int i = 1;
int u = 0;
void OnTick()
{
double ArrayUp[][100000],ArrayDown[][100000],ArrayCompare1[];
double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
ArraySetAsSeries(ArrayCompare1,true);
ArrayUp[0][0] = PreviousAsk;
ArrayDown[0][0] = PreviousBid;
if(Ask>PreviousAsk)
{
ArrayUp[n][m] = Ask;
n++;
ArrayCompare1[u] = Ask;
}
else if(Bid<PreviousBid)
{
ArrayDown[i][e] = Bid;
i++;
ArrayCompare1[u] =Bid;
}
if(u>=1 && (ArrayCompare1[u-1]==ArrayUp[n-2][m]) && ( ArrayCompare1[u]==ArrayDown[i-1][e]) )
{m++;}
if(u>=1 && (ArrayCompare1[u-1]==ArrayDown[i-2][e]) && ( ArrayCompare1[u]==ArrayUp[n-1][m]) )
{e++;}
u++;
if (n>=3 && PositionsTotal()<=5)
{trade.Buy(0.01,NULL,Ask,(Ask-100*_Point),(Ask+30*_Point),NULL);
double SL=NormalizeDouble(Ask-100*_Point,_Digits);
for (int y=PositionsTotal(); y<0; y--)
{string symbol=PositionGetSymbol(i);
if (_Symbol==symbol)
{
ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
double CurrentStopLoss=PositionGetDouble(POSITION_SL);
if (CurrentStopLoss<SL)
{trade.PositionModify(PositionTicket,(CurrentStopLoss+10*_Point),0);
}
}
}
}
if(i>=3 && PositionsTotal()<=5)
{trade.Sell(0.01,NULL,Bid,(Bid+100*_Point),(Bid-30*_Point),NULL);
double SL=NormalizeDouble(Bid+100*_Point,_Digits);
for (int z=PositionsTotal(); z<0; z--)
{string symbol=PositionGetSymbol(i);
if (_Symbol==symbol)
{
ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
double CurrentStopLoss=PositionGetDouble(POSITION_SL);
if (CurrentStopLoss>SL)
{trade.PositionModify(PositionTicket,(CurrentStopLoss-10*_Point),0);
}
}
}
}
PreviousAsk = Ask;
PreviousBid = Bid;
}
And I get two errors I can't solve :
-OnTick critical error
-Array out of range
(I haven't any error when debugging.)
Thank you for your help.