#property copyright "XXX" #property link "" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 3 #property indicator_plots 3 //--- plot Label1 #property indicator_label1 "Label1" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot Label2 #property indicator_label2 "Label2" #property indicator_type2 DRAW_LINE #property indicator_color2 clrAqua #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- plot Label3 #property indicator_label3 "Label3" #property indicator_type3 DRAW_LINE #property indicator_color3 clrDarkOrange #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- input parameters input int input1=200; input int input2=4; //--- indicator buffers double Label1Buffer[]; double Label2Buffer[]; double Label3Buffer[]; //definition of a function: double f1(double &data[], etc..) { //misc.. } //end of function definition //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,Label1Buffer); SetIndexBuffer(1,Label2Buffer); SetIndexBuffer(2,Label3Buffer); //misc arrays //--- 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[]) { //--- if the size of price[] is too small if(rates_total<200) return(0); //check for enough bars: if(rates_total>200) { //start main calculations: double f1_data[]; ArrayResize(f1_data,200); //filling data array with 200 previous close prices: for (int i=0; i<200; i++) { f1_data[i]=Close[i]; } //calling f1 twice with different inputs: Label1Buffer[0]=f1_result1(...); Label2Buffer[0]=f1_result2(...); //doing all calculations here and then show result: Label3Buffer[0]=main_result; } //end of calculations //--- return value of prev_calculated for next call return(prev_calculated); } //+------------------------------------------------------------------+