Harapa: Please help me to modify the code below so it will:
RaptorUK:
Please edit your post . . . or have your code removed
Please use this to post code . . . it makes it easier to read.
Thanks for the advice. I edited my original post.
Please edit your post . . . or have your code removed
Please use this to post code . . . it makes it easier to read.
Harapa:
Thanks for the advice. I edited my original post.
Thank you :-)
Thanks for the advice. I edited my original post.
So I re-did the code. Now it does exactly what I wanted to do. In doing this I re-learned that it is more fun to solve a puzzle than look for its answer;you enjoy few moments of glory plus you keep your respect.
So for newbies, this indicator calculates inverse of any instrument (user defined), and plots difference of two moving averages as two colored (user selected) histogram. There are few other ways to use this indicator as well, I will update you with those options as soon as I have them ready.
//---- indicator settings #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Aqua #property indicator_color2 Lime #property indicator_color3 Red #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 //---- indicator parameters extern string Instrument = "EURUSD"; extern int SignalMethod = MODE_EMA; extern int Fast_MA = 34; extern int Slow_MA = 89; //----indicator buffers double HistoBuffer[]; double HistoBufferHup[]; double HistoBufferHdn[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators setting SetIndexBuffer(0, HistoBuffer); SetIndexBuffer(1, HistoBufferHup); SetIndexBuffer(2, HistoBufferHdn); //---- SetIndexStyle(0, DRAW_LINE); SetIndexStyle(1, DRAW_HISTOGRAM); SetIndexStyle(2, DRAW_HISTOGRAM); // IndicatorShortName("MACD ONE:"+Instrument+" ("+Fast_MA+","+Slow_MA+")"); return(0); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int start() {{ int counted_bars=IndicatorCounted(); int i,limit; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = MathMin(Bars-counted_bars,Bars-1); // // // for(i=limit; i>=0; i--) HistoBuffer[i] = 1 / MathMax(iMA(Instrument,0,1,0,MODE_EMA,PRICE_CLOSE,i),Point); for(i=limit; i>=0; i--) { HistoBuffer[i] = iMAOnArray(HistoBuffer,Bars,Fast_MA, 0,SignalMethod,i) - iMAOnArray(HistoBuffer,Bars,Slow_MA,0,SignalMethod,i); if(HistoBuffer[i] >= 0) HistoBufferHup[i] = HistoBuffer[i]; else HistoBufferHup[i] = 0; //---- if(HistoBuffer[i] < 0 ) HistoBufferHdn[i] = HistoBuffer[i]; else HistoBufferHdn[i] = 0; } //---- done return(0); } } //---------------------

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
I have an indicator which allows me to plot inverse of any price. In addition to plotting the inverse, it also computes two moving average of the inverse and draws Bollinger's Bands. I use MA crosses to identify change in trend. Currently I manually check for the cross. I need your help to modify it so it will make identification of the cross easier (manually) and mark such an event automatically on the price chart.
Please help me to modify the code below so it will:
1. Display the difference of two moving averages as histogram in two different colors (much like two color MACD).
2. Draw an up/down arrow on the price chart whenever the histogram crosses up/down the zero line.
Thanks in advance . Here is the original code.