//+------------------------------------------------------------------+
//|                                                 #MarketPrice.mq4 |
//|                                                       ServerUang |
//|                                    http://www.indofx-trader.net/ |
//+------------------------------------------------------------------+
#property copyright "ServerUang"
#property link      "http://www.indofx-trader.net/"

#property indicator_chart_window

extern string Indicator_Name = "#MarketPrice";
extern bool Right_Top = true;
extern int Shift_Y = 0; 
extern int Shift_X = 0;

// Untuk menentukan Warna Harga sesuai arah Trend
extern string Price_Variable = "Setting for Price Color" ; // change
extern color Price_color_Up = Blue;
extern color Price_color_Dn = Red;
extern int Time_Frame=15;

extern int MA_Fast_Period = 1; 
extern int MA_Fast_Method = 0; 
extern int MA_Fast_Apply_To = 0;
extern int MA_Fast_Shift = 0;

extern int MA_Slow_Period = 5; 
extern int MA_Slow_Method = 0;
extern int MA_Slow_Apply_To = 0;
extern int MA_Slow_Shift = 0;

extern string Value_Color ="Setting for Value Color";
extern color Highest_Color          = Black;
extern color Distance_from_Highest_Color = Gainsboro;
extern color Lowest_Color           = DarkOrange;
extern color Distance_from_Lowest_Color  = Gold;
extern color Hi_to_Lo_Color         = SteelBlue;
extern color Daily_Av_Up_Color      = Lime;
extern color Daily_Av_Dn_Color      = Orange;
extern color Time_n_Spread_Color    = Aqua;
extern color PipsToOpen_Up_Color    = LightSkyBlue;
extern color PipsToOpen_Dn_Color    = Salmon;

extern string Xtra_Information = "Setting for Extra information"; 

extern bool  Show_Xtra_Info    = true;

extern string CCi_Parameters      = "CCi Parameters";
extern int   CCI_period           = 20; 
extern color Label_color          = Silver;
extern color Text_Xtreme_Up_Color = White;
extern color Text_Up_Color        = LightBlue;
extern color Text_Dn_Color        = Orange;
extern color Text_Xtreme_Dn_Color = Yellow;

// Input Parameter utk Bollinger Bands
extern string Bands_Parameters = "Bollinger Bands Parameters" ; // change
extern int Periode = 20;
extern int Deviation = 2;
extern int Bands_shift = 0;
extern int Applied_price = PRICE_CLOSE;
extern color Bands_ExtremePlus_Color = Aqua;
extern color Bands_Plus_Color = DodgerBlue;
extern color Bands_PlusMid_Color = Blue;
extern color Bands_Mid_Color = Silver;
extern color Bands_MinMid_Color = Red;
extern color Bands_Minus_Color = DarkOrange;
extern color Bands_ExtremeMinus_Color = Yellow;

// Untuk menentukan arah Trend
extern string Trend_Variable = "Variable TRend Direction" ; // change
extern int   xMA_Fast_Period     = 1; 
extern int   xMA_Fast_Method     = 0; 
extern int   xMA_Fast_Apply_To   = 0;
extern int   xMA_Fast_Shift      = 0;

extern int   xMA_Slow_Period     = 20; 
extern int   xMA_Slow_Method     = 0;
extern int   xMA_Slow_Apply_To   = 0;
extern int   xMA_Slow_Shift      = 0;
extern color Trend_Up_Color     = Blue;
extern color Trend_Dn_Color     = Red;
//=================================================================================
string Label_Teks="", Huruf="", Teks="", nomor="";
double Nilai, x, y, d_A, d_B, d_A1, d_B1, TF, Range, bbP, bbMid, bbM, nilaiWarnaCandle;
color  WarnaHarga, WarnaTrend, WarnaCandle;
int    Ukuran, n, Kolom;

// --- variabel Daili_Av --------------------------------------------
//int    R1, R5, R10, R20, RAvg, i;
//string Teks_ReRata = "", Teks_Rerata_Kemarin ="", Nomor="";
//color  Warna_ReRata;

