benny3 Posted January 12, 2010 Report Posted January 12, 2010 Hi i'm looking for a Macd color change indicator not as a histogram but just as a switch on color, so when the lines cross the color changes from (green as buy) (Red as sell) I've tried searching everywhere on the net but i can't seem to find it anywhere
cubicrey Posted January 12, 2010 Report Posted January 12, 2010 Re: (Req) MACD Colour cross indicator Hi benny3, Try this MACDbar //+------------------------------------------------------------------+ //| MACDBars.mq4 modified from | //| mtt-ErgodicMACD.mq4 | //| Copyright © 2004-07, MetaQuotes Software Corp. | //| [url]http://www.metaquotes.net/[/url] | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004-07, mietectec" #property link "" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DarkGreen #property indicator_color2 Red #property indicator_width1 4 #property indicator_width2 4 #property indicator_minimum 0 #property indicator_maximum 1 // MACD extern int FastEma = 12; extern int SlowEma = 26; extern int SignalSMMA = 9; extern string note1 = "0=Close,1=Open,2=High,3=Low"; extern string note2 = "4=Median Price,5=Typical Price"; extern string note3 = "6=Weighted Price"; extern int PriceField = 0; extern string note4 = "Numbers of bars to calculate"; extern int MaxBars=392; //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4,indicator_color1); SetIndexBuffer(0,ExtMapBuffer1); SetIndexLabel(0,"BuyZone"); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4,indicator_color2); SetIndexBuffer(1,ExtMapBuffer2); SetIndexLabel(1,"SellZone"); //---- name for DataWindow and indicator subwindow label string shortName = "MACD ("+FastEma+","+SlowEma+","+SignalSMMA+")"; IndicatorShortName(shortName); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Calculations | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>MaxBars) limit=MaxBars; //---- main loop for(int i=0; i<limit; i++) { ExtMapBuffer1[i] = 0; ExtMapBuffer2[i] = 0; /* double indMacdMain0 = iCustom(NULL, 0,"MACDsmoothed", FastEma, SlowEma, SignalSMMA, 0, i); double indMacdMain1 = iCustom(NULL, 0, "MACDsmoothed", FastEma, SlowEma, SignalSMMA, 0, i+1); double indMacdSignal0 = iCustom(NULL, 0, "MACDsmoothed",FastEma, SlowEma, SignalSMMA, 1, i); double indMacdSignal1 = iCustom(NULL, 0, "MACDsmoothed",FastEma, SlowEma, SignalSMMA, 1, i+1); */ double indMacdMain0 = iMACD(NULL,0,FastEma, SlowEma, SignalSMMA,PriceField,0,i); double indMacdMain1 = iMACD(NULL,0,FastEma, SlowEma, SignalSMMA,PriceField,0,i+1); double indMacdSignal0 = iMACD(NULL,0,FastEma, SlowEma, SignalSMMA,PriceField,1,i); double indMacdSignal1 = iMACD(NULL,0,FastEma, SlowEma, SignalSMMA,PriceField,1,i+1); if (indMacdMain0 > indMacdSignal0) ExtMapBuffer1[i]=2; else if (indMacdMain0 < indMacdSignal0 ) ExtMapBuffer2[i]=2; } return(0); } //+------------------------------------------------------------------+ http://www.abysse.co.jp/mt4/indicatorimgaes2/MACDBars.gif taipan and GTA 2 All that is necessary for evil to triumph is for good men/women to do nothing. Sharing is caring
benny3 Posted January 13, 2010 Author Report Posted January 13, 2010 Re: (Req) MACD Colour cross indicator That's the one i was after cubicrey :-bd :-bd :-bd :-bd
Fortuna1713006009 Posted November 20, 2011 Report Posted November 20, 2011 Do you have MTF version of this indicator? Thanks
atilabr Posted November 20, 2011 Report Posted November 20, 2011 //+------------------------------------------------------------------+ //| MACDBars.mq4 modified from | //| mtt-ErgodicMACD.mq4 | //| Copyright © 2004-07, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004-07, mietectec" #property link "" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DarkGreen #property indicator_color2 Red #property indicator_width1 4 #property indicator_width2 4 #property indicator_minimum 0 #property indicator_maximum 1 // MACD extern int Timeframe=0; extern int FastEma = 12; extern int SlowEma = 26; extern int SignalSMMA = 9; extern string note1 = "0=Close,1=Open,2=High,3=Low"; extern string note2 = "4=Median Price,5=Typical Price"; extern string note3 = "6=Weighted Price"; extern int PriceField = 0; extern string note4 = "Numbers of bars to calculate"; extern int MaxBars=392; //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4,indicator_color1); SetIndexBuffer(0,ExtMapBuffer1); SetIndexLabel(0,"BuyZone"); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4,indicator_color2); SetIndexBuffer(1,ExtMapBuffer2); SetIndexLabel(1,"SellZone"); //---- name for DataWindow and indicator subwindow label string shortName = "MACD ("+FastEma+","+SlowEma+","+SignalSMMA+")"; IndicatorShortName(shortName); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Calculations | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>MaxBars) limit=MaxBars; //---- main loop for(int i=0; i<limit; i++) { ExtMapBuffer1 = 0; ExtMapBuffer2 = 0; /* double indMacdMain0 = iCustom(NULL, 0,"MACDsmoothed", FastEma, SlowEma, SignalSMMA, 0, i); double indMacdMain1 = iCustom(NULL, 0, "MACDsmoothed", FastEma, SlowEma, SignalSMMA, 0, i+1); double indMacdSignal0 = iCustom(NULL, 0, "MACDsmoothed",FastEma, SlowEma, SignalSMMA, 1, i); double indMacdSignal1 = iCustom(NULL, 0, "MACDsmoothed",FastEma, SlowEma, SignalSMMA, 1, i+1); */ double indMacdMain0 = iMACD(NULL,Timeframe,FastEma, SlowEma, SignalSMMA,PriceField,0,i); double indMacdMain1 = iMACD(NULL,Timeframe,FastEma, SlowEma, SignalSMMA,PriceField,0,i+1); double indMacdSignal0 = iMACD(NULL,Timeframe,FastEma, SlowEma, SignalSMMA,PriceField,1,i); double indMacdSignal1 = iMACD(NULL,Timeframe,FastEma, SlowEma, SignalSMMA,PriceField,1,i+1); if (indMacdMain0 > indMacdSignal0) ExtMapBuffer1=2; else if (indMacdMain0 < indMacdSignal0 ) ExtMapBuffer2=2; } return(0); } //+------------------------------------------------------------------+ Fortuna1713006009 and mtuppers 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now