#property copyright "Copyright © 2007, FX Instructor, LLC" #property link "http://www.fxinstructor.com" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 Black #property indicator_color2 Black #property indicator_color3 Black #property indicator_color4 Black #property indicator_color5 Black #property indicator_color6 Black #property indicator_color7 Black extern int maxWeeks = 3; extern bool weeklyNotDaily = FALSE; extern bool showPivotLines = TRUE; extern bool showPivotLabels = TRUE; extern bool showPivotIcons = FALSE; extern int pivotThickness = 0; extern int pivotFontSize = 8; extern string pivotFont = "Arial"; extern color R3Color = AntiqueWhite; extern color R2Color = OldLace; extern color R1Color = White; extern color PColor = CornflowerBlue; extern color S1Color = Yellow; extern color S2Color = Gold; extern color S3Color = Orange; double g_ibuf_140[]; double g_ibuf_144[]; double g_ibuf_148[]; double g_ibuf_152[]; double g_ibuf_156[]; double g_ibuf_160[]; double g_ibuf_164[]; double gd_168; double gd_176; double gd_184; double gd_192; double gd_200; double gd_208; double gd_216; int gi_256 = 0; int g_digits_260; int init() { string ls_0; int l_style_8; Print("###########################################################################"); Print(" Questions? Email us at: info@fxinstructor.com"); Print(" http://www.fxinstructor.com"); Print(" ©2007, FX Instructor, LLC"); Print(" FXI Pivots v1.0.3 (2007-06-12)"); Print("###########################################################################"); g_digits_260 = MarketInfo(Symbol(), MODE_DIGITS); IndicatorDigits(g_digits_260); if (weeklyNotDaily) { l_style_8 = 2; ls_0 = "Week"; IndicatorShortName("FXI Weekly Pivots"); } else { l_style_8 = 0; ls_0 = "Day"; IndicatorShortName("FXI Daily Pivots"); } if (showPivotLines) { SetIndexBuffer(0, g_ibuf_148); SetIndexLabel(0, "R3 " + ls_0); SetIndexStyle(0, DRAW_LINE, l_style_8, pivotThickness, R3Color); SetIndexArrow(0, 160); SetIndexBuffer(1, g_ibuf_144); SetIndexLabel(1, "R2 " + ls_0); SetIndexStyle(1, DRAW_LINE, l_style_8, pivotThickness, R2Color); SetIndexArrow(1, 160); SetIndexBuffer(2, g_ibuf_140); SetIndexLabel(2, "R1 " + ls_0); SetIndexStyle(2, DRAW_LINE, l_style_8, pivotThickness, R1Color); SetIndexArrow(2, 160); SetIndexBuffer(3, g_ibuf_152); SetIndexLabel(3, "P " + ls_0); SetIndexStyle(3, DRAW_LINE, l_style_8, pivotThickness, PColor); SetIndexArrow(3, 160); SetIndexBuffer(4, g_ibuf_156); SetIndexLabel(4, "S1 " + ls_0); SetIndexStyle(4, DRAW_LINE, l_style_8, pivotThickness, S1Color); SetIndexArrow(4, 160); SetIndexBuffer(5, g_ibuf_160); SetIndexLabel(5, "S2 " + ls_0); SetIndexStyle(5, DRAW_LINE, l_style_8, pivotThickness, S2Color); SetIndexArrow(5, 160); SetIndexBuffer(6, g_ibuf_164); SetIndexLabel(6, "S3 " + ls_0); SetIndexStyle(6, DRAW_LINE, l_style_8, pivotThickness, S3Color); SetIndexArrow(6, 160); } return (0); } int deinit() { int li_0; if (weeklyNotDaily) li_0 = maxWeeks; else li_0 = 5 * maxWeeks; for (int li_4 = 1; li_4 <= li_0; li_4++) clearBars(li_4); Print("###########################################################################"); Print(" Questions? Email us at: info@fxinstructor.com"); Print(" Please visit our website: http://www.fxinstructor.com"); Print(" Thank you for using FXI Pivots!"); Print("###########################################################################"); return (0); } int start() { int li_0; int l_ind_counted_4 = IndicatorCounted(); if (weeklyNotDaily) li_0 = maxWeeks; else li_0 = 5 * maxWeeks; for (int li_8 = li_0; li_8 > 0; li_8--) doPivots(li_8); return (0); } void doPivots(int ai_0) { int l_timeframe_4; int l_datetime_8; if (weeklyNotDaily) l_timeframe_4 = 10080; else { l_timeframe_4 = 1440; l_datetime_8 = iTime(NULL, l_timeframe_4, ai_0); } if (!(!weeklyNotDaily) || !(TimeDayOfWeek(l_datetime_8) < 1 || TimeDayOfWeek(l_datetime_8) > 5)) { gd_168 = getP(ai_0, l_timeframe_4); gd_176 = getR1(ai_0, l_timeframe_4); gd_184 = getR2(ai_0, l_timeframe_4); gd_192 = getR3(ai_0, l_timeframe_4); gd_200 = getS1(ai_0, l_timeframe_4); gd_208 = getS2(ai_0, l_timeframe_4); gd_216 = getS3(ai_0, l_timeframe_4); if (showPivotLabels) drawPivotLabels(ai_0, l_timeframe_4); if (showPivotIcons) drawPivotIcons(ai_0, l_timeframe_4); } if (showPivotLines) drawPivotLines(ai_0, l_timeframe_4); } double getP(int ai_0, int a_timeframe_4) { double l_ihigh_8 = iHigh(Symbol(), a_timeframe_4, ai_0); double l_ilow_16 = iLow(Symbol(), a_timeframe_4, ai_0); double l_iclose_24 = iClose(Symbol(), a_timeframe_4, ai_0); double ld_ret_32 = (l_ihigh_8 + l_ilow_16 + l_iclose_24) / 3.0; return (ld_ret_32); } double getS1(int ai_0, int a_timeframe_4) { double l_ihigh_8 = iHigh(Symbol(), a_timeframe_4, ai_0); double ld_16 = gd_168; double ld_ret_24 = 2.0 * ld_16 - l_ihigh_8; return (ld_ret_24); } double getR1(int ai_0, int a_timeframe_4) { double l_ilow_8 = iLow(Symbol(), a_timeframe_4, ai_0); double ld_16 = gd_168; double ld_ret_24 = 2.0 * ld_16 - l_ilow_8; return (ld_ret_24); } double getS2(int ai_0, int a_timeframe_4) { double l_ihigh_8 = iHigh(Symbol(), a_timeframe_4, ai_0); double l_ilow_16 = iLow(Symbol(), a_timeframe_4, ai_0); double ld_24 = gd_168; double ld_ret_32 = ld_24 - (l_ihigh_8 - l_ilow_16); return (ld_ret_32); } double getR2(int ai_0, int a_timeframe_4) { double l_ihigh_8 = iHigh(Symbol(), a_timeframe_4, ai_0); double l_ilow_16 = iLow(Symbol(), a_timeframe_4, ai_0); double ld_24 = gd_168; double ld_ret_32 = ld_24 + (l_ihigh_8 - l_ilow_16); return (ld_ret_32); } double getS3(int ai_0, int a_timeframe_4) { double l_ihigh_8 = iHigh(Symbol(), a_timeframe_4, ai_0); double l_ilow_16 = iLow(Symbol(), a_timeframe_4, ai_0); double ld_24 = gd_168; double ld_ret_32 = l_ilow_16 - 2.0 * (l_ihigh_8 - ld_24); return (ld_ret_32); } double getR3(int ai_0, int a_timeframe_4) { double l_ihigh_8 = iHigh(Symbol(), a_timeframe_4, ai_0); double l_ilow_16 = iLow(Symbol(), a_timeframe_4, ai_0); double ld_24 = gd_168; double ld_ret_32 = l_ihigh_8 + 2.0 * (ld_24 - l_ilow_16); return (ld_ret_32); } void drawPivotIcons(int ai_0, int a_timeframe_4) { string ls_12; int l_datetime_8 = iTime(Symbol(), a_timeframe_4, ai_0 - 1); if (weeklyNotDaily) ls_12 = "Week"; else ls_12 = "Day"; if (ObjectFind("R1 " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("R1 " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_176 + Point * gi_256); ObjectSet("R1 " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 140); ObjectSet("R1 " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("R1 " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, R1Color); } else { ObjectSet("R1 " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("R1 " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_176 + Point * gi_256); } if (ObjectFind("R2 " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("R2 " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_184 + Point * gi_256); ObjectSet("R2 " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 141); ObjectSet("R2 " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("R2 " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, R2Color); } else { ObjectSet("R2 " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("R2 " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_184 + Point * gi_256); } if (ObjectFind("R3 " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("R3 " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_192 + Point * gi_256); ObjectSet("R3 " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 142); ObjectSet("R3 " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("R3 " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, R3Color); } else { ObjectSet("R3 " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("R3 " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_192 + Point * gi_256); } if (ObjectFind("P " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("P " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_168 + Point * gi_256); ObjectSet("P " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 164); ObjectSet("P " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("P " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, PColor); } else { ObjectSet("P " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("P " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_168 + Point * gi_256); } if (ObjectFind("S1 " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("S1 " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_200 + Point * gi_256); ObjectSet("S1 " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 129); ObjectSet("S1 " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("S1 " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, S1Color); } else { ObjectSet("S1 " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("S1 " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_200 + Point * gi_256); } if (ObjectFind("S2 " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("S2 " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_208 + Point * gi_256); ObjectSet("S2 " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 130); ObjectSet("S2 " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("S2 " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, S2Color); } else { ObjectSet("S2 " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("S2 " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_208 + Point * gi_256); } if (ObjectFind("S3 " + ls_12 + " Icon " + ai_0) == -1) { ObjectCreate("S3 " + ls_12 + " Icon " + ai_0, OBJ_ARROW, 0, l_datetime_8, gd_216 + Point * gi_256); ObjectSet("S3 " + ls_12 + " Icon " + ai_0, OBJPROP_ARROWCODE, 131); ObjectSet("S3 " + ls_12 + " Icon " + ai_0, OBJPROP_WIDTH, pivotThickness + 1); ObjectSet("S3 " + ls_12 + " Icon " + ai_0, OBJPROP_COLOR, S3Color); return; } ObjectSet("S3 " + ls_12 + " Icon " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("S3 " + ls_12 + " Icon " + ai_0, OBJPROP_PRICE1, gd_216 + Point * gi_256); } void drawPivotLines(int ai_0, int a_timeframe_4) { int l_shift_8 = iBarShift(Symbol(), 0, iTime(Symbol(), a_timeframe_4, ai_0 - 1)); int l_shift_12 = iBarShift(Symbol(), 0, iTime(Symbol(), a_timeframe_4, ai_0 - 2)); if (ai_0 == 1) l_shift_12 = 0; for (int li_16 = l_shift_8; li_16 >= l_shift_12; li_16--) { g_ibuf_152[li_16] = gd_168; g_ibuf_140[li_16] = gd_176; g_ibuf_144[li_16] = gd_184; g_ibuf_148[li_16] = gd_192; g_ibuf_156[li_16] = gd_200; g_ibuf_160[li_16] = gd_208; g_ibuf_164[li_16] = gd_216; } } void drawPivotLabels(int ai_0, int a_timeframe_4) { string ls_12; int l_datetime_8 = iTime(Symbol(), a_timeframe_4, ai_0 - 1); if (weeklyNotDaily) ls_12 = "Week"; else ls_12 = "Day"; if (ObjectFind("R1 " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("R1 " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_176 + Point * gi_256); ObjectSet("R1 " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("R1 " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, R1Color); } else { ObjectSet("R1 " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("R1 " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_176 + Point * gi_256); } ObjectSetText("R1 " + ls_12 + " Label " + ai_0, "R1 " + ls_12 + ": " + DoubleToStr(gd_176, g_digits_260), pivotFontSize, pivotFont, R1Color); if (ObjectFind("R2 " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("R2 " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_184 + Point * gi_256); ObjectSet("R2 " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("R2 " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, R2Color); } else { ObjectSet("R2 " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("R2 " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_184 + Point * gi_256); } ObjectSetText("R2 " + ls_12 + " Label " + ai_0, "R2 " + ls_12 + ": " + DoubleToStr(gd_184, g_digits_260), pivotFontSize, pivotFont, R2Color); if (ObjectFind("R3 " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("R3 " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_192 + Point * gi_256); ObjectSet("R3 " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("R3 " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, R3Color); } else { ObjectSet("R3 " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("R3 " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_192 + Point * gi_256); } ObjectSetText("R3 " + ls_12 + " Label " + ai_0, "R3 " + ls_12 + ": " + DoubleToStr(gd_192, g_digits_260), pivotFontSize, pivotFont, R3Color); if (ObjectFind("P " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("P " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_168 + Point * gi_256); ObjectSet("P " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("P " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, PColor); } else { ObjectSet("P " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("P " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_168 + Point * gi_256); } ObjectSetText("P " + ls_12 + " Label " + ai_0, "P " + ls_12 + ": " + DoubleToStr(gd_168, g_digits_260), pivotFontSize, pivotFont, PColor); if (ObjectFind("S1 " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("S1 " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_200 + Point * gi_256); ObjectSet("S1 " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("S1 " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, S1Color); } else { ObjectSet("S1 " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("S1 " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_200 + Point * gi_256); } ObjectSetText("S1 " + ls_12 + " Label " + ai_0, "S1 " + ls_12 + ": " + DoubleToStr(gd_200, g_digits_260), pivotFontSize, pivotFont, S1Color); if (ObjectFind("S2 " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("S2 " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_208 + Point * gi_256); ObjectSet("S2 " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("S2 " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, S2Color); } else { ObjectSet("S2 " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("S2 " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_208 + Point * gi_256); } ObjectSetText("S2 " + ls_12 + " Label " + ai_0, "S2 " + ls_12 + ": " + DoubleToStr(gd_208, g_digits_260), pivotFontSize, pivotFont, S2Color); if (ObjectFind("S3 " + ls_12 + " Label " + ai_0) == -1) { ObjectCreate("S3 " + ls_12 + " Label " + ai_0, OBJ_TEXT, 0, l_datetime_8, gd_216 + Point * gi_256); ObjectSet("S3 " + ls_12 + " Label " + ai_0, OBJPROP_WIDTH, pivotThickness); ObjectSet("S3 " + ls_12 + " Label " + ai_0, OBJPROP_COLOR, S3Color); } else { ObjectSet("S3 " + ls_12 + " Label " + ai_0, OBJPROP_TIME1, l_datetime_8); ObjectSet("S3 " + ls_12 + " Label " + ai_0, OBJPROP_PRICE1, gd_216 + Point * gi_256); } ObjectSetText("S3 " + ls_12 + " Label " + ai_0, "S3 " + ls_12 + ": " + DoubleToStr(gd_216, g_digits_260), pivotFontSize, pivotFont, S3Color); } void clearBars(int ai_0) { string ls_4; if (weeklyNotDaily) ls_4 = "Week"; else ls_4 = "Day"; if (showPivotIcons) { ObjectDelete("P " + ls_4 + " Icon " + ai_0); ObjectDelete("R1 " + ls_4 + " Icon " + ai_0); ObjectDelete("R2 " + ls_4 + " Icon " + ai_0); ObjectDelete("R3 " + ls_4 + " Icon " + ai_0); ObjectDelete("S1 " + ls_4 + " Icon " + ai_0); ObjectDelete("S2 " + ls_4 + " Icon " + ai_0); ObjectDelete("S3 " + ls_4 + " Icon " + ai_0); } if (showPivotLabels) { ObjectDelete("P " + ls_4 + " Label " + ai_0); ObjectDelete("R1 " + ls_4 + " Label " + ai_0); ObjectDelete("R2 " + ls_4 + " Label " + ai_0); ObjectDelete("R3 " + ls_4 + " Label " + ai_0); ObjectDelete("S1 " + ls_4 + " Label " + ai_0); ObjectDelete("S2 " + ls_4 + " Label " + ai_0); ObjectDelete("S3 " + ls_4 + " Label " + ai_0); } }