iClose(...)
Thanks, but it's just the beginning.
I think there is a work to select the right Close[] with Time[]
I think there is a work to select the right Close[] with Time[]
tintin92:
Thanks, but it's just the beginning.
I think there is a work to select the right Close[] with Time[]
What have you tried ?
Thanks, but it's just the beginning.
I think there is a work to select the right Close[] with Time[]
Tested with period of time 5 minutes and 1 mins:
Surely improvable.
//+------------------------------------------------------------------+ //| idClose.mq4 | //| Copyright 2014, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- buffers double Close_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Close_Buffer); SetIndexLabel(0,"Close"); //--- 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[]) { //--- datetime DateScan,DateWeek; int iWeek; int limit=(Bars-IndicatorCounted())-1; int limitWeek=iBars(NULL,PERIOD_M5)-1; for(int i=limit; i>=0; i--) { DateScan=Time[i]; for(iWeek=limitWeek; iWeek>=0; iWeek--) { DateWeek=iTime(NULL,PERIOD_M5,iWeek); if(DateWeek>DateScan) { iWeek++; iWeek++; break; } } if(iWeek<0) {Close_Buffer[i]=iClose(NULL,PERIOD_M5,1);} else {Close_Buffer[i]=iClose(NULL,PERIOD_M5,iWeek);} } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| idClose.mq4 | //| Copyright 2014, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Yellow //---- buffers double Close_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Close_Buffer); SetIndexLabel(0,"Close"); //--- 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[]) { //--- datetime DateScan,DateWeek; int iWeek; int limit=(Bars-IndicatorCounted())-1; int limitWeek=iBars(NULL,PERIOD_W1)-1; for(int i=limit; i>=0; i--) { DateScan=Time[i]; for(iWeek=limitWeek; iWeek>=0; iWeek--) { DateWeek=iTime(NULL,PERIOD_W1,iWeek); if(DateWeek>DateScan) { iWeek++; iWeek++; break; } } if(iWeek<0) {Close_Buffer[i]=iClose(NULL,PERIOD_W1,1);} else {Close_Buffer[i]=iClose(NULL,PERIOD_W1,iWeek);} } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
ok bro, thanks...

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
Hello,
How to display, with a indicator, the Weekly Close, in a Daily or H4 graph ?
Any helps welcome.
Regards,