// --- Variabel Time for next candle
string Teks_Menit, Teks_Detik;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll(0,OBJ_HLINE);
   ObjectsDeleteAll(0,OBJ_TEXT);
   ObjectsDeleteAll(0,OBJ_LABEL);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   int    counted_bars=IndicatorCounted();
   
   //Menampilkan Harga
   Nilai=iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0); Teks=DoubleToStr(Nilai,Digits);
   Huruf="Arial"; Ukuran=34; x=09+Shift_X; y=22+Shift_Y;
   // WarnaHarga=WarnaLampu pada trend TF 5 menit
   d_B = iMA(Symbol(),0,MA_Fast_Period,MA_Fast_Shift,MA_Fast_Method,MA_Fast_Apply_To,0);
   d_A = iMA(Symbol(),0,MA_Slow_Period,MA_Slow_Shift,MA_Slow_Method,MA_Slow_Apply_To,0);
   WarnaHarga=CheckWarna(d_B, d_A, Price_color_Up, Price_color_Dn);
   Tulis("MP01", Right_Top, x, y, Teks, Ukuran, Huruf, WarnaHarga);

   Huruf="Tahoma Bold"; Ukuran=10; 
   //Menampilkan Highest
   d_A=iHigh(NULL,1440,0);d_A1=iHigh(NULL,1440,1); Teks=DoubleToStr(d_A1, Digits);
   x=100+Shift_X; y=14+Shift_Y;
   Tulis("MP02", Right_Top, x, y, Teks, Ukuran, Huruf, Highest_Color);
   
   //Menampilkan Lowest
   d_B=iLow(NULL,1440,0);d_B1=iLow(NULL,1440,1); Teks=DoubleToStr(d_B1, Digits);
   x=100+Shift_X; y=62+Shift_Y;
   Tulis("MP03", Right_Top, x, y, Teks, Ukuran, Huruf, Lowest_Color);
   
   //--- Informasi Distance from Highest ---
   //Teks=DoubleToStr((Nilai-d_A)/Point,0);
   //x=56+Shift_X; y=14+Shift_Y;
   //Tulis("MP04", Right_Top, x, y, Teks, Ukuran, Huruf, Distance_from_Highest_Color);
   
   //--- Informasi Distance from Lowest ---
   //Teks=DoubleToStr((Nilai-d_B)/Point,0);
   //x=56+Shift_X; y=62+Shift_Y;
   //Tulis("MP05", Right_Top, x, y, Teks, Ukuran, Huruf, Distance_from_Lowest_Color);
   
   //--- Informasi Hi to Lo ---
   Teks=DoubleToStr((d_A1 - d_B1)/Point,0);
   x=10+Shift_X; y=14+Shift_Y;
   Tulis("MP06", Right_Top, x, y, Teks, Ukuran, Huruf, Hi_to_Lo_Color);
   
   //--- Informasi Daily Av ---
   //R1=0; R5=0; R10=0; R20=0; RAvg=0; i=0;
   //R1 =  (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   //for(i=1;i<=5;i++)   
   //  R5  = R5  + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   //for(i=1;i<=10;i++)
   //  R10 = R10 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   //for(i=1;i<=20;i++)
  //   R20 = R20 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;

   //R5 = R5/5;
  // R10 = R10/10;
  // R20 = R20/20;
  // RAvg  =  (R1+R5+R10+R20)/4;    
   
  // Teks_ReRata = (DoubleToStr(RAvg,Digits-4));
  // Teks_Rerata_Kemarin = (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   
  // if (Teks_ReRata > Teks_Rerata_Kemarin) {Warna_ReRata = Daily_Av_Up_Color;}
  //    else {Warna_ReRata = Daily_Av_Dn_Color;}
      
  // x=10+Shift_X; y=62+Shift_Y;
  // Tulis("MP07", Right_Top, x, y, Teks_ReRata, Ukuran, Huruf, Warna_ReRata);
   
//  Time for Next Candle
   d_B = (Time[4]-Time[5])-MathMod(CurTime(),Time[4]-Time[5]);
   d_A = d_B/60;
   d_B = (d_A-MathFloor(d_A))*60;
   d_A = MathFloor(d_A);
   Teks_Menit = DoubleToStr(d_A,0);
   Teks_Detik = DoubleToStr(d_B,0);
   Teks=Teks_Menit+":"+Teks_Detik;
   x=14+Shift_X; y=64+Shift_Y;
   Tulis("MP08", Right_Top, x, y, Teks, Ukuran, Huruf, Time_n_Spread_Color);
   
   // --- Spread
  // d_A = (Ask - Bid)/Point;
  // Teks = (DoubleToStr(d_A,Digits-4));
  // x=56+Shift_X; y=74+Shift_Y;
  // Tulis("MP09", Right_Top, x, y, Teks, Ukuran, Huruf, Time_n_Spread_Color);
   
   //--- Informasi from Pips to Open ---
  // d_A = iOpen(NULL,1440,0);
  // d_B = iClose(NULL,1440,0);
   //WarnaHarga=CheckWarna(d_B, d_A, PipsToOpen_Up_Color, PipsToOpen_Dn_Color);
  // Teks=DoubleToStr((d_B-d_A)/Point,0);
  // x=10+Shift_X; y=74+Shift_Y;
  // Tulis("MP10", Right_Top, x, y, Teks, Ukuran, Huruf, WarnaHarga);
   
   //--- Show_Xtra_Info ---
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// Prosedur Tulis
void Tulis(string LBL, double sebelah, int pos_x, int pos_y, string teks, int ukuran_huruf, string nama_huruf, color warna=CLR_NONE)
     {
       Label_Teks=LBL;
       ObjectCreate(LBL, OBJ_LABEL, 0, 0, 0);
       ObjectSetText(LBL,teks, ukuran_huruf, nama_huruf, warna);
       ObjectSet(LBL, OBJPROP_CORNER, sebelah);
       ObjectSet(LBL, OBJPROP_XDISTANCE, pos_x);
       ObjectSet(LBL, OBJPROP_YDISTANCE, pos_y);
     }

// Function CheckWarna
color CheckWarna(double a, double b, color U, color D)
      {
        if (a>b) { return (U); } else { return (D); }
      } 
      
// Function CheckWarnaAngka
  