//+------------------------------------------------------------------+ //| Daily-Weekly Open.mq4 | //| djindyfx@sbcglobal.net | //| http://www.learncurrencytrading.com/fxforum/blogs/djindyfx/ | //+------------------------------------------------------------------+ #property copyright "djindyfx@sbcglobal.net" #property link "http://www.learncurrencytrading.com/fxforum/blogs/djindyfx/" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Aqua #property indicator_color2 Blue //---- buffers double dailyopen[]; double weeklyopen[]; double line; double d,w,p; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,STYLE_DOT,1); SetIndexBuffer(0,dailyopen); SetIndexStyle(1,DRAW_LINE,STYLE_DASHDOT,1); SetIndexBuffer(1,weeklyopen); string dopen, wopen; dopen = "Daily Open"; wopen = "Weekly Open"; IndicatorShortName(dopen); IndicatorShortName(wopen); SetIndexLabel(0,dopen); SetIndexLabel(1,wopen); SetIndexDrawBegin(0,1); SetIndexDrawBegin(1,1); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("Weekly Open"); ObjectDelete("Daily Open"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int limit, i; p=Period(); //---- if(counted_bars<0) return(-1); limit=(Bars-counted_bars)-1; // - Weekly Open Line Draw if(counted_bars==0) {//0 if (p>PERIOD_D1)return(-1); ObjectCreate("Weekly Open",OBJ_HLINE,0,0,0); }//0 for(i=limit; i>=0; i--) {//0 if(1==TimeDayOfWeek(Time[i]) && 1!=TimeDayOfWeek(Time[i+1])) {//1 w=Open[i]; ObjectMove("Weekly Open",0,Time[i],line); }//2 weeklyopen[i]=w; //Comment("Weekly Open ", weeklyopen[i]); }//0 // - Daily Open Line Draw if(counted_bars==0) {//0 if (p>PERIOD_H4)return(-1); ObjectCreate("Daily Open",OBJ_HLINE,0,0,0); }//0 for(i=limit; i>=0; i--) { if (TimeDay(Time[i]) !=TimeDay(Time[i+1])) {//3 d=Open[i]; ObjectMove("Daily Open",0,Time[i],line); }//3 //weeklyopen[i]=w; dailyopen[i]=d; /* Comment("Daily Open ", dailyopen[i],"\n", "Weekly Open ", weeklyopen[i]); */ } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains open prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: