//+-------------------------------------------------------------------------------------------+ //| | //| PivotsMW.mq4 | //| | //+-------------------------------------------------------------------------------------------+ #property copyright "Domas4 and Traderathome - public domain code" #property link "email: traderathome@msn.com" /*--------------------------------------------------------------------------------------------+ PivotsMW: Both Monthy and Weekly pivots can be displayed with this indicator. It provides for color and line style selection of pivot lines. It provides for color, font size and font style selection of line labels, and the ability to position labels from the left chart border to right of the current candle. Zooming in/out on the chart is an activity that can distort the position of labels. With each data tic proper label positioning is automatically restored. Included is the ability to independently turn on/off the price displayed in line labels and in the right chart margin (right margin labels are possible when lines are full screen). Pivot lines can be calculated using either the "Daily" formula or the "Fibonacci" formula, which has two added levels. Included are MidPivot lines which can be turned on/off. The first item in the Indicator Window is the indicator "On/Off" switch (default=true). By turning the indicator display "Off", you do not have to remove the indicator from the chart list when not in use, and the indicator settings for the chart are preserved. ------------------------------------------------------------------------------------------------ PivotsMW_v2: My apologies to users for errant pivots in the initial release, and my gratitude to grant18265 for bringing this to my attention. They are corrected in this revision. "THANKS!" are owed to Domas4 for coding the line displays so they can be of one configuration prior to the Today session and of a different configuration for the Today session! Furthermore, Domas4 has re-coded the price labels so that they are now compatible with non-forex items! Set the input to "false" on charts for non-forex items such as Gold, Stocks, etc. PivotsMW_v3: The external input for labels font style was changed to allow the actual neme of a font style to be typed in. Thus, more style choices are now available to the user. Arial, Arial Bold and Verdana Bold are recommended, with font sizes 8 to 12. PivotsMW_v4: New code allows the MW pivot lines to be started at the current candle. New code also lets the lines be stopped at the current candle. This is to allow them to be matched with lines of the "PivotsD" indicator having the same new options. The external inputs section has been re-worked for improved clarity and consistency of terminology. PivotsMW_v5: New code from Domas4 lets you enter a time frame, above which the indicator will not display. This lets you switch to large TF charts to make assesments without having to turn the indy off to remove a congestion of pivot lines. The external inputs section is reworked. Most notably a "Pivot Line Star/Stopt Settings" section is added along with new code that allows lines to be started at the Day Separator. This establishes greater compatibility with the "PivotsD" indy. In addition, labels for Monthly and Weekly pivots now have separate shift inputs. If a Monthly line is so close to a Weekly line that their labels interfere, you can use different shift numbers to display the Monthy and Weekly labels. - Traderathome Robert added correction to comments for 5 digit pricing 10/25/2011 - Robert added additional fib levels Fixed possible issue for JPY digits value Reset default values to only show weekly pivots ---------------------------------------------------------------------------------------------*/ #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 CLR_NONE /*--------------------------------------------------------------------------------------------- Color Suggestions: White Chart Black Chart MainPivot_Color Blue C'27,63,171' Pivot_Resistances_Color Red Maroon Pivot_Supports_Color LimeGreen DarkGreen MidPivots_Color Olive C'85,85,0' LabelsColor MidnightBlue DarkGray ---------------------------------------------------------------------------------------------*/ extern bool Indicator_On = true; extern bool Use_For_Forex = true; extern string Exit_Period_Choices = "M1, M5, M15, M30, H1, H4, D1"; extern string Exit_If_Period_Greater_Than = "H1"; extern string _ = ""; extern string Part_1 = "Pivots & Formulas Settings:"; extern bool Show_Monthly_Pivots = false; extern bool Monthly_Use_Day_Formula = false; extern bool Show_Weekly_Pivots = true; extern bool Weekly_Use_Day_Formula = false; extern bool WeeklyUseOpenPrice = true; extern string __ = ""; extern string Part_2 = "Pivot Lines Start/Stop Settings:"; extern string note1 = "Start with fullscreen lines, enter '1'"; extern string note2 = "Start lines at Day Separator, enter '2'"; extern string note3 = "Start lines at current candle, enter '3'"; extern int StartLines = 1; extern bool StopLines_At_Current_Candle = true; extern string ___ = ""; extern string Part_3 = "Pivot Line Color & Selection Settings:"; extern color Central_Pivot_Color = Blue; extern color Resistance_Pivots_Color = Red; extern color Support_Pivots_Color = LimeGreen; extern bool Show_Monthly_MidPivots = false; extern bool Show_Weekly_MidPivots = false; extern color MidPivots_Color = Olive; extern string ____ = ""; extern string Part_4 = "Pivot Lines Dual Style Settings:"; extern string note4 = "Pivot lines thru *CurrentDay* can have"; extern string note5 = "different style than used for lines thru"; extern string note6 = "prior days & full screen, *PriorDaysFS*"; extern int CurrentDay_LineStyle_01234 = 2; extern int CurrentDay_SolidLineThickness = 1; extern int PriorDaysFS_LineStyle_01234 = 0; extern int PriorDaysFS_SolidLineThickness = 1; extern string note7 = "For FS lines single style, enter '1'"; extern string note8 = "For FS lines dual style, enter '2'"; extern int Line_Configuration_Number = 2; extern string _____ = ""; extern string Part_5 = "Pivot Labels Settings:"; extern color PivotLabels_Color = Yellow;//DarkGray extern string PivotLabels_FontStyle = "Arial"; extern int PivotLabels_Fontsize = 9; extern int Shift_MonthLabels_PerCent_Left = 88; extern int Shift_WeekLabels_PerCent_Left = 75; extern bool Show_Price_in_PivotLabels = true; extern bool Show_RightMargin_Prices = true; extern bool Subordinate_Labels = true; int fxDigits,CalcPeriod,shift,dow,S; double HiPrice,LoPrice,Range,ClosePrice,Pivot,R1,S1,R2,S2,R3,S3,R4,S4,R5,S5; // New fib pivots double FibPivot, OpenPivot; double R0, S0, R21, S21, R31, S31, R32, S32; double R41, S41, R42, S42, R43, S43, R44, S44; string Price; //+-------------------------------------------------------------------------------------------+ //| Indicator Initialization | //+---------------------------------------------------------------------------------------=---+ int init() { if(Use_For_Forex) { if (StringFind(Symbol(), "JPY") >= 0) {fxDigits = 2;} else {fxDigits = 4;} } return(0); } //+----------------------------------------------------------------------------------------=--+ //| Indicator De-initialization | //+-------------------------------------------------------------------------------------------+ int deinit() { int obj_total= ObjectsTotal(); for (int k= obj_total; k>=0; k--) { string name= ObjectName(k); if (StringSubstr(name,0,10)=="[PivotsMW]") {ObjectDelete(name);}} return(0); } //+-------------------------------------------------------------------------------------------+ //| Indicator Start | //+-------------------------------------------------------------------------------------------+ int start() { deinit(); if (Indicator_On == false){return(0);} //Exit if period is greater than ----------------------------------------------- int E; if(Exit_If_Period_Greater_Than== "M1") {E= 1;} if(Exit_If_Period_Greater_Than== "M5") {E= 5;} if(Exit_If_Period_Greater_Than== "M15") {E= 15;} if(Exit_If_Period_Greater_Than== "M30") {E= 30;} if(Exit_If_Period_Greater_Than== "H1") {E= 60;} if(Exit_If_Period_Greater_Than== "H4") {E= 240;} if(Exit_If_Period_Greater_Than== "D1") {E= 1440;} if(Period() > E) {deinit(); return(-1);} //Do Weekly Pivots-------------------------------------------------------------------------- if (Show_Weekly_Pivots) { string wpLineStr,wpStr,wp,ws1Str; string wS1LineStr,ws1,wr1Str,wR1LineStr,wr1; string ws2Str,wS2LineStr,ws2,wr2Str,wR2LineStr,wr2; string ws3Str,wS3LineStr,ws3,wr3Str,wR3LineStr,wr3; string ws4Str,wS4LineStr,ws4,wr4Str,wR4LineStr,wr4; string ws5Str,wS5LineStr,ws5,wr5Str,wR5LineStr,wr5; string wmrLineStr; S= 1; // New fib pivots string wS0LineStr,wR0LineStr,wS21LineStr,wR21LineStr; string wS31LineStr,wR31LineStr,wS32LineStr,wR32LineStr; string wS41LineStr,wR41LineStr,wS42LineStr,wR42LineStr; string wS43LineStr,wR43LineStr,wS44LineStr,wR44LineStr; if (Weekly_Use_Day_Formula) { wpLineStr = " WPV"; wS1LineStr = " WS1"; wR1LineStr = " WR1"; wS2LineStr = " WS2"; wR2LineStr = " WR2"; wS3LineStr = " WS3"; wR3LineStr = " WR3"; wmrLineStr = "Wm"; } else { wpLineStr = " WFPV"; wS0LineStr = " WFS0"; wR0LineStr = " WFR0"; wS1LineStr = " WFS1"; wR1LineStr = " WFR1"; wS2LineStr = " WFS2"; wR2LineStr = " WFR2"; wS21LineStr = " WFS21"; wR21LineStr = " WFR21"; wS3LineStr = " WFS3"; wR3LineStr = " WFR3"; wS31LineStr = " WFS31"; wR31LineStr = " WFR31"; wS32LineStr = " WFS32"; wR32LineStr = " WFR32"; wS4LineStr = " WFS4"; wR4LineStr = " WFR4"; wS41LineStr = " WFS41"; wR41LineStr = " WFR41"; wS42LineStr = " WFS42"; wR42LineStr = " WFR42"; wS43LineStr = " WFS43"; wR43LineStr = " WFR43"; wS44LineStr = " WFS44"; wR44LineStr = " WFR44"; wS5LineStr = " WFS5"; wR5LineStr = " WFR5"; wmrLineStr = "Wm"; } CalcPeriod = 10080; shift = iBarShift(NULL,CalcPeriod,Time[0])+ 1;//default=one period ago ClosePrice = NormalizeDouble(iClose(NULL,CalcPeriod,shift),4); HiPrice = NormalizeDouble (iHigh(NULL,CalcPeriod,shift),4); LoPrice = NormalizeDouble (iLow(NULL,CalcPeriod,shift),4); Range = HiPrice - LoPrice; Pivot = NormalizeDouble((HiPrice+LoPrice+ClosePrice)/3,4); OpenPivot = NormalizeDouble(iOpen(NULL, CalcPeriod, shift - 1), 4); if (WeeklyUseOpenPrice) FibPivot = OpenPivot; else FibPivot = Pivot; if (Weekly_Use_Day_Formula) { R1 = (2*Pivot)-LoPrice; S1 = (2*Pivot)-HiPrice; R2 = Pivot+(R1-S1); S2 = Pivot-(R1-S1); R3 = ( 2.0 * Pivot) + ( HiPrice - ( 2.0 * LoPrice ) ); S3 = ( 2.0 * Pivot) - ( ( 2.0 * HiPrice ) - LoPrice ); } else { // The ratios I use are: 0.236, 0.382, 0.618, 0.820, 1.0, // 1.236, 1.328, 1.618, 1.820, 2.00, 2.236 and 2.382 R0 = FibPivot + (Range * 0.236); S0 = FibPivot - (Range * 0.236); R1 = FibPivot + (Range * 0.382); S1 = FibPivot - (Range * 0.382); R2 = FibPivot + (Range * 0.618); S2 = FibPivot - (Range * 0.618); R21 = FibPivot + (Range * 0.820); S21 = FibPivot - (Range * 0.820); R3 = FibPivot + Range ; S3 = FibPivot - Range ; R31 = FibPivot + (Range * 1.236); S31 = FibPivot - (Range * 1.236); R32 = FibPivot + (Range * 1.328); S32 = FibPivot - (Range * 1.328); R4 = FibPivot + (Range * 1.618); S4 = FibPivot - (Range * 1.618); R41 = FibPivot + (Range * 1.820); S41 = FibPivot - (Range * 1.820); R42 = FibPivot + (Range * 2.0); S42 = FibPivot - (Range * 2.0); R43 = FibPivot + (Range * 2.236); S43 = FibPivot - (Range * 2.236); R44 = FibPivot + (Range * 2.382); S44 = FibPivot - (Range * 2.382); R5 = FibPivot + (Range * 2.618); S5 = FibPivot - (Range * 2.618); } drawLine("wR32", R32, Resistance_Pivots_Color); drawLabel( wR32LineStr,R32,PivotLabels_Color,S); drawLine("wR31", R31, Resistance_Pivots_Color); drawLabel( wR31LineStr,R31,PivotLabels_Color,S); drawLine("wR3", R3, Resistance_Pivots_Color); drawLabel( wR3LineStr,R3,PivotLabels_Color,S); drawLine("wR21", R21, Resistance_Pivots_Color); drawLabel(wR21LineStr,R21,PivotLabels_Color,S); drawLine("wR2", R2, Resistance_Pivots_Color); drawLabel(wR2LineStr,R2,PivotLabels_Color,S); drawLine("wR1", R1, Resistance_Pivots_Color); drawLabel(wR1LineStr,R1,PivotLabels_Color,S); drawLine("wR0", R0, Resistance_Pivots_Color); drawLabel(wR0LineStr,R0,PivotLabels_Color,S); drawLine("wPIVOT", Pivot, Central_Pivot_Color); drawLabel(wpLineStr, Pivot,PivotLabels_Color,S); drawLine("wS0", S0, Support_Pivots_Color); drawLabel(wS0LineStr,S0,PivotLabels_Color,S); drawLine("wS1", S1, Support_Pivots_Color); drawLabel(wS1LineStr,S1,PivotLabels_Color,S); drawLine("wS2", S2, Support_Pivots_Color); drawLabel(wS2LineStr,S2,PivotLabels_Color,S); drawLine("wS21", S21, Support_Pivots_Color); drawLabel(wS21LineStr,S21,PivotLabels_Color,S); drawLine("wS3", S3, Support_Pivots_Color); drawLabel(wS3LineStr ,S3,PivotLabels_Color,S); drawLine("wS31", S31, Support_Pivots_Color); drawLabel(wS31LineStr ,S31,PivotLabels_Color,S); drawLine("wS32", S32, Support_Pivots_Color); drawLabel(wS32LineStr ,S32,PivotLabels_Color,S); if (Weekly_Use_Day_Formula==false){ drawLine("wR5", R5, Resistance_Pivots_Color); drawLabel( wR5LineStr,R5,PivotLabels_Color,S); drawLine("wR44", R44, Resistance_Pivots_Color); drawLabel(wR44LineStr,R44,PivotLabels_Color,S); drawLine("wR43", R43, Resistance_Pivots_Color); drawLabel(wR43LineStr,R43,PivotLabels_Color,S); drawLine("wR42", R42, Resistance_Pivots_Color); drawLabel(wR42LineStr,R42,PivotLabels_Color,S); drawLine("wR41", R41, Resistance_Pivots_Color); drawLabel(wR41LineStr,R41,PivotLabels_Color,S); drawLine("wR4", R4, Resistance_Pivots_Color); drawLabel(wR4LineStr,R4,PivotLabels_Color,S); drawLine("wS4", S4, Support_Pivots_Color); drawLabel(wS4LineStr,S4,PivotLabels_Color,S); drawLine("wS41", S41, Support_Pivots_Color); drawLabel(wS41LineStr,S41,PivotLabels_Color,S); drawLine("wS42", S42, Support_Pivots_Color); drawLabel(wS42LineStr,S42,PivotLabels_Color,S); drawLine("wS43", S43, Support_Pivots_Color); drawLabel(wS43LineStr,S43,PivotLabels_Color,S); drawLine("wS44", S44, Support_Pivots_Color); drawLabel(wS44LineStr,S44,PivotLabels_Color,S); drawLine("wS5", S5, Support_Pivots_Color); drawLabel(wS5LineStr ,S5,PivotLabels_Color,S);} if(Show_Weekly_MidPivots){ drawLine("wMR3", (R2+R3)/2, MidPivots_Color); drawLabel(wmrLineStr+"R3",(R2+R3)/2,PivotLabels_Color,S); drawLine("wMR2", (R1+R2)/2, MidPivots_Color); drawLabel(wmrLineStr+"R2",(R1+R2)/2,PivotLabels_Color,S); drawLine("wMR1", (Pivot+R1)/2, MidPivots_Color); drawLabel(wmrLineStr+"R1",(Pivot+R1)/2,PivotLabels_Color,S); drawLine("wMS1", (Pivot+S1)/2, MidPivots_Color); drawLabel(wmrLineStr+"S1",(Pivot+S1)/2,PivotLabels_Color,S); drawLine("wMS2", (S1+S2)/2, MidPivots_Color); drawLabel(wmrLineStr+"S2",(S1+S2)/2,PivotLabels_Color,S); drawLine("wMS3", (S2+S3)/2, MidPivots_Color); drawLabel(wmrLineStr+"S3",(S2+S3)/2,PivotLabels_Color,S);} if (Weekly_Use_Day_Formula==false){ drawLine("wMR5", (R4+R5)/2, MidPivots_Color); drawLabel(wmrLineStr+"R5",(R4+R5)/2,PivotLabels_Color,S); drawLine("wMR4", (R3+R4)/2, MidPivots_Color); drawLabel(wmrLineStr+"R4",(R3+R4)/2,PivotLabels_Color,S); drawLine("wMS4", (S3+S4)/2, MidPivots_Color); drawLabel(wmrLineStr+"S4",(S3+S4)/2,PivotLabels_Color,S); drawLine("wMS5", (S4+S5)/2, MidPivots_Color); drawLabel(wmrLineStr+"S5",(S4+S5)/2,PivotLabels_Color,S);} } //Do Monthly Pivots------------------------------------------------------------------------- if (Show_Monthly_Pivots) { string mpLineStr,mpStr,mp; string ms1Str,mS1LineStr,ms1,mr1Str,mR1LineStr,mr1; string ms2Str,mS2LineStr,ms2,mr2Str,mR2LineStr,mr2; string ms3Str,mS3LineStr,ms3,mr3Str,mR3LineStr,mr3; string ms4Str,mS4LineStr,ms4,mr4Str,mR4LineStr,mr4; string ms5Str,mS5LineStr,ms5,mr5Str,mR5LineStr,mr5; string mmrLineStr; S= 2; if (Monthly_Use_Day_Formula) { mpLineStr = " MPV"; mS1LineStr = " MS1"; mR1LineStr = " MR1"; mS2LineStr = " MS2"; mR2LineStr = " MR2"; mS3LineStr = " MS3"; mR3LineStr = " MR3"; mmrLineStr = " Mm"; } else { mpLineStr = " MFPV"; mS1LineStr = " MFS1"; mR1LineStr = " MFR1"; mS2LineStr = " MFS2"; mR2LineStr = " MFR2"; mS3LineStr = " MFS3"; mR3LineStr = " MFR3"; mS4LineStr = " MFS4"; mR4LineStr = " MFR4"; mS5LineStr = " MFS5"; mR5LineStr = " MFR5"; mmrLineStr = " Mm"; } CalcPeriod = 43200; shift = iBarShift(NULL,CalcPeriod,Time[0])+ 1;//default=one period ago ClosePrice = NormalizeDouble(iClose(NULL,CalcPeriod,shift),4); HiPrice = NormalizeDouble (iHigh(NULL,CalcPeriod,shift),4); LoPrice = NormalizeDouble (iLow(NULL,CalcPeriod,shift),4); Range = HiPrice - LoPrice; Pivot = NormalizeDouble((HiPrice+LoPrice+ClosePrice)/3,4); if (Monthly_Use_Day_Formula) { R1 = (2*Pivot)-LoPrice; S1 = (2*Pivot)-HiPrice; R2 = Pivot+(R1-S1); S2 = Pivot-(R1-S1); R3 = ( 2.0 * Pivot) + ( HiPrice - ( 2.0 * LoPrice ) ); S3 = ( 2.0 * Pivot) - ( ( 2.0 * HiPrice ) - LoPrice ); } else { R1 = Pivot + (Range * 0.382); S1 = Pivot - (Range * 0.382); R2 = Pivot + (Range * 0.618); S2 = Pivot - (Range * 0.618); R3 = Pivot + Range ; S3 = Pivot - Range ; R4 = Pivot + (Range * 1.618); S4 = Pivot - (Range * 1.618); R5 = Pivot + (Range * 2.618); S5 = Pivot - (Range * 2.618); } drawLine("mR3", R3, Resistance_Pivots_Color); drawLabel(mR3LineStr,R3,PivotLabels_Color,S); drawLine("mR2", R2, Resistance_Pivots_Color); drawLabel(mR2LineStr,R2,PivotLabels_Color,S); drawLine("mR1", R1, Resistance_Pivots_Color); drawLabel(mR1LineStr,R1,PivotLabels_Color,S); drawLine("mPIVOT", Pivot, Central_Pivot_Color); drawLabel(mpLineStr, Pivot,PivotLabels_Color,S); drawLine("mS1", S1, Support_Pivots_Color); drawLabel(mS1LineStr,S1,PivotLabels_Color,S); drawLine("mS2", S2, Support_Pivots_Color); drawLabel(mS2LineStr,S2,PivotLabels_Color,S); drawLine("mS3", S3, Support_Pivots_Color); drawLabel(mS3LineStr ,S3,PivotLabels_Color,S); if (Monthly_Use_Day_Formula==false){ drawLine("mR5", R5, Resistance_Pivots_Color); drawLabel(mR5LineStr,R5,PivotLabels_Color,S); drawLine("mR4", R4, Resistance_Pivots_Color); drawLabel(mR4LineStr,R4,PivotLabels_Color,S); drawLine("mS4", S4, Support_Pivots_Color); drawLabel(mS4LineStr,S4,PivotLabels_Color,S); drawLine("mS5", S5, Support_Pivots_Color); drawLabel(mS5LineStr ,S5,PivotLabels_Color,S);} if(Show_Monthly_MidPivots){ drawLine("mMR3", (R2+R3)/2, MidPivots_Color); drawLabel(mmrLineStr+"R3",(R2+R3)/2,PivotLabels_Color,S); drawLine("mMR2", (R1+R2)/2, MidPivots_Color); drawLabel(mmrLineStr+"R2",(R1+R2)/2,PivotLabels_Color,S); drawLine("mMR1", (Pivot+R1)/2, MidPivots_Color); drawLabel(mmrLineStr+"R1",(Pivot+R1)/2,PivotLabels_Color,S); drawLine("mMS1", (Pivot+S1)/2, MidPivots_Color); drawLabel(mmrLineStr+"S1",(Pivot+S1)/2,PivotLabels_Color,S); drawLine("mMS2", (S1+S2)/2, MidPivots_Color); drawLabel(mmrLineStr+"S2",(S1+S2)/2,PivotLabels_Color,S); drawLine("mMS3", (S2+S3)/2, MidPivots_Color); drawLabel(mmrLineStr+"S3",(S2+S3)/2,PivotLabels_Color,S);} if (Monthly_Use_Day_Formula==false){ drawLine("mMR5", (R4+R5)/2, MidPivots_Color); drawLabel(mmrLineStr+"R5",(R4+R5)/2,PivotLabels_Color,S); drawLine("mMR4", (R3+R4)/2, MidPivots_Color); drawLabel(mmrLineStr+"R4",(R3+R4)/2,PivotLabels_Color,S); drawLine("mMS4", (S3+S4)/2, MidPivots_Color); drawLabel(mmrLineStr+"S4",(S3+S4)/2,PivotLabels_Color,S); drawLine("mMS5", (S4+S5)/2, MidPivots_Color); drawLabel(mmrLineStr+"S5",(S4+S5)/2,PivotLabels_Color,S);} } return(0); } //+-------------------------------------------------------------------------------------------+ //| drawLabel sub-routine to name and draw labels for pivot lines | //+-------------------------------------------------------------------------------------------+ void drawLabel(string text, double level, color Color, int kind) { //Define name and content of the pivot line labels string plabel = "[PivotsMW] " + text + " Label"; if (Use_For_Forex) {Price=DoubleToStr(level, fxDigits);} else {Price=DoubleToStr(level, Digits);} if (Show_Price_in_PivotLabels && StrToInteger(text)==0) {text = text + " " + Price;} //Determine start position for labels & initiate needed variables int S2; if (kind == 1){S2= Shift_WeekLabels_PerCent_Left;} else {S2= Shift_MonthLabels_PerCent_Left;} if (S2 < 0) {S2 =0;} if (S2 > 100) {S2 =100;} int L, LabelsShift = (WindowFirstVisibleBar()*S2)/100; //Initiate needed time variables int time, startday = Time[1]; if (Time[0] > iTime(NULL, PERIOD_D1, 0)){startday = iTime(NULL, PERIOD_D1, 0);} //Set tabs required for desired label text alignment string tab; if (StartLines==1) L= 1; if (StartLines==2 && startday<=iTime(NULL,0,WindowFirstVisibleBar()) ) L= 1; if (L==1){ time= Time[LabelsShift]; if (Show_Price_in_PivotLabels){tab=" ";} //33 else {tab = " ";}} //17 else { if (Show_Price_in_PivotLabels){tab=" ";} //30 else {tab = " ";} //14 if (StartLines==2){time= startday;} else {time= Time[0];}} //Draw labels if (ObjectFind(plabel) != 0){ ObjectCreate(plabel, OBJ_TEXT, 0, time, level); ObjectSetText(plabel, tab+text, PivotLabels_Fontsize, PivotLabels_FontStyle, Color); ObjectSet(plabel, OBJPROP_BACK, false); if (Subordinate_Labels) {ObjectSet(plabel, OBJPROP_BACK, true);}} else {ObjectMove(plabel, 0, time, level);} } //+-------------------------------------------------------------------------------------------+ //| drawLine sub-routine to name and draw pivot lines | //+-------------------------------------------------------------------------------------------+ void drawLine(string text, double level, color Color) { //Define line labels string pline1= "[PivotsMW] " + text + " Line historic";//Lines historic string pline2= "[PivotsMW] " + text + " Line today";//Lines today zone string pline3= "[PivotsMW] " + text + " Line full screen";//Lines fullscreen Y=1,F=true and HLINE //Define line configuration variables int a = PriorDaysFS_LineStyle_01234; int b = PriorDaysFS_SolidLineThickness; int c =1; if (a==0)c=b; int u = CurrentDay_LineStyle_01234; int v = CurrentDay_SolidLineThickness; int w =1; if (u==0)w=v; int Y,Z= OBJ_TREND, F= true; //F=true=extend line as ray line int startline1, stopline1, startline2, stopline2, startline3, stopline3; //Define needed time variables int startline, startday = Time[1]; if (Time[0] > iTime(NULL, PERIOD_D1, 0)){startday = iTime(NULL, PERIOD_D1, 0);} //Order variables as needed to create/move lines if (StartLines==1) { if (Line_Configuration_Number==1) {{Y=1; F= true;} if (Show_RightMargin_Prices) {Z=OBJ_HLINE;}} if(Line_Configuration_Number==2) {Y=0; Z= OBJ_TREND; F=true;}} else {if (StartLines==2) {Y= 2; Z= OBJ_TREND; F= true; startline= startday;} else {if (StartLines==3) {Y= 2; Z= OBJ_TREND; F= true; startline= Time[1];} }} if (StopLines_At_Current_Candle && StartLines != 3) {Z= OBJ_TREND; F= false;} //Draw lines if(Y==0){ if(ObjectFind(pline1) != 0){ ObjectCreate(pline1, Z, 0, iTime(NULL, PERIOD_D1, 0), level, WindowFirstVisibleBar(), level); ObjectSet(pline1, OBJPROP_STYLE, a); ObjectSet(pline1, OBJPROP_WIDTH, c); ObjectSet(pline1, OBJPROP_COLOR, Color); ObjectSet(pline1, OBJPROP_BACK, true);} if(ObjectFind(pline2) != 0){ ObjectCreate(pline2, Z, 0, startday, level, Time[0], level); ObjectSet(pline2, OBJPROP_STYLE, u); ObjectSet(pline2, OBJPROP_WIDTH, v); ObjectSet(pline2, OBJPROP_COLOR, Color); ObjectSet(pline2, OBJPROP_BACK, true); ObjectSet(pline2, OBJPROP_RAY, F);} } else {if(Y==1){ if(ObjectFind(pline3) != 0){ ObjectCreate(pline3, Z, 0, WindowFirstVisibleBar(), level, Time[0], level); ObjectSet(pline3, OBJPROP_STYLE, a); ObjectSet(pline3, OBJPROP_WIDTH, c); ObjectSet(pline3, OBJPROP_COLOR, Color); ObjectSet(pline3, OBJPROP_BACK, true); ObjectSet(pline3, OBJPROP_RAY, F);}} else {if(Y==2){ if(ObjectFind(pline2) != 0){ ObjectCreate(pline2, Z, 0, startline, level, Time[0], level); ObjectSet(pline2, OBJPROP_STYLE, u); ObjectSet(pline2, OBJPROP_WIDTH, v); ObjectSet(pline2, OBJPROP_COLOR, Color); ObjectSet(pline2, OBJPROP_BACK, true); ObjectSet(pline2, OBJPROP_RAY, F);}} //Move lines else{ if(Y==0){ ObjectMove (pline1, 0, iTime(NULL, PERIOD_D1, 0),level); ObjectMove (pline1, 1, WindowFirstVisibleBar(), level); ObjectMove (pline2, 0, startday,level); ObjectMove (pline2, 1, Time[0], level);} else {if(Y==1){ ObjectMove (pline3, 0, WindowFirstVisibleBar(),level); ObjectMove (pline3, 1, Time[0], level);} else {if(Y==2){ ObjectMove (pline2, 0, startline,level); ObjectMove (pline2, 1, Time[0], level);}} }}}} } //+-------------------------------------------------------------------------------------------+ //| End of Program | //+-------------------------------------------------------------------------------------------+