Download MetaTrader 5
To add comments, please log in or register
Do you have a trading signal? Publish it in your blog as well!
pragma64 2016.09.10 09:20 
Hello, i have got an error in the line 24 :'SetIndexBuffer' - no one of the overloads can be applied to the function call   
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      ""
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//--- input parameters
input int      Input1;
input int      Input2;
double CBDR;
//| Custom indicator initialization function                         |
int init() 
return (0);}

//| Custom indicator iteration function                              |

 int OnCalculate (const int rates_total,      // size of input time series 
                 const int prev_calculated,  // bars handled in previous call 
                 const datetime& time[],     // Time 
                 const double& open[],       // Open 
                 const double& high[],       // High 
                 const double& low[],        // Low 
                 const double& close[],      // Close 
                 const long& tick_volume[],  // Tick Volume 
                 const long& volume[],       // Real Volume 
                 const int& spread[]         // Spread 
double val1;
//--- calculating the highest value on the input1 consecutive bars in the range
//--- from the input2 to the 23rd index inclusive on the current chart
   int val1_index=iHighest(NULL,0,MODE_HIGH,Input1,Input2);
   if(val1_index!=-1)  val1=High[val1_index];
   else PrintFormat("Error in call iHighest. Error code=%d",GetLastError());


    double val2;
//--- calculating the lowest value on the 10 consequtive bars in the range
//--- from the 10th to the 19th index inclusive on the current chart
   int val2_index=iLowest(NULL,0,MODE_LOW,Input1,Input2);
   if(val2_index!=-1) val2=Low[val2_index];
   else PrintFormat("Error in iLowest. Error code=%d",GetLastError());

CBDR=val1-val2 ; 

datetime time1=TimeCurrent();//aujourdhui a 5H DU MATIN
string obj_name="CBDR";
   long current_chart_id=ChartID();
//--- creating label object (it does not have time/price coordinates)
   ObjectCreate(current_chart_id,obj_name,OBJ_HLINE,time1,CBDR,  0, 0, 0);

honest_knave 2016.09.10 09:56  

A few things to think about.

Firstly, CBDR needs to be an array. You need to declare it as such:

double CBDR[];

 ... and access it as such (you will probably want to work on this bit - have a look here for some ideas about lookbacks)

CBDR[0]=val1-val2 ; 




Although some of this info is outdated, this link might be a good start point. HTH

To add comments, please log in or register