Please don't double post.
Marco vd Heijden:
Please don't double post.
Its not double post. Its different indicator!
Please don't double post.
FxEmpire:
#property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Yellow #property indicator_color2 Red #property indicator_color3 Magenta #property indicator_color4 Magenta #property indicator_width3 1 #property indicator_width4 1 input bool SendNotify=true; extern bool RSICCI_Filter = FALSE; extern double RSIPeriod = 14; extern double RSIOverbought = 75; extern double RSIOversold = 25; extern double CCIPeriod = 14; extern double CCIBuyLevel = 50; extern double CCISellLevel = -50; extern bool HighLow = FALSE; extern int SignalLine = 1; extern bool Alerts = TRUE; extern bool AlertOnClose = TRUE; extern int BarCount = 10000; bool HighBreakout = FALSE; bool HighBreakPending = FALSE; bool LowBreakout = FALSE; bool LowBreakPending = FALSE; double LastResistance = 0; double LastSupport = 0; double AlertBar = 0; //---- buffers double v1[]; double v2[]; double BreakUp[]; double BreakDown[]; double val1; double val2; int counter1; int counter2; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexArrow(0, 119); SetIndexArrow(1, 119); //---- SetIndexStyle(0, DRAW_LINE, STYLE_DOT, 0, Snow); //SetIndexDrawBegin(0, i-1); SetIndexBuffer(0, v1); SetIndexLabel(0, "Resistance"); //---- SetIndexStyle(1, DRAW_LINE, STYLE_DOT, 0, Snow); //SetIndexDrawBegin(1, i-1); SetIndexBuffer(1, v2); SetIndexLabel(1, "Support"); //---- SetIndexStyle(2, DRAW_ARROW, EMPTY, 2); SetIndexArrow(2, 233); SetIndexBuffer(2, BreakUp); //---- SetIndexStyle(3, DRAW_ARROW, EMPTY, 2); SetIndexArrow(3, 234); SetIndexBuffer(3, BreakDown); return(0); } //+------------------------------------------------------------------+ int start() { //---- for(int i = BarCount; i >=0; i--) { val1 = iFractals(NULL, 0, MODE_UPPER, i); //---- if(val1 > 0) { v1[i] = High[i]; counter1 = 1; } else { v1[i] = v1[i+1]; counter1++; } val2 = iFractals(NULL, 0, MODE_LOWER, i); //---- if(val2 > 0) { v2[i] = Low[i]; counter2 = 1; } else { v2[i] = v2[i+1]; counter2++; } if (v1[i] != LastResistance) { HighBreakPending = True; LastResistance = v1[i]; } if (v2[i] != LastSupport) { LowBreakPending = True; LastSupport = v2[i]; } if (HighLow) double BPrice=High[i]; else BPrice=Close[i]; if (HighBreakPending && BPrice > v1[i] && (!RSICCI_Filter || (RSICCI_Filter && iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i) < RSIOverbought && iCCI(Symbol(), NULL, CCIPeriod, PRICE_CLOSE, i) > CCIBuyLevel)) && counter1 >= SignalLine) HighBreakout = TRUE; if (HighLow) BPrice=Low[i]; else BPrice=Close[i]; if (LowBreakPending && BPrice < v2[i] && (!RSICCI_Filter || (RSICCI_Filter && iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i) > RSIOversold && iCCI(Symbol(), NULL, CCIPeriod, PRICE_CLOSE, i) < CCISellLevel)) && counter2 >= SignalLine) LowBreakout = TRUE; if (AlertOnClose) int AlertCandle = 1; else AlertCandle = 0; if (HighBreakout) { if (i >= AlertCandle) BreakUp[i] = Low[i]-10*Point; if (i == AlertCandle && Bars > AlertBar) { if (Alerts) Alert(Symbol(), " M", Period(), ": Resistance Breakout: BUY"); if (SendNotify) SendNotification(Symbol()+ " M"+ Period()+ ": Resistance Breakout: BUY"); AlertBar = Bars; } HighBreakout = False; HighBreakPending = False; } else if (LowBreakout) { if (i >= AlertCandle) BreakDown[i] = High[i]+10*Point; if ( i==AlertCandle && Bars>AlertBar) { if (Alerts) Alert(Symbol(), " M", Period(), ": Support Breakout: SELL"); if (SendNotify) SendNotification(Symbol()+ " M"+ Period()+ ": Resistance Breakout: SELL"); AlertBar = Bars; } LowBreakout = False; LowBreakPending = False; } } return(0); }
Mehmet Bastem:
Thank you very much for your work. Highly appreciate it!!!
Thank you very much for your work. Highly appreciate it!!!
#property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 clrLime #property indicator_color2 clrRed #property indicator_color3 clrMagenta #property indicator_color4 clrBlue //---- #define arrowsDisplacement 0.0001 //---- input parameters extern string separator1="*** MACD Settings ***"; extern int fastEMA = 12; extern int slowEMA = 26; extern int signalSMA=9; extern string separator2="*** Indicator Settings ***"; extern bool drawIndicatorTrendLines=true; extern bool drawPriceTrendLines=true; extern bool displayAlert=true; //---- buffers double bullishDivergence[]; double bearishDivergence[]; double macd[]; double signal[]; //---- static datetime lastAlertTime; static string indicatorName; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW); SetIndexStyle(1,DRAW_ARROW); SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); //---- SetIndexBuffer(0,bullishDivergence); SetIndexBuffer(1,bearishDivergence); SetIndexBuffer(2,macd); SetIndexBuffer(3,signal); //---- SetIndexArrow(0,233); SetIndexArrow(1,234); //---- indicatorName="FX5_MACD_Divergence_v1.1("+fastEMA+", "+ slowEMA+", "+signalSMA+")"; SetIndexDrawBegin(3,signalSMA); IndicatorDigits(Digits+2); IndicatorShortName(indicatorName); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { for(int i=ObjectsTotal()-1; i>=0; i--) { string label=ObjectName(i); if(StringSubstr(label,0,19)!="MACD_DivergenceLine") continue; ObjectDelete(label); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int countedBars=IndicatorCounted(); if(countedBars<0) countedBars=0; CalculateIndicator(countedBars); //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CalculateIndicator(int countedBars) { int limit=Bars-countedBars; if(countedBars==0) limit-=slowEMA; for(int i=limit; i>=0; i--) { CalculateMACD(i); CatchBullishDivergence(i+2); CatchBearishDivergence(i+2); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CalculateMACD(int i) { macd[i]=iMACD(NULL,0,fastEMA,slowEMA,signalSMA, PRICE_CLOSE,MODE_MAIN,i); signal[i]=iMACD(NULL,0,fastEMA,slowEMA,signalSMA, PRICE_CLOSE,MODE_SIGNAL,i); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CatchBullishDivergence(int shift) { if(IsIndicatorTrough(shift)==false) return; int currentTrough=shift; int lastTrough=GetIndicatorLastTrough(shift); //---- if((lastTrough>=0 && lastTrough<Bars) && macd[currentTrough]>macd[lastTrough] && Low[currentTrough]<Low[lastTrough]) { bullishDivergence[currentTrough]=macd[currentTrough]- arrowsDisplacement; //---- if(drawPriceTrendLines==true) DrawPriceTrendLine(Time[currentTrough],Time[lastTrough], Low[currentTrough], Low[lastTrough],Lime,STYLE_SOLID); //---- if(drawIndicatorTrendLines==true) DrawIndicatorTrendLine(Time[currentTrough], Time[lastTrough], macd[currentTrough], macd[lastTrough], Lime,STYLE_SOLID); //---- if(displayAlert==true) DisplayAlert("Classical bullish divergence on: ", currentTrough); } //---- if((lastTrough>=0 && lastTrough<Bars) && macd[currentTrough]<macd[lastTrough] && Low[currentTrough]>Low[lastTrough]) { bullishDivergence[currentTrough]=macd[currentTrough]- arrowsDisplacement; //---- if(drawPriceTrendLines==true) DrawPriceTrendLine(Time[currentTrough],Time[lastTrough], Low[currentTrough], Low[lastTrough],Lime,STYLE_DOT); //---- if(drawIndicatorTrendLines==true) DrawIndicatorTrendLine(Time[currentTrough], Time[lastTrough], macd[currentTrough], macd[lastTrough], Lime,STYLE_DOT); //---- if(displayAlert==true) DisplayAlert("Reverse bullish divergence on: ", currentTrough); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CatchBearishDivergence(int shift) { if(IsIndicatorPeak(shift)==false) return; int currentPeak=shift; int lastPeak=GetIndicatorLastPeak(shift); //---- if((lastPeak>=0 && lastPeak<Bars) && macd[currentPeak]<macd[lastPeak] && High[currentPeak]>High[lastPeak]) { bearishDivergence[currentPeak]=macd[currentPeak]+ arrowsDisplacement; if(drawPriceTrendLines==true) DrawPriceTrendLine(Time[currentPeak],Time[lastPeak], High[currentPeak], High[lastPeak],Red,STYLE_SOLID); if(drawIndicatorTrendLines==true) DrawIndicatorTrendLine(Time[currentPeak],Time[lastPeak], macd[currentPeak], macd[lastPeak],Red,STYLE_SOLID); if(displayAlert==true) DisplayAlert("Classical bearish divergence on: ", currentPeak); } if((lastPeak>=0 && lastPeak<Bars) && macd[currentPeak]>macd[lastPeak] && High[currentPeak]<High[lastPeak]) { bearishDivergence[currentPeak]=macd[currentPeak]+ arrowsDisplacement; //---- if(drawPriceTrendLines==true) DrawPriceTrendLine(Time[currentPeak],Time[lastPeak], High[currentPeak], High[lastPeak],Red,STYLE_DOT); //---- if(drawIndicatorTrendLines==true) DrawIndicatorTrendLine(Time[currentPeak],Time[lastPeak], macd[currentPeak], macd[lastPeak],Red,STYLE_DOT); //---- if(displayAlert==true) DisplayAlert("Reverse bearish divergence on: ", currentPeak); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsIndicatorPeak(int shift) { if(macd[shift]>=macd[shift+1] && macd[shift]>macd[shift+2] && macd[shift]>macd[shift-1]) return(true); else return(false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsIndicatorTrough(int shift) { if(macd[shift]<=macd[shift+1] && macd[shift]<macd[shift+2] && macd[shift]<macd[shift-1]) return(true); else return(false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int GetIndicatorLastPeak(int shift) { for(int i=shift+5;(i<Bars-3) && (i>1); i++) { if(signal[i] >= signal[i+1] && signal[i] >= signal[i+2] && signal[i] >= signal[i-1] && signal[i] >= signal[i-2]) { for(int j=i;(j<Bars-3) && (j>1); j++) { if(macd[j] >= macd[j+1] && macd[j] > macd[j+2] && macd[j] >= macd[j-1] && macd[j] > macd[j-2]) return(j); } } } return(-1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int GetIndicatorLastTrough(int shift) { for(int i=shift+5;(i<Bars-3) && (i>1); i++) { if(signal[i] <= signal[i+1] && signal[i] <= signal[i+2] && signal[i] <= signal[i-1] && signal[i] <= signal[i-2]) { for(int j=i;(j<Bars-3) && (j>1); j++) { if(macd[j] <= macd[j+1] && macd[j] < macd[j+2] && macd[j] <= macd[j-1] && macd[j] < macd[j-2]) return(j); } } } return(-1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DisplayAlert(string message,int shift) { if(shift<=2 && Time[shift]!=lastAlertTime) { lastAlertTime=Time[shift]; Alert(message,Symbol()," , ",Period()," minutes chart"); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DrawPriceTrendLine(datetime x1,datetime x2,double y1, double y2,color lineColor,double style) { string label="MACD_DivergenceLine_v1.0# "+DoubleToStr(x1,0); ObjectDelete(label); ObjectCreate(label,OBJ_TREND,0,x1,y1,x2,y2,0,0); ObjectSet(label,OBJPROP_RAY,0); ObjectSet(label,OBJPROP_COLOR,lineColor); ObjectSet(label,OBJPROP_STYLE,style); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DrawIndicatorTrendLine(datetime x1,datetime x2,double y1, double y2,color lineColor,double style) { int indicatorWindow=WindowFind(indicatorName); if(indicatorWindow<0) return; string label="MACD_DivergenceLine_v1.0$# "+DoubleToStr(x1,0); ObjectDelete(label); ObjectCreate(label,OBJ_TREND,indicatorWindow,x1,y1,x2,y2, 0,0); ObjectSet(label,OBJPROP_RAY,0); ObjectSet(label,OBJPROP_COLOR,lineColor); ObjectSet(label,OBJPROP_STYLE,style); } //+------------------------------------------------------------------+
Hi! Mehmet!!!
Would you mind to encode PushNotification of this indicator please!!
Highly appreciate your effort!
FxEmpire:
Hi! Mehmet!!!
Would you mind to encode PushNotification of this indicator please!!
Highly appreciate your effort!
#property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 clrLime #property indicator_color2 clrRed #property indicator_color3 clrMagenta #property indicator_color4 clrBlue //---- #define arrowsDisplacement 0.0001 //---- input parameters extern string separator1 = "*** MACD Settings ***"; extern int fastEMA = 12; extern int slowEMA = 26; extern int signalSMA = 9; extern string separator2 = "*** Indicator Settings ***"; extern bool drawIndicatorTrendLines = true; extern bool drawPriceTrendLines = true; extern bool displayAlert = true; extern bool SendNotifi = true; //---- buffers double bullishDivergence[]; double bearishDivergence[]; double macd[]; double signal[]; //---- static datetime lastAlertTime; static string indicatorName; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW); SetIndexStyle(1, DRAW_ARROW); SetIndexStyle(2, DRAW_LINE); SetIndexStyle(3, DRAW_LINE); //---- SetIndexBuffer(0, bullishDivergence); SetIndexBuffer(1, bearishDivergence); SetIndexBuffer(2, macd); SetIndexBuffer(3, signal); //---- SetIndexArrow(0, 233); SetIndexArrow(1, 234); //---- indicatorName = "FX5_MACD_Divergence_v1.1(" + fastEMA + ", " + slowEMA + ", " + signalSMA + ")"; SetIndexDrawBegin(3, signalSMA); IndicatorDigits(Digits + 2); IndicatorShortName(indicatorName); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { for (int i = ObjectsTotal() - 1; i >= 0; i--) { string label = ObjectName(i); if (StringSubstr(label, 0, 19) != "MACD_DivergenceLine") continue; ObjectDelete(label); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int countedBars = IndicatorCounted(); if (countedBars < 0) countedBars = 0; CalculateIndicator(countedBars); //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CalculateIndicator(int countedBars) { int limit = Bars - countedBars; if (countedBars == 0) limit -= slowEMA; for (int i = limit; i >= 0; i--) { CalculateMACD(i); CatchBullishDivergence(i + 2); CatchBearishDivergence(i + 2); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CalculateMACD(int i) { macd[i] = iMACD(NULL, 0, fastEMA, slowEMA, signalSMA, PRICE_CLOSE, MODE_MAIN, i); signal[i] = iMACD(NULL, 0, fastEMA, slowEMA, signalSMA, PRICE_CLOSE, MODE_SIGNAL, i); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CatchBullishDivergence(int shift) { if (IsIndicatorTrough(shift) == false) return; int currentTrough = shift; int lastTrough = GetIndicatorLastTrough(shift); //---- if ((lastTrough >= 0 && lastTrough < Bars) && macd[currentTrough] > macd[lastTrough] && Low[currentTrough] < Low[lastTrough]) { bullishDivergence[currentTrough] = macd[currentTrough] - arrowsDisplacement; //---- if (drawPriceTrendLines == true) DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], Low[currentTrough], Low[lastTrough], Lime, STYLE_SOLID); //---- if (drawIndicatorTrendLines == true) DrawIndicatorTrendLine(Time[currentTrough], Time[lastTrough], macd[currentTrough], macd[lastTrough], Lime, STYLE_SOLID); //---- if (displayAlert == true) DisplayAlert("Classical bullish divergence on: ", currentTrough); } //---- if ((lastTrough >= 0 && lastTrough < Bars) && macd[currentTrough] < macd[lastTrough] && Low[currentTrough] > Low[lastTrough]) { bullishDivergence[currentTrough] = macd[currentTrough] - arrowsDisplacement; //---- if (drawPriceTrendLines == true) DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], Low[currentTrough], Low[lastTrough], Lime, STYLE_DOT); //---- if (drawIndicatorTrendLines == true) DrawIndicatorTrendLine(Time[currentTrough], Time[lastTrough], macd[currentTrough], macd[lastTrough], Lime, STYLE_DOT); //---- if (displayAlert == true) DisplayAlert("Reverse bullish divergence on: ", currentTrough); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CatchBearishDivergence(int shift) { if (IsIndicatorPeak(shift) == false) return; int currentPeak = shift; int lastPeak = GetIndicatorLastPeak(shift); //---- if ((lastPeak >= 0 && lastPeak < Bars) && macd[currentPeak] < macd[lastPeak] && High[currentPeak] > High[lastPeak]) { bearishDivergence[currentPeak] = macd[currentPeak] + arrowsDisplacement; if (drawPriceTrendLines == true) DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], High[currentPeak], High[lastPeak], Red, STYLE_SOLID); if (drawIndicatorTrendLines == true) DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], macd[currentPeak], macd[lastPeak], Red, STYLE_SOLID); if (displayAlert == true) DisplayAlert("Classical bearish divergence on: ", currentPeak); } if ((lastPeak >= 0 && lastPeak < Bars) && macd[currentPeak] > macd[lastPeak] && High[currentPeak] < High[lastPeak]) { bearishDivergence[currentPeak] = macd[currentPeak] + arrowsDisplacement; //---- if (drawPriceTrendLines == true) DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], High[currentPeak], High[lastPeak], Red, STYLE_DOT); //---- if (drawIndicatorTrendLines == true) DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], macd[currentPeak], macd[lastPeak], Red, STYLE_DOT); //---- if (displayAlert == true) DisplayAlert("Reverse bearish divergence on: ", currentPeak); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsIndicatorPeak(int shift) { if (macd[shift] >= macd[shift + 1] && macd[shift] > macd[shift + 2] && macd[shift] > macd[shift - 1]) return(true); else return(false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsIndicatorTrough(int shift) { if (macd[shift] <= macd[shift + 1] && macd[shift] < macd[shift + 2] && macd[shift] < macd[shift - 1]) return(true); else return(false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int GetIndicatorLastPeak(int shift) { for (int i = shift + 5; (i < Bars - 3) && (i > 1); i++) { if (signal[i] >= signal[i + 1] && signal[i] >= signal[i + 2] && signal[i] >= signal[i - 1] && signal[i] >= signal[i - 2]) { for (int j = i; (j < Bars - 3) && (j > 1); j++) { if (macd[j] >= macd[j + 1] && macd[j] > macd[j + 2] && macd[j] >= macd[j - 1] && macd[j] > macd[j - 2]) return(j); } } } return(-1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int GetIndicatorLastTrough(int shift) { for (int i = shift + 5; (i < Bars - 3) && (i > 1); i++) { if (signal[i] <= signal[i + 1] && signal[i] <= signal[i + 2] && signal[i] <= signal[i - 1] && signal[i] <= signal[i - 2]) { for (int j = i; (j < Bars - 3) && (j > 1); j++) { if (macd[j] <= macd[j + 1] && macd[j] < macd[j + 2] && macd[j] <= macd[j - 1] && macd[j] < macd[j - 2]) return(j); } } } return(-1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DisplayAlert(string message, int shift) { if (shift <= 2 && Time[shift] != lastAlertTime) { lastAlertTime = Time[shift]; Alert(message, Symbol(), " , ", Period(), " minutes chart"); if (SendNotifi) SendNotification(message + Symbol() + " , " + Period() + " minutes chart"); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DrawPriceTrendLine(datetime x1, datetime x2, double y1, double y2, color lineColor, double style) { string label = "MACD_DivergenceLine_v1.0# " + DoubleToStr(x1, 0); ObjectDelete(label); ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0); ObjectSet(label, OBJPROP_RAY, 0); ObjectSet(label, OBJPROP_COLOR, lineColor); ObjectSet(label, OBJPROP_STYLE, style); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DrawIndicatorTrendLine(datetime x1, datetime x2, double y1, double y2, color lineColor, double style) { int indicatorWindow = WindowFind(indicatorName); if (indicatorWindow < 0) return; string label = "MACD_DivergenceLine_v1.0$# " + DoubleToStr(x1, 0); ObjectDelete(label); ObjectCreate(label, OBJ_TREND, indicatorWindow, x1, y1, x2, y2, 0, 0); ObjectSet(label, OBJPROP_RAY, 0); ObjectSet(label, OBJPROP_COLOR, lineColor); ObjectSet(label, OBJPROP_STYLE, style); } //+------------------------------------------------------------------+
Your Welcome :)
Koros Jafarzadeh:
Your Welcome :)
Thank yo so much buddy!! Highly appreciate your effort.
God bless you!!
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