//+------------------------------------------------------------------+ //| fibopiv monthly.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("MS1"); ObjectDelete("MS2"); ObjectDelete("MS3"); ObjectDelete("MR1"); ObjectDelete("MR2"); ObjectDelete("MR3"); ObjectDelete("MONTHLY PIVOT"); ObjectDelete("Monthly Support 1"); ObjectDelete("Monthly 2"); ObjectDelete("Monthly 3"); ObjectDelete("Monthly Pivot level"); ObjectDelete("Monthly Resistance 1"); ObjectDelete("Monthly Resistance 2"); ObjectDelete("Monthly Resistance 3"); Comment(" "); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- double rates[1][6],monthly_close,monthly_high,monthly_low; ArrayCopyRates(rates, Symbol(), PERIOD_MN1); if(DayOfWeek() == 1) { if(TimeDayOfWeek(iTime(Symbol(),PERIOD_MN1,1)) == 5) { monthly_close = rates[1][4]; monthly_high = rates[1][3]; monthly_low = rates[1][2]; } else { for(int d = 5;d>=0;d--) { if(TimeDayOfWeek(iTime(Symbol(),PERIOD_MN1,d)) == 5) { monthly_close = rates[d][4]; monthly_high = rates[d][3]; monthly_low = rates[d][2]; } } } } else { monthly_close = rates[1][4]; monthly_high = rates[1][3]; monthly_low = rates[1][2]; } //---- Calculate Pivots Comment("\nMonthly quotations:\nH ",monthly_high,"\nL ",monthly_low, "\nC ",monthly_close); double R = monthly_high - monthly_low;//range double mp = (monthly_high + monthly_low + monthly_close)/3;// Standard Pivot double mr3 = mp + (R * 1.000); double mr2 = mp + (R * 0.618); double mr1 = mp + (R * 0.382); double ms1 = mp - (R * 0.382); double ms2 = mp - (R * 0.618); double ms3 = mp - (R * 1.000); drawLine(mr3,"MR3", DarkGreen,0); drawLabel("Monthly Resistance 3",mr3,White); drawLine(mr2,"MR2", DarkGreen,0); drawLabel("Monthly Resistance 2",mr2,White); drawLine(mr1,"MR1", DarkGreen,0); drawLabel("Monthly Resistance 1",mr1,White); drawLine(mp,"MONTHLY PIVOT",White,1); drawLabel("Monthly Pivot ",mp,White); drawLine(ms1,"MS1",DarkSlateBlue,0); drawLabel("Monthly Support 1",ms1,White); drawLine(ms2,"MS2",DarkSlateBlue,0); drawLabel("Monthly Support 2",ms2,White); drawLine(ms3,"MS3",DarkSlateBlue,0); drawLabel("Monthly Support 3",ms3,White); //---- return(0); } //+------------------------------------------------------------------+ void drawLabel(string name,double lvl,color Color) { if(ObjectFind(name) != 0) { ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl); ObjectSetText(name, name, 8, "Lucida Handwriting", EMPTY); ObjectSet(name, OBJPROP_COLOR, Color); } else { ObjectMove(name, 0, Time[10], lvl); } } void drawLine(double lvl,string name, color Col,int type) { if(ObjectFind(name) != 0) { ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl); if(type == 1) ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); else ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); ObjectSet(name, OBJPROP_COLOR, Col); ObjectSet(name,OBJPROP_WIDTH,1); } else { ObjectDelete(name); ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl); if(type == 1) ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); else ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); ObjectSet(name, OBJPROP_COLOR, Col); ObjectSet(name,OBJPROP_WIDTH,1); } }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: