
#property copyright "Copyright Wise-EA Programming"
#property link      ""

#property indicator_separate_window
#property indicator_minimum -10.0
#property indicator_maximum 120.0
#property indicator_buffers 7
#property indicator_color1 White
#property indicator_color2 Lime
#property indicator_color3 Yellow
#property indicator_color4 White
#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 Gold

extern string DIS = " --- Display Settings --- ";
extern color BorderNameColor = White;
extern string DisplaySymbol = "";
extern string DisplayTimeFrame = "15,30,60";
extern int BarCount = 0;
extern int CandleDisplayMode = 3;//1=line chart 2= cs no wick 3= full cs
extern color WickColor = White;
extern color BullCandleColor = Lime;
extern color BearCandleColor = Red;
extern int BodyThickness = 4;
extern int IndicatorThickness = 1;
extern bool UpdateRealTick = TRUE;
extern string MA = " --- MA Settings --- ";
extern int FastMAPeriod = 20;
extern int FastMAType = 0;
extern int FastMAShift = 0;
extern int SlowMAPeriod = 0;
extern int SlowMAType = 0;
extern int SlowMAShift = 0;
extern string PSAR = " --- PSAR Settings --- ";
extern double Step = 0.0;
extern double Maximum = 0.2;
extern string BB = " --- BB Settings --- ";
extern int BandsPeriod = 20;
extern int BandsShift = 0;
extern double BandsDeviations = 2.0;
extern int BandsAppliedPrice = 0;
extern string RSI = " --- RSI Settings --- ";
extern int RSIPeriod = 0;
extern int RSIAppliedPrice = 0;
extern string STOCH = " --- Stochastic Settings --- ";
extern int StochK = 0;
extern int StochD = 5;
extern int StochSlowing = 5;
double G_ibuf_252[];
double G_ibuf_256[];
double G_ibuf_260[];
double G_ibuf_264[];
double G_ibuf_268[];
double G_ibuf_272[];
double G_ibuf_276[];
int G_digits_280;
int Gi_284;
int G_window_288;
int Gi_292;
int Gia_296[10];
int G_timeframe_300;
double Gd_304;
double Gd_312;
double G_ihigh_320;
double G_ilow_328;
int G_datetime_336;
string Gs_340;
string Gs_dummy_348;
string Gs_dummy_356;
string G_symbol_364;


int init() {
   if (DisplaySymbol == "") G_symbol_364 = Symbol();
   else G_symbol_364 = DisplaySymbol;
   Gd_304 = MarketInfo(G_symbol_364, MODE_POINT);
   G_digits_280 = MarketInfo(G_symbol_364, MODE_DIGITS);
   if (G_digits_280 == 3 || G_digits_280 == 5) Gd_304 = 10.0 * Gd_304;
   Gs_340 = "MultiCharts " + G_symbol_364;
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, IndicatorThickness);
   SetIndexBuffer(0, G_ibuf_252);
   SetIndexLabel(0, NULL);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, IndicatorThickness);
   SetIndexBuffer(1, G_ibuf_256);
   SetIndexLabel(1, NULL);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 159);
   SetIndexBuffer(2, G_ibuf_260);
   SetIndexLabel(2, NULL);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, IndicatorThickness);
   SetIndexBuffer(3, G_ibuf_264);
   SetIndexLabel(3, NULL);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, IndicatorThickness);
   SetIndexBuffer(4, G_ibuf_268);
   SetIndexLabel(4, NULL);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, IndicatorThickness);
   SetIndexBuffer(5, G_ibuf_272);
   SetIndexLabel(5, NULL);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, IndicatorThickness);
   SetIndexBuffer(6, G_ibuf_276);
   SetIndexLabel(6, NULL);
   SetLevelStyle(2, 1, DimGray);
   /*SetLevelValue(0, 0);
   SetLevelValue(1, 10);
   SetLevelValue(2, 20);
   SetLevelValue(3, 30);
   SetLevelValue(4, 40);
   SetLevelValue(5, 50);
   SetLevelValue(6, 60);
   SetLevelValue(7, 70);
   SetLevelValue(8, 80);
   SetLevelValue(9, 90);
   SetLevelValue(10, 100);*/
   IndicatorShortName(Gs_340);
   G_datetime_336 = iTime(G_symbol_364, G_timeframe_300, 1);
   f0_0(DisplayTimeFrame, Gia_296);
   for (int Li_0 = ArraySize(Gia_296) - 1; Li_0 > 0; Li_0--) Gia_296[Li_0] = Gia_296[Li_0 - 1];
   Gi_292 = ArraySize(Gia_296) - 1;
   G_timeframe_300 = Period();
   for (Li_0 = ArraySize(Gia_296) - 1; Li_0 > 0; Li_0--)
      if (Gia_296[Li_0] < G_timeframe_300) G_timeframe_300 = Gia_296[Li_0];
   G_datetime_336 = iTime(G_symbol_364, G_timeframe_300, 1);
   return (0);
}


int deinit() {
   f0_1(Gs_340);
   f0_1("LOGO");
   return (0);
}


