#property copyright "© 2009.07.17, SwingMan" #property link "" #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Red #property indicator_color4 Green #property indicator_color5 Aqua #property indicator_color6 Gold extern int TRIX_Period = 3; extern string _____TRIX_Averages_____ = "0=SMA, 1=EMA, 2=SMMA, 3=LWMA"; extern int Mode_Average_1 = 1; extern int Mode_Average_2 = 1; extern int Mode_Average_3 = 1; extern string _____TRIX_Input_Price_____ = "0=C,4=Median,5=Typical,6=Weighted"; extern int Input_Price = 0; extern int iArrow = 167; extern int CountBars = 500; extern bool Draw_Closes = TRUE; int g_period_124 = 0; double gd_128 = 1000.0; double gda_136[]; double gda_140[]; double gda_144[]; double gda_148[]; double gda_152[]; double gda_156[]; double gda_160[]; double gda_164[]; double g_ibuf_168[]; double g_ibuf_172[]; double g_ibuf_176[]; double g_ibuf_180[]; double g_ibuf_184[]; double g_ibuf_188[]; int g_ma_method_192; int g_ma_method_196; int g_ma_method_200; int g_applied_price_204; int init() { string ls_0; string ls_8; string ls_24; ArraySetAsSeries(gda_136, TRUE); ArraySetAsSeries(gda_140, TRUE); ArraySetAsSeries(gda_164, TRUE); ArraySetAsSeries(gda_152, TRUE); ArraySetAsSeries(gda_156, TRUE); ArraySetAsSeries(gda_160, TRUE); ArraySetAsSeries(gda_144, TRUE); ArraySetAsSeries(gda_148, TRUE); IndicatorDigits(Digits); SetIndexBuffer(0, g_ibuf_168); SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexLabel(0, "High/Low 1"); SetIndexBuffer(1, g_ibuf_172); SetIndexStyle(1, DRAW_HISTOGRAM); SetIndexLabel(1, "High/Low 2"); SetIndexBuffer(2, g_ibuf_176); SetIndexStyle(2, DRAW_HISTOGRAM); SetIndexLabel(2, "Open"); SetIndexBuffer(3, g_ibuf_180); SetIndexStyle(3, DRAW_HISTOGRAM); SetIndexLabel(3, "Close"); SetIndexBuffer(4, g_ibuf_184); SetIndexStyle(4, DRAW_ARROW); SetIndexArrow(4, iArrow); SetIndexLabel(4, NULL); SetIndexBuffer(5, g_ibuf_188); SetIndexStyle(5, DRAW_ARROW); SetIndexArrow(5, iArrow); SetIndexLabel(5, NULL); g_ma_method_192 = 2; g_ma_method_196 = 2; g_ma_method_200 = 1; g_applied_price_204 = 0; switch (Mode_Average_1) { case 0: g_ma_method_192 = 0; ls_8 = "S"; break; case 1: g_ma_method_192 = 1; ls_8 = "E"; break; case 2: g_ma_method_192 = 2; ls_8 = "M"; break; case 3: g_ma_method_192 = 3; ls_8 = "W"; } switch (Mode_Average_2) { case 0: g_ma_method_196 = 0; td_16 = "S"; break; case 1: g_ma_method_196 = 1; td_16 = "E"; break; case 2: g_ma_method_196 = 2; td_16 = "M"; break; case 3: g_ma_method_196 = 3; td_16 = "W"; } switch (Mode_Average_3) { case 0: g_ma_method_200 = 0; ls_24 = "S"; break; case 1: g_ma_method_200 = 1; ls_24 = "E"; break; case 2: g_ma_method_200 = 2; ls_24 = "M"; break; case 3: g_ma_method_200 = 3; ls_24 = "W"; } switch (Input_Price) { case 0: g_applied_price_204 = 0; ls_0 = "C"; break; case 4: g_applied_price_204 = 4; ls_0 = "M"; break; case 5: g_applied_price_204 = 5; ls_0 = "T"; break; case 6: g_applied_price_204 = 6; ls_0 = "W"; } string ls_48 = ", " + ls_8 + "," + td_16 + "," + ls_24 + ", " + ls_0; string ls_56 = "smC4Scalper Candles_v3.1 (" + TRIX_Period + ls_48 + ")"; IndicatorShortName(ls_56); Comment(ls_56); return (0); } int deinit() { Comment(""); return (0); } int start() { string ls_unused_0; if (TRIX_Period == g_period_124) return (0); ArrayResize(gda_136, Bars); ArrayResize(gda_140, Bars); ArrayResize(gda_164, Bars); ArrayResize(gda_152, Bars); ArrayResize(gda_156, Bars); ArrayResize(gda_160, Bars); ArrayResize(gda_144, Bars); ArrayResize(gda_148, Bars); int li_12 = CountBars; if (li_12 > Bars) li_12 = Bars - 1; for (int li_8 = 0; li_8 < li_12; li_8++) gda_136[li_8] = iMA(Symbol(), Period(), TRIX_Period, 0, g_ma_method_192, g_applied_price_204, li_8); for (li_8 = 0; li_8 < li_12; li_8++) gda_140[li_8] = iMAOnArray(gda_136, 0, TRIX_Period, 0, g_ma_method_196, li_8); for (li_8 = 0; li_8 < li_12; li_8++) gda_164[li_8] = iMAOnArray(gda_140, 0, TRIX_Period, 0, g_ma_method_200, li_8); for (li_8 = 0; li_8 < li_12 - 1; li_8++) if (gda_164[li_8 + 1] != 0.0) gda_136[li_8] = gd_128 * (gda_164[li_8] - (gda_164[li_8 + 1])) / (gda_164[li_8 + 1]); for (li_8 = 0; li_8 < li_12 - 1; li_8++) gda_140[li_8] = iMAOnArray(gda_136, 0, g_period_124, 0, MODE_EMA, li_8); for (li_8 = 0; li_8 < li_12 - 1; li_8++) Set_CandleValues(li_8); return (0); } void Set_CandleValues(int ai_0) { bool li_12; bool li_16; double ld_4 = gda_136[ai_0] - gda_140[ai_0]; if (ld_4 >= 0.0) { li_12 = TRUE; li_16 = FALSE; } else { li_12 = FALSE; li_16 = TRUE; } double l_iopen_20 = iOpen(Symbol(), Period(), ai_0); double l_iclose_28 = iClose(Symbol(), Period(), ai_0); double l_ihigh_36 = iHigh(Symbol(), Period(), ai_0); double l_ilow_44 = iLow(Symbol(), Period(), ai_0); if (li_12 == TRUE) { if (l_iclose_28 >= l_iopen_20) { if (Draw_Closes == TRUE) { g_ibuf_184[ai_0] = l_iclose_28; g_ibuf_188[ai_0] = EMPTY_VALUE; } g_ibuf_168[ai_0] = l_ilow_44; g_ibuf_172[ai_0] = l_ihigh_36; g_ibuf_176[ai_0] = l_iopen_20; g_ibuf_180[ai_0] = l_iclose_28; return; } if (Draw_Closes == TRUE) { g_ibuf_184[ai_0] = EMPTY_VALUE; g_ibuf_188[ai_0] = l_iclose_28; } g_ibuf_168[ai_0] = l_ilow_44; g_ibuf_172[ai_0] = l_ihigh_36; g_ibuf_176[ai_0] = l_iclose_28; g_ibuf_180[ai_0] = l_iopen_20; return; } if (li_16 == TRUE) { if (l_iclose_28 >= l_iopen_20) { if (Draw_Closes == TRUE) { g_ibuf_184[ai_0] = l_iclose_28; g_ibuf_188[ai_0] = EMPTY_VALUE; } g_ibuf_168[ai_0] = l_ihigh_36; g_ibuf_172[ai_0] = l_ilow_44; g_ibuf_176[ai_0] = l_iclose_28; g_ibuf_180[ai_0] = l_iopen_20; } else { if (Draw_Closes == TRUE) { g_ibuf_184[ai_0] = EMPTY_VALUE; g_ibuf_188[ai_0] = l_iclose_28; } g_ibuf_168[ai_0] = l_ihigh_36; g_ibuf_172[ai_0] = l_ilow_44; g_ibuf_176[ai_0] = l_iopen_20; g_ibuf_180[ai_0] = l_iclose_28; } } }