//+------------------------------------------------------------------+ //| pipmaster_Colour.mq4 | //| Copyright 2015, @ | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2015, Raj Enterprises Limited" #property link "eatrader@raj-enterprises.co.uk" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 10 input color UpColor=clrGreen; input color DownColor=clrRed; input int LWMA1=20; input int LWMA2=30; input int LWMA3=100; input int LWMA4=200; input int LWMA5=1000; double upma1[],upma2[],upma3[],upma4[],upma5[]; double downma1[],downma2[],downma3[],downma4[],downma5[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,upma1); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,UpColor); SetIndexDrawBegin(0,LWMA1); SetIndexBuffer(1,downma1); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2,DownColor); SetIndexDrawBegin(1,LWMA1); SetIndexLabel(0,"LWMA("+IntegerToString(LWMA1)+")"); SetIndexLabel(1,"LWMA("+IntegerToString(LWMA1)+")"); SetIndexBuffer(2,upma2); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2,UpColor); SetIndexDrawBegin(2,LWMA2); SetIndexBuffer(3,downma2); SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2,DownColor); SetIndexDrawBegin(3,LWMA2); SetIndexLabel(2,"LWMA("+IntegerToString(LWMA2)+")"); SetIndexLabel(3,"LWMA("+IntegerToString(LWMA2)+")"); SetIndexBuffer(4,upma3); SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,2,UpColor); SetIndexDrawBegin(4,LWMA3); SetIndexBuffer(5,downma3); SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,2,DownColor); SetIndexDrawBegin(5,LWMA3); SetIndexLabel(4,"LWMA("+IntegerToString(LWMA3)+")"); SetIndexLabel(5,"LWMA("+IntegerToString(LWMA3)+")"); SetIndexBuffer(6,upma4); SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,2,UpColor); SetIndexDrawBegin(6,LWMA4); SetIndexBuffer(7,downma4); SetIndexStyle(7,DRAW_LINE,STYLE_SOLID,2,DownColor); SetIndexDrawBegin(7,LWMA4); SetIndexLabel(6,"LWMA("+IntegerToString(LWMA4)+")"); SetIndexLabel(7,"LWMA("+IntegerToString(LWMA4)+")"); SetIndexBuffer(8,upma5); SetIndexStyle(8,DRAW_LINE,STYLE_SOLID,2,UpColor); SetIndexDrawBegin(8,LWMA5); SetIndexBuffer(9,downma5); SetIndexStyle(9,DRAW_LINE,STYLE_SOLID,2,DownColor); SetIndexDrawBegin(9,LWMA5); SetIndexLabel(8,"LWMA("+IntegerToString(LWMA5)+")"); SetIndexLabel(9,"LWMA("+IntegerToString(LWMA5)+")"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int limit=rates_total-prev_calculated; if(rates_total<=LWMA1) return(0); if(prev_calculated==0)limit=rates_total-2; for( int i=limit;i>=0;i--){ double curMa1=iMA(Symbol(),0,LWMA1,0,MODE_LWMA,PRICE_CLOSE,i); double prevMa1=iMA(Symbol(),0,LWMA1,0,MODE_LWMA,PRICE_CLOSE,i+1); double curMa2=iMA(Symbol(),0,LWMA2,0,MODE_LWMA,PRICE_CLOSE,i); double prevMa2=iMA(Symbol(),0,LWMA2,0,MODE_LWMA,PRICE_CLOSE,i+1); double curMa3=iMA(Symbol(),0,LWMA3,0,MODE_LWMA,PRICE_CLOSE,i); double prevMa3=iMA(Symbol(),0,LWMA3,0,MODE_LWMA,PRICE_CLOSE,i+1); double curMa4=iMA(Symbol(),0,LWMA4,0,MODE_LWMA,PRICE_CLOSE,i); double prevMa4=iMA(Symbol(),0,LWMA4,0,MODE_LWMA,PRICE_CLOSE,i+1); double curMa5=iMA(Symbol(),0,LWMA5,0,MODE_LWMA,PRICE_CLOSE,i); double prevMa5=iMA(Symbol(),0,LWMA5,0,MODE_LWMA,PRICE_CLOSE,i+1); downma1[i]=EMPTY_VALUE; upma1[i]=EMPTY_VALUE; downma2[i]=EMPTY_VALUE; upma2[i]=EMPTY_VALUE; if(curMa1>prevMa1){ upma1[i]=curMa1; upma1[i+1]=prevMa1; } if(curMa1prevMa2){ upma2[i]=curMa2; upma2[i+1]=prevMa2; } if(curMa2prevMa3){ upma3[i]=curMa3; upma3[i+1]=prevMa3; } if(curMa3prevMa4){ upma4[i]=curMa4; upma4[i+1]=prevMa4; } if(curMa4prevMa5){ upma5[i]=curMa5; upma5[i+1]=prevMa5; } if(curMa5