Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor Your code Documentation CopyTime( Time, _Period, 0, 999999, myTime );
int CopyTime( string symbol_name, // symbol name ENUM_TIMEFRAMES timeframe, // period int start_pos, // start position int count, // data count to copy datetime time_array[] // target array to copy open times );
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014
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
Was trying to write a signal trigger alert that only appear once but not sure what it keeps pop out "array out of range" in my code. Anyone can help on this?
#include <Trade\Trade.mqh>
CTrade trade;
datetime LastActiontime;
void OnTick()
{
double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
datetime myTime[];
double myRSIArray[];
ArraySetAsSeries(myRSIArray,true);
ArrayResize(myTime,100000,100000);
int myRSIDefinition = iRSI(_Symbol,_Period,14,PRICE_CLOSE);
datetime Time = iTime(_Symbol,_Period,0);
CopyBuffer(myRSIDefinition,0,0,3,myRSIArray);
CopyTime(Time,_Period,0,999999,myTime);
double myRSIValue0=NormalizeDouble(myRSIArray[0],2);
double myRSIValue1=NormalizeDouble(myRSIArray[1],2);
double myRSIValue2=NormalizeDouble(myRSIArray[2],2);
if(myRSIValue1>=70 && myRSIValue2<70
&& LastActiontime!=myTime[0]
){
Alert("RSI cross-up 70"+" "+_Symbol);
LastActiontime=myTime[0];
}
if(myRSIValue1<70 && myRSIValue2>=70
&& LastActiontime!=myTime[0]
){
Alert("RSI cross-down 70"+" "+_Symbol);
LastActiontime=myTime[0];
}
if(myRSIValue1<=30 && myRSIValue2>30
&& LastActiontime!=myTime[0]
){
Alert("RSI cross-down 30"+" "+_Symbol);
LastActiontime=myTime[0];
}
if(myRSIValue1>30 && myRSIValue2<=30
&& LastActiontime!=myTime[0]
){
Alert("RSI cross-up 30"+" "+_Symbol);
LastActiontime=myTime[0];
}
}