int start() {
   if (UpdateRealTick) f0_4();
   else
      if (f0_2(G_timeframe_300)) f0_4();
   f0_7();
   return (0);
}


void f0_4() {
   f0_1(Gs_340);
   for (int index_0 = 0; index_0 < Bars; index_0++) {
      G_ibuf_252[index_0] = EMPTY_VALUE;
      G_ibuf_256[index_0] = EMPTY_VALUE;
      G_ibuf_260[index_0] = EMPTY_VALUE;
      G_ibuf_264[index_0] = EMPTY_VALUE;
      G_ibuf_268[index_0] = EMPTY_VALUE;
      G_ibuf_272[index_0] = EMPTY_VALUE;
      G_ibuf_276[index_0] = EMPTY_VALUE;
   }
   Gi_284 = BarCount + 1;
   if (BarCount == 0) Gi_284 = MathFloor((WindowFirstVisibleBar() + 1) / Gi_292);
   G_window_288 = WindowFind(Gs_340);
   f0_6();
}


void f0_9(int Ai_0, int Ai_4, int Ai_8) {
   string name_16;
   double price_24;
   double price_32;
   G_ihigh_320 = iHigh(G_symbol_364, Gia_296[Ai_0], iHighest(G_symbol_364, Gia_296[Ai_0], MODE_HIGH, Ai_8 - Ai_4 + 1, 0));
   G_ilow_328 = iLow(G_symbol_364, Gia_296[Ai_0], iLowest(G_symbol_364, Gia_296[Ai_0], MODE_LOW, Ai_8 - Ai_4 + 1, 0));
   Gd_312 = (G_ihigh_320 - G_ilow_328) / 100.0;
   for (int Li_12 = Ai_4; Li_12 <= Ai_8; Li_12++) {
      if (CandleDisplayMode == 1 || CandleDisplayMode == 3) {
         name_16 = Gs_340 + 2 + "-" + Time[Li_12] + " Wick";
         price_24 = (iHigh(G_symbol_364, Gia_296[Ai_0], Li_12 - Ai_4) - G_ilow_328) / Gd_312;
         price_32 = (iLow(G_symbol_364, Gia_296[Ai_0], Li_12 - Ai_4) - G_ilow_328) / Gd_312;
         ObjectCreate(name_16, OBJ_TREND, G_window_288, Time[Li_12], price_24, Time[Li_12], price_32);
         f0_8(name_16, WickColor, STYLE_SOLID, 1);
      }
      if (CandleDisplayMode == 2 || CandleDisplayMode == 3) {
         name_16 = Gs_340 + 3 + "-" + Time[Li_12] + " Body";
         price_24 = (iOpen(G_symbol_364, Gia_296[Ai_0], Li_12 - Ai_4) - G_ilow_328) / Gd_312;
         price_32 = (iClose(G_symbol_364, Gia_296[Ai_0], Li_12 - Ai_4) - G_ilow_328) / Gd_312;
         ObjectCreate(name_16, OBJ_TREND, G_window_288, Time[Li_12], price_24, Time[Li_12], price_32);
         if (price_32 >= price_24) {
            f0_8(name_16, BullCandleColor, STYLE_SOLID, BodyThickness);
            continue;
         }
         f0_8(name_16, BearCandleColor, STYLE_SOLID, BodyThickness);
      }
   }
}


void f0_3(int Ai_0, int Ai_4, int Ai_8) {
   double Ld_16;
   for (int Li_12 = Ai_4; Li_12 <= Ai_8; Li_12++) {
      if (FastMAPeriod > 0) {
         Ld_16 = iMA(G_symbol_364, Gia_296[Ai_0], FastMAPeriod, FastMAShift, FastMAType, PRICE_CLOSE, Li_12 - Ai_4);
         G_ibuf_252[Li_12] = (Ld_16 - G_ilow_328) / Gd_312;
      }
      if (SlowMAPeriod > 0) {
         Ld_16 = iMA(G_symbol_364, Gia_296[Ai_0], SlowMAPeriod, SlowMAShift, SlowMAType, PRICE_CLOSE, Li_12 - Ai_4);
         G_ibuf_256[Li_12] = (Ld_16 - G_ilow_328) / Gd_312;
      }
      if (Step > 0.0) {
         Ld_16 = iSAR(G_symbol_364, Gia_296[Ai_0], Step, Maximum, Li_12 - Ai_4);
         G_ibuf_260[Li_12] = (Ld_16 - G_ilow_328) / Gd_312;
      }
      if (BandsPeriod > 0) {
         Ld_16 = iBands(G_symbol_364, Gia_296[Ai_0], BandsPeriod, BandsDeviations, BandsShift, BandsAppliedPrice, MODE_UPPER, Li_12 - Ai_4);
         G_ibuf_264[Li_12] = (Ld_16 - G_ilow_328) / Gd_312;
         Ld_16 = iBands(G_symbol_364, Gia_296[Ai_0], BandsPeriod, BandsDeviations, BandsShift, BandsAppliedPrice, MODE_LOWER, Li_12 - Ai_4);
         G_ibuf_268[Li_12] = (Ld_16 - G_ilow_328) / Gd_312;
      }
      if (RSIPeriod > 0) G_ibuf_272[Li_12] = iRSI(G_symbol_364, Gia_296[Ai_0], RSIPeriod, RSIAppliedPrice, Li_12 - Ai_4);
      if (StochK > 0) G_ibuf_276[Li_12] = iStochastic(G_symbol_364, Gia_296[Ai_0], StochK, StochD, StochSlowing, MODE_SMA, 0, MODE_MAIN, Li_12 - Ai_4);
   }
}


