Hello,
I'm trying to add another line to my MA indicator but I'm not sure how to do this very simple thing.
I just want to have another line that look exactly like my Moving Average but + a number of ticks/pips. I attach an image to make it clear.
How do I add it to this simple MA indicator code? :
In my other software that I use (eSignal) it's simlple as this code:
Any help will be much appreciated.
Kind Regards,
Johny-Raa.
I'm trying to add another line to my MA indicator but I'm not sure how to do this very simple thing.
I just want to have another line that look exactly like my Moving Average but + a number of ticks/pips. I attach an image to make it clear.
How do I add it to this simple MA indicator code? :
Inserted Code
#property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Green extern int period=5; double SMA[]; double sum=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexBuffer(0, SMA); SetIndexLabel(0,"Sma"); SetIndexStyle(0,DRAW_LINE); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- int limit; if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; limit=Bars-counted_bars-1; for(int i=limit; i >=0; i--) { sum=0; for(int j=i+period-1;j>=i; j--) { sum+=Close[j]; } SMA[i]=sum/period; } return(0); }
In my other software that I use (eSignal) it's simlple as this code:
Inserted Code
var MA; function main() { MA = sma(200); var MAextra = MA; return new array(MA, MAextra+100); }
Any help will be much appreciated.
Kind Regards,
Johny-Raa.