Reverse the code?
i tried to reverse, but it dosen't work, the alert goes on evry nimute when rsi is lower then 70 (i need alert only on the cross line)
this is the code
#property indicator_separate_window #property indicator_minimum 0 #property indicator_level1 30 #property indicator_level2 70 #property indicator_buffers 1 #property indicator_color1 LightBlue extern int period=3; extern int applied_price=0; extern bool EnableAlert=true; extern double OverSold=30; extern double OverBought=70; extern bool EnableSendMail=false; extern bool EnableComment=true; datetime Timee; double RSI_Line[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0,RSI_Line); SetIndexStyle(0,DRAW_LINE); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { Comment(""); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if(EnableComment)Comment("King_Prog"+"\n"+"www.forexdyr.com"); int bars=Bars-IndicatorCounted(); for(int i=0;i<=bars;i++) { RSI_Line[i]=iRSI(Symbol(),0,period,applied_price,i); } if(RSI_Line[1]>=OverBought&&RSI_Line[2]<OverBought&&Timee!=Time[0]) { if(EnableAlert)Alert("RSI Over Bought "+Symbol()+" TF: "+Period()); if(EnableSendMail)SendMail("RSI Over Bought","RSI Over Bought "+Symbol()+" period: "+Period()); Timee=Time[0]; } if(RSI_Line[1]<=OverSold&&RSI_Line[2]>OverSold&&Timee!=Time[0]) { if(EnableAlert)Alert("RSI Over Sold "+Symbol()+" TF: "+Period()); if(EnableSendMail)SendMail("RSI Over Sold","RSI Over Sold "+Symbol()+" period: "+Period()); Timee=Time[0]; } }
goghi: i tried to reverse, but it dosen't work, the alert goes on evry nimute when rsi is lower then 70 (i need alert only on the cross line)
You are alerting on a true signal, and you get multiple ticks per bar. Instead either test once per bar or alert on a change of signal:if(RSI_Line[1]>=OverBought&&RSI_Line[2]<OverBought&&Timee!=Time[0])
static bool isOverBought = false; bool wasOverBought = isOverBought; isOverBought = RSI_Line[1]>=OverBought&&RSI_Line[2]<OverBought&&Timee!=Time[0]; if(isOverBought && !wasOverBought)
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,
i am making a little ea and i need an advice.
i make an alert for rsi crossing up the 70 level and i want another alert for when rsi coss down the 70 level.
how can i make this coss down code?
thanks