//+------------------------------------------------------------------+ //| Sample_4.mq4 | //| Naguisa Unada | //| https://www.mql5.com/en/users/unadajapon/news | //+------------------------------------------------------------------+ #property copyright "Naguisa Unada" #property link "https://www.mql5.com/en/users/unadajapon/news" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot MA #property indicator_label1 "Moving Average 1" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- input parameters //--- indicator buffers double MA1_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,MA1_Buffer); //--- 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 i,limit; if(prev_calculated<0) return(-1); if(prev_calculated==0) limit=rates_total-100; else limit=rates_total-prev_calculated+1; if(NewBar()) { for(i=limit; i>=0; i--) MA1_Buffer[i]=CCFp(0,i); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ bool NewBar() { static datetime lastbar; datetime curbar=Time[0]; if(lastbar!=curbar) { lastbar=curbar; return (true); } else { return (false); } } //+------------------------------------------------------------------+ double CCFp(int index,int shift) { bool ShowOnlyPairOnChart=false; int MA_Method=3; int Price= 6; int Fast = 3; int Slow = 5; bool USD = 1; bool EUR = 1; bool GBP = 1; bool CHF = 1; bool JPY = 1; bool AUD = 1; bool CAD = 1; bool NZD = 1; color Color_USD = Green; color Color_EUR = DarkBlue; color Color_GBP = Red; color Color_CHF = Chocolate; color Color_JPY = Maroon; color Color_AUD = DarkOrange; color Color_CAD = Purple; color Color_NZD = Teal; int Line_Thickness=2; int All_Bars=100; int Last_Bars=100; double value=iCustom(Symbol(),Period(),"CCFp",ShowOnlyPairOnChart,MA_Method,Price,Fast,Slow,USD,EUR,GBP,CHF,JPY,AUD,CAD,NZD,Color_USD,Color_EUR, Color_GBP,Color_CHF,Color_JPY,Color_AUD,Color_CAD,Color_NZD,Line_Thickness,All_Bars,Last_Bars,index,shift); //double value = iCustom(NULL, PERIOD_CURRENT, "CCFp", index, shift); return value; } //+------------------------------------------------------------------+