//+------------------------------------------------------------------+
//|                                                    BDMMtcswl.mq4 |
//|                                           Alguasta Software 2015 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Alguasta Software 2015"
#property link      ""
#property version   "1.01"
#property strict

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Purple
#property indicator_color4 DarkTurquoise
#property indicator_color5 Yellow
#property indicator_color6 Lime
#property indicator_color7 White
#property indicator_color8 Blue
#property indicator_level1 80
#property indicator_level2 75
#property indicator_level3 50
#property indicator_level4 25
#property indicator_level5 20
#property indicator_levelcolor Gray
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_SOLID

#import "SDSMain.dll"
   int xCreateFunc2012();
   int xDestroyFunc2012(int a0);
   void SDSAddPriceData(int a0, double a1, double a2, double a3, double a4, int a5, int a6, int a7, int a8, int a9, double a10, int a11);
   double SDSFatman1(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman2(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman3(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman4(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman5(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman6(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman7(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   double SDSFatman8(int a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10);
   int SDSFatArray(int a0, int a1, int & arr[]);
   int SDSFatLength(int a0, double & a1[]);
#import
#import "kernel32.dll"
   int LocalAlloc(int, int);                   
   int LocalFree(int);                  
   int lstrcpyA(int,uchar & arr[]);
   int lstrlenA(int);
   void RtlMoveMemory(uchar & arr[], int, int);
#import
#import "user32.dll"
int GetForegroundWindow();
int FindWindowExW(int,int,string,string);
int GetWindowRect(int,int &arr[]);
int GetClientRect(int,int &arr[]);
int SetWindowLongW(int,int,int);
int SetWindowLongPtr(int,int,int);
int GetWindowLongW(int,int);
int GetSystemMenu(int,bool);
int InsertMenuW(int,int,int,int,string);
int SetWindowPos(int,int,int,int,int,int,int);
int GetParent(int);
int GetAncestor(int,int);
int GetWindowTextW(int,short &arr[],int);
int ShowWindow(int,int);
int GetClassNameW(int,short &arr[],int);
int GetDlgCtrlID(int);
int GetDlgItem(int,int);
bool IsZoomed(int);
bool InvalidateRect(int,int &arr[],bool);
#import

#define GWL_STYLE         -16 
#define WS_SIZEBOX        0x00040000
#define WS_MINIMIZEBOX    0x00020000
#define WS_MAXIMIZEBOX    0x00010000
#define WS_CAPTION        0x00C00000
#define WS_THICKFRAME     0x00040000
#define WS_SYSMENU        0x00080000
#define WS_MAXIMIZE       0x01000000
#define WS_MINIMIZE       0x20000000
#define WS_DLGFRAME       0x00400000
#define WS_POPUP          0x80000000
#define WS_CHILD          0x40000000
#define WS_THINFRAME      0x00100000
#define MF_STRING         0x00000000
#define MF_BYPOSITION     0x00000400
#define SW_MAXIMIZE       0x0003
#define SC_SIZE           0xF000
#define SC_MAXIMIZE       0xF030
#define SC_MINIMIZE       0xF020
#define SC_RESTORE        0xF120
#define SWP_NOSIZE        0x0001
#define SWP_NOMOVE        0x0002
#define SWP_NOZORDER      0x0004
#define SWP_NOACTIVATE    0x0010
#define SWP_FRAMECHANGED  0x0020

enum tfs {M1=1,M5=5,M15=15,M30=30,H1=60,H4=240,D1=1440,W1=10080,MN=43200};

 int LookBack = 100;
 tfs ShowPeriod = 15;
 bool EveryTick = true;
 bool Show_ALL = true;
 int LineWidth = 1;

int Color_AUD = Red;
int Color_CAD = Yellow;
int Color_CHF = White;
int Color_EUR = Lime;
int Color_GBP = Orange;
int Color_JPY = Purple;
int Color_NZD = Blue;
int Color_USD = DarkTurquoise;

bool Show_AUD = false;
bool Show_CAD = false;
bool Show_CHF = false;
bool Show_EUR = false;
bool Show_GBP = false;
bool Show_JPY = false;
bool Show_NZD = false;
int Show_USD = false;

double G_ibuf_92[];
double G_ibuf_96[];
double G_ibuf_100[];
double G_ibuf_104[];
double G_ibuf_108[];
double G_ibuf_112[];
double G_ibuf_116[];
double G_ibuf_120[];

int Gi_124;
string Gs_128;
datetime lastbar;
int winnum;
int runperiod;
int offset;
string highername;
int broadcastEventID=5000;

int but[9]={1,5,15,30,60,240,1440,10080,43200};
string butname[9]={"M1","M5","M15","M30","H1","H4","D1","W1","MN"};

int init() {

//   resizeWindow();   

   if (allowed() == false)
      return(INIT_FAILED);

   ObjectsDeleteAll();
   
   runperiod = Period();

   for(int i=0;i<9;i++) {
   ObjectCreate(0,butname[i],OBJ_BUTTON,0,0,0);
   ObjectSetInteger(0,butname[i],OBJPROP_XSIZE,25);
   ObjectSetInteger(0,butname[i],OBJPROP_YSIZE,15);
   if (runperiod == but[i])
      ObjectSetInteger(0,butname[i],OBJPROP_BGCOLOR,clrBlue);
   else
      ObjectSetInteger(0,butname[i],OBJPROP_BGCOLOR,clrGray);
   ObjectSetInteger(0,butname[i],OBJPROP_ANCHOR,ANCHOR_LEFT_UPPER);
   ObjectSetInteger(0,butname[i],OBJPROP_YDISTANCE,40);
   ObjectSetInteger(0,butname[i],OBJPROP_XDISTANCE,40 + i * 30);
   ObjectSetString(0,butname[i],OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,butname[i],OBJPROP_FONTSIZE,8);
   ObjectSetInteger(0,butname[i],OBJPROP_COLOR,clrWhite);
   ObjectSetString(0,butname[i],OBJPROP_TEXT,butname[i]);
   ObjectSetInteger(0,butname[i],OBJPROP_BACK,0);
   ObjectSetInteger(0,butname[i],OBJPROP_STATE,0);
   ObjectSetInteger(0,butname[i],OBJPROP_SELECTABLE,0);
   }

   SetIndexBuffer(0, G_ibuf_92);
   SetIndexBuffer(1, G_ibuf_96);
   SetIndexBuffer(2, G_ibuf_100);
   SetIndexBuffer(3, G_ibuf_104);
   SetIndexBuffer(4, G_ibuf_108);
   SetIndexBuffer(5, G_ibuf_112);
   SetIndexBuffer(6, G_ibuf_116);
   SetIndexBuffer(7, G_ibuf_120);
   SetIndexShift(0, 0);
   SetIndexShift(1, 0);
   SetIndexShift(2, 0);
   SetIndexShift(3, 0);
   SetIndexShift(4, 0);
   SetIndexShift(5, 0);
   SetIndexShift(6, 0);
   SetIndexShift(7, 0);
   SetIndexDrawBegin(0, 0);
   SetIndexDrawBegin(1, 0);
   SetIndexDrawBegin(2, 0);
   SetIndexDrawBegin(3, 0);
   SetIndexDrawBegin(4, 0);
   SetIndexDrawBegin(5, 0);
   SetIndexDrawBegin(6, 0);
   SetIndexDrawBegin(7, 0);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, LineWidth);
   SetIndexLabel(0, "AUD");
   SetIndexLabel(1, "GBP");
   SetIndexLabel(2, "JPY");
   SetIndexLabel(3, "USD");
   SetIndexLabel(4, "CAD");
   SetIndexLabel(5, "EUR");
   SetIndexLabel(6, "CHF");
   SetIndexLabel(7, "NZD");
   IndicatorShortName("TCSPOP");

   winnum = WindowFind("TCSPOP");

   Gi_124 = xCreateFunc2012();

   return (0);
}
int deinit() {
   ObjectDelete("AUD"+runperiod);
   ObjectDelete("USD"+runperiod);
   ObjectDelete("CHF"+runperiod);
   ObjectDelete("EUR"+runperiod);
   ObjectDelete("CAD"+runperiod);
   ObjectDelete("NZD"+runperiod);
   ObjectDelete("JPY"+runperiod);
   ObjectDelete("GBP"+runperiod);
   xDestroyFunc2012(Gi_124);
   return (0);
}
int start() {

   if (EveryTick == false) {
      if (iTime(Symbol(),runperiod,0) == lastbar)
         return(0);
   }

   lastbar = iTime(Symbol(),runperiod,0);
       
   int Li_4;
   int Li_16;
   double ima_20;
   double ima_28;
   double ima_36;
   double ima_44;
   double ima_52;
   double ima_60;
   double ima_68;
   double ima_76;
   double ima_84;
   double ima_92;
   double ima_100;
   double ima_108;
   double ima_116;
   double ima_124;
   double ima_132;
   double ima_140;
   double ima_188;
   double ima_196;
   double ima_204;
   double ima_212;
   double ima_220;
   double ima_228;
   double ima_236;
   double ima_244;
   double ima_252;
   double ima_260;
   double ima_268;
   double ima_276;
   double ima_284;
   double ima_292;
   double ima_300;
   double ima_308;
   double ima_316;
   double ima_324;
   double ima_332;
   double ima_340;
   double ima_348;
   double ima_356;
   double ima_364;
   double ima_372;
   double ima_420;
   double ima_428;
   double ima_436;
   double ima_444;
   double ima_452;
   double ima_460;
   double ima_468;
   double ima_476;
   int Li_488;
   int disp;

   int untilhere = 0;
   if (EveryTick == true)
      untilhere = -1;

   if (winnum == -1)
      winnum = 0;

   if (AccountNumber() > 0) {
      Li_4 = AccountNumber();
      if (Li_4 > 99999999) Li_4 -= 100000000 * (Li_4 / 100000000);

    string Lsa_8[31] = {"xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx",
                        "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx"};

   int fatmanparms[];
   ArrayResize(fatmanparms,64);

   for (int i = 0; i < 31; i++) {
      int szString = StringLen(Lsa_8[i]);
      fatmanparms[i * 2] = szString;
   
      int ptrMem = LocalAlloc(0x40 /* LPTR */, 6 + 1);
      fatmanparms[(i * 2) + 1] = ptrMem;

      uchar ucString[];
      StringToCharArray(Lsa_8[i], ucString);
 
      lstrcpyA(ptrMem, ucString);     
   }

    Li_16 = SDSFatArray(Gi_124, Li_4, fatmanparms);

   for (int i = 0; i < 31; i++) {
      int NewSizeofString = lstrlenA(fatmanparms[(i * 2) + 1]);
      
      uchar ucReceive[];
      ArrayResize(ucReceive, NewSizeofString + 1);
      RtlMoveMemory(ucReceive, fatmanparms[(i * 2) + 1], NewSizeofString + 1);

      Lsa_8[i] = CharArrayToString(ucReceive);
      
      LocalFree(fatmanparms[(i * 2) + 1]);
   }
   double Lda_12[5]={1.5,2.6,3.7,4.8,5.9};

   Li_16 = SDSFatLength(Gi_124, Lda_12);
      for (int bars_484 = iBars(Symbol(),runperiod); bars_484 > untilhere; bars_484--) {
         if (bars_484 <= 200) {
            SDSAddPriceData(Gi_124, iOpen(Symbol(),runperiod,bars_484), iHigh(Symbol(),runperiod,bars_484), iLow(Symbol(),runperiod,bars_484), iClose(Symbol(),runperiod,bars_484), iVolume(Symbol(),runperiod,bars_484), iTime(Symbol(),runperiod,bars_484), runperiod, runperiod, 2, Point, iBars(Symbol(),runperiod) - bars_484);
         
            ima_20 = iMA(Lsa_8[2], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_28 = iMA(Lsa_8[3], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_36 = iMA(Lsa_8[4], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_44 = iMA(Lsa_8[5], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_52 = iMA(Lsa_8[6], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_60 = iMA(Lsa_8[7], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_68 = iMA(Lsa_8[8], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_76 = iMA(Lsa_8[9], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_84 = iMA(Lsa_8[10], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_92 = iMA(Lsa_8[11], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_100 = iMA(Lsa_8[12], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_108 = iMA(Lsa_8[13], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_116 = iMA(Lsa_8[14], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_124 = iMA(Lsa_8[15], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_132 = iMA(Lsa_8[16], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_140 = iMA(Lsa_8[17], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_188 = iMA(Lsa_8[23], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_196 = iMA(Lsa_8[24], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_204 = iMA(Lsa_8[25], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_212 = iMA(Lsa_8[26], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_220 = iMA(Lsa_8[27], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_228 = iMA(Lsa_8[28], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_236 = iMA(Lsa_8[29], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_244 = iMA(Lsa_8[30], runperiod, Lda_12[1], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_252 = iMA(Lsa_8[2], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_260 = iMA(Lsa_8[3], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_268 = iMA(Lsa_8[4], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_276 = iMA(Lsa_8[5], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_284 = iMA(Lsa_8[6], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_292 = iMA(Lsa_8[7], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_300 = iMA(Lsa_8[8], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_308 = iMA(Lsa_8[9], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_316 = iMA(Lsa_8[10], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_324 = iMA(Lsa_8[11], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_332 = iMA(Lsa_8[12], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_340 = iMA(Lsa_8[13], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_348 = iMA(Lsa_8[14], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_356 = iMA(Lsa_8[15], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_364 = iMA(Lsa_8[16], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_372 = iMA(Lsa_8[17], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_420 = iMA(Lsa_8[23], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_428 = iMA(Lsa_8[24], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_436 = iMA(Lsa_8[25], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_444 = iMA(Lsa_8[26], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_452 = iMA(Lsa_8[27], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_460 = iMA(Lsa_8[28], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_468 = iMA(Lsa_8[29], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
            ima_476 = iMA(Lsa_8[30], runperiod, Lda_12[2], 0, MODE_EMA, PRICE_CLOSE, bars_484);
          G_ibuf_92[bars_484] = SDSFatman1(Gi_124, ima_20, ima_28, ima_36, ima_44, ima_84, ima_252, ima_260, ima_268, ima_276, ima_316);
          G_ibuf_96[bars_484] = SDSFatman2(Gi_124, ima_44, ima_52, ima_60, ima_68, ima_92, ima_276, ima_284, ima_292, ima_300, ima_324);
          G_ibuf_100[bars_484] = SDSFatman3(Gi_124, ima_28, ima_60, ima_76, ima_108, ima_132, ima_260, ima_292, ima_308, ima_340, ima_364);
          G_ibuf_104[bars_484] = SDSFatman4(Gi_124, ima_36, ima_68, ima_116, ima_124, ima_132, ima_268, ima_300, ima_348, ima_356, ima_364);
          G_ibuf_108[bars_484] = SDSFatman5(Gi_124, ima_20, ima_52, ima_76, ima_100, ima_124, ima_252, ima_284, ima_308, ima_332, ima_356);
          G_ibuf_112[bars_484] = SDSFatman6(Gi_124, ima_84, ima_92, ima_100, ima_108, ima_116, ima_316, ima_324, ima_332, ima_340, ima_348);
          G_ibuf_116[bars_484] = SDSFatman7(Gi_124, ima_140, ima_228, ima_236, ima_244, ima_20, ima_372, ima_460, ima_468, ima_476, ima_252);
          G_ibuf_120[bars_484] = SDSFatman8(Gi_124, ima_188, ima_196, ima_204, ima_212, ima_220, ima_420, ima_428, ima_436, ima_444, ima_452);
         }
      }
      Li_488 = iBars(Symbol(),runperiod) - IndicatorCounted();
   }
   if (EveryTick == false) {
      disp = 1;
   } else {
      disp = 0;
   }

   CreateText("AUD"+runperiod,winnum,"AUD "+(int)G_ibuf_92[disp],6,"Tahoma Narrow",Red,Time[0],G_ibuf_92[disp]+1,true);
   CreateText("GBP"+runperiod,winnum,"GBP "+(int)G_ibuf_96[disp],6,"Tahoma Narrow",Orange,Time[0],G_ibuf_96[disp]+1,true);
   CreateText("JPY"+runperiod,winnum,"JPY "+(int)G_ibuf_100[disp],6,"Tahoma Narrow",Purple,Time[0],G_ibuf_100[disp]+1,true);
   CreateText("USD"+runperiod,winnum,"USD "+(int)G_ibuf_104[disp],6,"Tahoma Narrow",DarkTurquoise,Time[0],G_ibuf_104[disp]+1,true);
   CreateText("CAD"+runperiod,winnum,"CAD "+(int)G_ibuf_108[disp],6,"Tahoma Narrow",Yellow,Time[0],G_ibuf_108[disp]+1,true);
   CreateText("EUR"+runperiod,winnum,"EUR "+(int)G_ibuf_112[disp],6,"Tahoma Narrow",Lime,Time[0],G_ibuf_112[disp]+1,true);
   CreateText("CHF"+runperiod,winnum,"CHF "+(int)G_ibuf_116[disp],6,"Tahoma Narrow",White,Time[0],G_ibuf_116[disp]+1,true);
   CreateText("NZD"+runperiod,winnum,"NZD "+(int)G_ibuf_120[disp],6,"Tahoma Narrow",Blue,Time[0],G_ibuf_120[disp]+1,true);
   ChartRedraw();
   return (0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CreateText(string TextName, int Window, string LabelText, int FontSz, string FontName, color TextColor, datetime Time1, double Price1, bool del)
  {
   if (del == true) ObjectDelete(TextName);

   if (EveryTick == true)
      Time1 = Time1 + Period() * 60;

   if(ObjectFind(TextName)!=0)
     {
      ObjectCreate(TextName, OBJ_TEXT, Window, Time1, Price1);
      ObjectSetText(TextName, LabelText, FontSz, FontName, TextColor);
     }
   else
      ObjectMove(TextName, 0, Time1, Price1);
  }
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_CLICK)
     {

      string clickedChartObject=ObjectGetString(0,sparam,OBJPROP_TEXT);
      string clickedObjectName = sparam;

      if (clickedChartObject == "Close") {
            ChartClose(0);
         return;
      }
      for (int i=0;i<9;i++) {
         if (clickedChartObject == butname[i]) {
            ChartSetSymbolPeriod(0,Symbol(),but[i]);
            return;
         }  
      }
   }
}
//+------------------------------------------------------------------+
void resizeWindow() {


int wndh = WindowHandle(Symbol(),Period());
   if (wndh == -1)
      return;
int wndhp = GetParent(wndh);
   if (wndhp == -1)
      return;

int wnds = GetWindowLongW(wndhp,GWL_STYLE);

   wnds &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
//   wnds &= WS_THINFRAME;

   SetWindowLongW(wndhp,GWL_STYLE,wnds);
   SetWindowPos(wndhp,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);      
   SetWindowPos(wndhp,0,100,100,800,600,SWP_NOZORDER);      
   
}  
bool allowed() {

int vars = GlobalVariablesTotal();

bool isallowed = false;

   for (int i=0;i<vars;i++) {
      if (StringFind(GlobalVariableName(i),"BDM$CHART$") != -1)
            isallowed = true;;
      if (StringFind(GlobalVariableName(i),"DASH$CHART$") != -1)
            isallowed = true;;
   }

   return(isallowed);
}