void f0_6() {
   string name_4;
   int Li_12;
   for (int Li_0 = 1; Li_0 <= Gi_292; Li_0++) {
      name_4 = Gs_340 + 0 + "-" + (Time[Gi_284 * Li_0]) + " VLine";
      ObjectCreate(name_4, OBJ_VLINE, G_window_288, Time[Gi_284 * Li_0], 0);
      f0_8(name_4, BorderNameColor, STYLE_SOLID, 2);
      f0_9(Li_0, Gi_284 * (Li_0 - 1) + 1, Gi_284 * Li_0 - 1);
      f0_3(Li_0, Gi_284 * (Li_0 - 1) + 1, Gi_284 * Li_0 - 1);
      name_4 = Gs_340 + 1 + "-" + Li_0 + " Lable";
      Li_12 = Gi_284 * Li_0 - MathFloor(Gi_284 / 2);
      ObjectCreate(name_4, OBJ_TEXT, G_window_288, Time[Li_12], 120);
      ObjectSetText(name_4, G_symbol_364 + " " + Gia_296[Li_0] + " ( " + ((Gi_284 - 1)) + " , " + DoubleToStr(100.0 * Gd_312 / Gd_304, 1) + " pips )", 7, "Arial Bold",
         BorderNameColor);
   }
}


void f0_8(string A_name_0, color A_color_8, int A_style_12, int A_width_16) {
   ObjectSet(A_name_0, OBJPROP_COLOR, A_color_8);
   ObjectSet(A_name_0, OBJPROP_WIDTH, A_width_16);
   ObjectSet(A_name_0, OBJPROP_STYLE, A_style_12);
   ObjectSet(A_name_0, OBJPROP_BACK, FALSE);
   ObjectSet(A_name_0, OBJPROP_TIMEFRAMES, NULL);
   ObjectSet(A_name_0, OBJPROP_RAY, FALSE);
}


void f0_0(string As_0, int &Aia_8[10]) {
   int Li_16 = 0;
   int index_20 = 0;
   for (int Li_12 = StringFind(As_0, ",", Li_16); Li_12 > 0; Li_12 = StringFind(As_0, ",", Li_16)) {
      Aia_8[index_20] = StrToDouble(StringSubstr(As_0, Li_16, Li_12 - Li_16));
      index_20++;
      Li_16 = Li_12 + 1;
   }
   if (Li_12 < 0) {
      if (index_20 > 0) Aia_8[index_20] = StrToDouble(StringSubstr(As_0, Li_16, StringLen(As_0) - 1));
      else Aia_8[index_20] = StrToDouble(StringSubstr(As_0, Li_16, StringLen(As_0)));
      index_20++;
   }
   ArrayResize(Aia_8, index_20 + 1);
}


int f0_2(int A_timeframe_0) {
   bool Li_ret_4 = FALSE;
   if (G_datetime_336 != iTime(G_symbol_364, A_timeframe_0, 0)) {
      G_datetime_336 = iTime(G_symbol_364, A_timeframe_0, 0);
      Li_ret_4 = TRUE;
   }
   return (Li_ret_4);
}


void f0_1(string As_0) {
   string name_12;
   int Li_8 = 0;
   while (Li_8 < ObjectsTotal()) {
      name_12 = ObjectName(Li_8);
      if (StringSubstr(name_12, 0, StringLen(As_0)) == As_0) ObjectDelete(name_12);
      else Li_8++;
   }
}


void f0_7() {
   f0_5("LOGO" + "0", "", 20, DarkGray, 3, 275, 5, "Arial", 150);
   f0_5("LOGO" + "1", "Product of Wise-EA Programming", 10, DarkGray, 3, 70, 10, "Arial", 0);
   f0_5("LOGO" + "2", "", 20, DarkGray, 3, 37, 5, "Arial", 151);
}


void f0_5(string A_name_0, string A_text_8, int A_fontsize_16, color A_color_20, int A_corner_24, int A_x_28, int A_y_32, string A_fontname_36, int Ai_44) {
   //ObjectDelete(A_name_0);
  // ObjectCreate(A_name_0, OBJ_LABEL, 0, 0, 0);
   //if (A_text_8 != "") ObjectSetText(A_name_0, A_text_8, A_fontsize_16, A_fontname_36, A_color_20);
   //else ObjectSetText(A_name_0, CharToStr(Ai_44), A_fontsize_16, "Wingdings", Black);
   ObjectSet(A_name_0, OBJPROP_CORNER, A_corner_24);
   ObjectSet(A_name_0, OBJPROP_XDISTANCE, A_x_28);
   ObjectSet(A_name_0, OBJPROP_YDISTANCE, A_y_32);
}
