iharter:
Ok, what have you tried ?
Hi
I am inciting and would like to create a basic indicator. to draw a line in average prices ((open-close / 2) + open)
grateful
Hi,
Maybe this code can get you up and running?
//+------------------------------------------------------------------+ //| average prices.mq5 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_width1 1 double indicator_buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,indicator_buffer,INDICATOR_DATA); //--- 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(rates_total<1) return 0; int limit; if(prev_calculated==0) { limit=0; ArrayInitialize(indicator_buffer,EMPTY_VALUE); } else limit=rates_total-1; for(int i=limit;i<rates_total;i++) indicator_buffer[i]=(open[i]-close[i])/2+open[i]; //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
I am inciting and would like to create a basic indicator. to draw a line in average prices ((open-close / 2) + open)
grateful