//============================================================================================================================================================
//+------------------------------------------------------------------+
//|                                                   TAURUS PROJETO |
//|                                         CRIADOR> IVONALDO FARIAS |
//|                             CONTATO INSTRAGAM>> @IVONALDO FARIAS |
//|                                   CONTATO WHATSAPP 21 97278-2759 |
//|                                  TELEGRAM E O MESMO NUMERO ACIMA |
//| INDICADOR TAURUS                                            2022 |
//+------------------------------------------------------------------+
//============================================================================================================================================================
#property indicator_chart_window
#property indicator_buffers 33
//============================================================================================================================================================
#define KEY_DELETE 46
#define READURL_BUFFER_SIZE   100
#define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
#import "kernel32.dll"
int  FindFirstFileW(string Path, ushort &Answer[]);
bool FindNextFileW(int handle,  ushort &Answer[]);
bool FindClose(int handle);
bool GetVolumeInformationW(string,string,uint,uint&[],uint,uint,string,uint);
#import
//============================================================================================================================================================
#include <WinUser32.mqh>
//============================================================================================================================================================
//CORRETORAS DISPONÍVEIS
enum corretora_price
  {
   EmTodas = 1, //Todas
   EmIQOption = 2, //IQ Option
   EmSpectre = 3, //Spectre
   EmBinary = 4, //Binary
   EmGC = 5, //Grand Capital
   EmBinomo = 6, //Binomo
   EmOlymp = 7, //Olymp Trade
   EmQuotex = 8, //Quotex
   EmAlpari = 9, //Alpari
   EmPocket = 10, //Pocket Option
   EmPrice = 11, //Price Tester
   EmBitness = 12, //Bitness
   EmCapitalBear = 13, //Capital Bear
   EmProTester = 14, //Pro Tester
   EmExnova = 15, //Exnova
   EmBinarium = 16, //Binarium
   EmMangoTrade = 17, //MangoTrade
   EmEtradeTrade = 18 //Etrade
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum broker
  {
   Todos = 0,   //Todas
   IQOption = 1,
   Binary = 2,
   Spectre = 3,
   Alpari = 4,
   InstaBinary = 5
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum corretora
  {
   All = 0,      //Todas
   IQ = 1,       //IQ Option
   Bin = 2,      //Binary
   Spectree = 3, //Spectre
   GC = 4,       //Grand Capital
   Binomo = 5,   //Binomo
   Olymp = 6,    //Olymp Trade
   Quotex = 7    //Quotex
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum tipo_expiracao
  {
   TEMPO_FIXO = 0, //Tempo Fixo!
   RETRACAO = 1    //Tempo Do Time Frame!
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum sinal
  {
   MESMA_VELA = 0,  //MESMA VELA 0  //PROIBIDO COPY 3
   PROXIMA_VELA = 1 //PROXIMA VELA
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum signaltype
  {
   IntraBar = 0,          //Intrabar
   ClosedCandle = 1       //On new bar
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum martintype
  {
   NoMartingale = 0,             // Sem Martingale (No Martingale)
   OnNextExpiry = 1,             // Próxima Expiração (Next Expiry)
   OnNextSignal = 2,             // Próximo Sinal (Next Signal)
   Anti_OnNextExpiry = 3,        // Anti-/ Próxima Expiração (Next Expiry)
   Anti_OnNextSignal = 4,        // Anti-/ Próximo Sinal (Next Signal)
   OnNextSignal_Global = 5,      // Próximo Sinal (Next Signal) (Global)
   Anti_OnNextSignal_Global = 6  // Anti-/ Próximo Sinal (Global)
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum TaurusChave
  {
   desativado=0, //desativado Off
   ativado=1     //ativado On
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//--- Seletor de Corretora
enum CorretoraG3X
  {
   IQOPTION1 = 0, //IQ OPTION
   BINOMO1   = 1, //BINOMO
   QUOTEX1   = 2, //QUOTEX
   BINARY1   = 3, //BINARY
   OLYMP1    = 4, //OLYMP
   BITNESS1  = 5, //BITNESS
   TODAS1    = 6, //TODAS
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum TipoFechamentoG3X
  {
   FIM_DA_VELA1    = 0,//FIM DA VELA
   TEMPO_CORRIDO1  = 1,//TEMPO CORRIDO
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum Antercipacao
  {
   EntradaNormal    = 0,//Entrada Normal Na Seta ?
   EntradaNoPre  = 1,   //Entrada No Pre Alerta antecipação ?
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum OpcaoSinal
  {
   MesmaVela=0,  //Mesma Vela ?
   ProximaVela=1 //Proxima Vela ?
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
enum ft
  {
   Desativado = 0, // Desativado
   Simples = 1, // Simples
   Ref = 2, // Referência
  };
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
extern string ________BACKTESTE____________________ = "-=-=-=-=-=-=-= Painel Backteste! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
TaurusChave AtivaPainel  = ativado;             //Ativa Painel de Estatísticas?
extern int  Velas  = 288;                       //Catalogação Por Velas Do backtest ?
int PeriodSecAutoRefresh = 10;                  //PeriodSecAutoRefresh ?
static int tic= 0;                              //tic ?
extern TaurusChave  EntraAposUmLoss  = desativado;//Entra Apos Um Loss ?
input TaurusChave VerticalLines = desativado;   //Linhas Vertical Win x Loss ?
input string NomeDoSinal =""; //Sinal para os Robos (NOME) ?
string SignalName  ="TaurusVulcano 3.0"+NomeDoSinal;//Nome do Sinal para Robos (Opcional)
input TaurusChave AlertsMessage  = desativado;  //Alerta Dos Sinais ?
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                   DEFINIÇÃO DOS TRADES                           |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
input string  __________DEFINIÇÃO_DOS_TRADES_______________________ = "-=-=-=-=-=-=-=- Filtro De Acerto! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
input TaurusChave Mãofixa   = desativado;          // Aplica Filtro Mão Fixa ?
input double FiltroMãofixa = 60;                   // Manda Sinal Acima % Mão fixa?
input TaurusChave AplicaFiltroNoGale = desativado; // Aplica Filtro No Martingale G1?
input double FiltroMartingale = 80;                // Manda Sinal Acima % Martingale G1 ?
input TaurusChave AplicaFiltroNoGale2 = desativado;// Aplica Filtro No Martingale G2?
input double FiltroMartingale2 = 90;               // Manda Sinal Acima % Martingale G2 ?
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                   DEFINIÇÃO DOS TRADES                           |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
extern string _______Estrategias____________________ = "-=-=-=-=-=-= Estrategias Vulcano! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
extern TaurusChave VulcanoRevercao = ativado; // Vulcano Revercao Estrategia Pura ?
extern TaurusChave TaurusEnigma = desativado; // Taurus Padrao Enigma OTC, OB?
input OpcaoSinal VelaSinal = ProximaVela;     // Mesma Vela Ou Proxima Enigma ?
extern int    Sensitivity = 0;                // Sensitivity Sinais Enigma ?
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                   DEFINIÇÃO DOS TRADES                           |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
extern string ________FILTROS____________________ = "-=-=-=-=-=-= Filtros Vulcano Ativo! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
extern TaurusChave HILL = ativado;              // Pode Recalcula HILL Modificador ?
extern TaurusChave FILTROVORTEX = desativado;   // Pode Recalcula VORTEX Modificador ?
extern TaurusChave VulcanoValue = desativado;   // Vulcano ValueChart Modificador ?
input TaurusChave   Confirma = desativado;      // Confirma VelaCor Oposta Pro Sinal ?
input TaurusChave Bloquea = desativado ;        // Bloquea velas Mesma Cor ?
input int quantidade = 3;                       // Quantidade De velas ?
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                   DEFINIÇÃO DOS TRADES                           |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
input string  __________DEFINIÇÃO_______________________ = "-=-=-=-=-=-=- Filtro De Tendencia! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
extern ft Filtro = Desativado; // Filtro de Média ?
extern int Media = 20; // Período Filtro (Referência)
extern int Fast = 5; // Período Média Rápida
//+------------------------------------------------------------------+
//|                 CONCTOR  MT2  TAURUS                             |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
input string _____________ROBOS____________________ = "-=-=-=-=-=-=- Conectores Interno! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-= Automatizadores =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
input Antercipacao Tempo  = EntradaNormal;        //Antecipação Pras Corretoras ?
input int tempoad = 4;                            //Tempo antecipação Em Segundos ?
input int ExpiryMinutes = 1;                      //Tempo De Expiração Pro Robos ?
input int MaxDelay = 5;                           //Delay Máximo Do Sinal - 0 = Desativar ?
input string  _________MX2___________________ = "-=-=-=-=-=-=-=-=-=-=- MX2 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
input TaurusChave OperarComMX2       = desativado;//Automatizar com MX2 TRADING ?
tipo_expiracao TipoExpiracao = TEMPO_FIXO;        //Tipo De Entrada No MX2 TRADING ?
input string  _______PRICEPRO___________________ = "-=-=-=-=-=-=-=-=-= PRICEPRO =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
input TaurusChave OperarComPricePro  = desativado;  //Automatizar com PRICEPRO ?
input corretora_price PriceProCorretora = EmTodas;  //Corretora PRICEPRO ?
input string  _________MT2___________________ = "-=-=-=-=-=-=-=-=-=-=- MT2 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
input TaurusChave OperarComMT2       = desativado;//Automatizar com MT2 ?
input martintype MartingaleType = OnNextExpiry;  //Martingale  (para MT2) ?
input double MartingaleCoef = 2.0;               //Coeficiente do Martingale MT2 ?
input int    MartingaleSteps = 0;                //MartinGales Pro MT2 ?
input double TradeAmount = 2;                    //Valor do Trade  Pro MT2 ?
input string  _________G3X1___________________ = "-=-=-=-=-=-=-=-=-=-=- G3X -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
input TaurusChave OperarComG3X1      = desativado;  //Automatizar com G3X TRADING ?
input CorretoraG3X      Corretora1   =   TODAS1;    //Escolher Corretora ?
input TipoFechamentoG3X Fechamento1  =   TEMPO_CORRIDO1; //Tipo de Fechamento do Trade ?
//============================================================================================================================================================
bool ativarantidelay = ativado;                     //Ativar AntiDelay ?
//============================================================================================================================================================
//+------------------------------------------------------------------+
//|                      CONCTOR  MX2                                |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
string sinalNome = SignalName;                 //Nome do Sinal para MX2 TRADING ?
sinal SinalEntradaMX2 = MESMA_VELA;            //Entrar na ?
corretora CorretoraMx2 = All;                  //Corretora ?
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                CONCTOR  SIGNAL SETTINGS MT2                      |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
string _____________MT2_____________= "======= SIGNAL SETTINGS MT2 ================================================================================="; //=================================================================================";
broker Broker = Todos;        //Corretora
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                   CONFIGURAÇÕES_GERAIS                           |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
string ___________CONFIGURAÇÕES_GERAIS_____________= "===== CONFIGURAÇÕES_GERAIS ======================================================================"; //=================================================================================";
TaurusChave   AlertsSound = desativado;              //Alerta Sonoro?
string  SoundFileUp          = "alert2.wav";    //Som do alerta CALL
string  SoundFileDown        = "alert2.wav";    //Som do alerta PUT
string  AlertEmailSubject    = "";              //Assunto do E-mail (vazio = desabilita).
TaurusChave SendPushNotification = desativado;       //Notificações por PUSH?
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int trendPeriod = 2; // Período TDF 1
int trendPeriod2 = 3; // Período TDF 2
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int    PeríodoRSI  = 9;
int    Divisor = 5;
int    PeríodoDesvio = 70;
double Desvio = 0.8;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
double RSI[];
double DevBuffer[];
double UpperBuffer[];
double LowerBuffer[];
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//---- buffers
double up[];
double down[];
double CrossUp[];
double CrossDown[];
double AntilossUp[];
double AntilossDn[];
double BufferSignalUp[];
double BufferSignalDn[];
double MA[];
double MA2[];
double VerticalLine[];
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
double MMABuffer[], SMMABuffer[], TDFBuffer[],TDF[];
double MMABuffer2[], SMMABuffer2[], TDFBuffer2[],TDF2[];
double MMABuffer3[], SMMABuffer3[], TDFBuffer3[],TDF3[];
datetime timet;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
string TaurusProtector[256];
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
datetime LastSignal;
datetime TimeBarEntradaUp;
datetime TimeBarEntradaDn;
datetime TimeBarUp;
datetime TimeBarDn;
int Sig_UpCall0 = 0;
int Sig_DnPut0 = 0;
int Sig_Up0 = 0;
int Sig_Dn0 = 0;
int Sig_Up5 = 0;
int Sig_Dn5 = 0;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
double win[],loss[],wg[],ht[],wg2[],ht2[],wg1,ht1,WinRate1,WinRateGale1,WinRateGale22,ht22,wg22,mb;
double Barcurrentopen,Barcurrentclose,Barcurrentopen1,Barcurrentclose1,Barcurrentopen2,Barcurrentclose2,m1,m2,lbk,wbk;
string WinRate;
string WinRateGale;
string WinRateGale2;
datetime tvb1;
int g;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
// Variables
int lbnum = 0;
datetime sendOnce;
string asset;
string signalID;
int mID = 0;      // ID (não altere)
TaurusChave initgui = desativado;
bool TaurusSetas=ativado;
extern string _______________________________________ = "-=-=-=-=-=-=- TaurusVulcano 3.0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
bool LIBERAR_ACESSO=desativado;
string chave;
int dist;
static int largura_tela = 0, altura_tela = 0;
int candlesup,candlesdn;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
#import "mt2trading_library.ex4"   // Please use only library version 13.52 or higher !!!
bool mt2trading(string symbol, string direction, double amount, int expiryMinutes);
bool mt2trading(string symbol, string direction, double amount, int expiryMinutes, string signalname);
bool mt2trading(string symbol, string direction, double amount, int expiryMinutes, martintype martingaleType, int martingaleSteps, double martingaleCoef, broker myBroker, string signalName, string signalid);
int  traderesult(string signalid);
int getlbnum();
bool chartInit(int mid);
int updateGUI(bool initialized, int lbnum, string indicatorName, broker Broker, bool auto, double amount, int expiryMinutes);
int processEvent(const int id, const string& sparam, bool auto, int lbnum);
void showErrorText(int lbnum, broker Broker, string errorText);
void remove(const int reason, int lbnum, int mid);
void cleanGUI();
#import
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
#import "user32.dll"
int      PostMessageA(int hWnd,int Msg,int wParam,int lParam);
int      GetWindow(int hWnd,int uCmd);
int      RegisterWindowMessageA(string a0);
int      GetParent(int hWnd);
#import
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
#import "MX2Trading_library.ex4"
bool mx2trading(string par, string direcao, int expiracao, string sinalNome, int Signaltipo, int TipoExpiracao, string TimeFrame, string mID, string Corretora);
#import
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
#import "PriceProLib.ex4"
void TradePricePro(string ativo, string direcao, int expiracao, string nomedosinal, int martingales, int martingale_em, int data_atual, int corretora);
#import
//+------------------------------------------------------------------+
//--- Importa a Lib
#import "G3X_Lib.ex4"
bool G3X(string par, string direcao, int timeframe, string nome_sinal, int segundos, int corretora, int tipo_fechamento);
#import
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
#import "Kernel32.dll"
bool GetVolumeInformationW(string,string,uint,uint&[],uint,uint,string,uint);
#import
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//ATENÇÃO !!!
//CHAVE DE SEGURANÇA DO INDICADOR POR TRAVA CID NUNCA ESQUEÇA DE ATIVA QUANDO POR EM TESTE AOS CLIENTES!!!!
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
bool AtivaChaveDeSeguranca = FALSE; // Ativa Chave De Segurança !!!!
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//CHAVE DE SEGURANÇA DO INDICADOR POR TRAVA CID NUNCA ESQUEÇA DE ATIVA QUANDO POR EM TESTE AOS CLIENTES!!!!
//ATENÇÃO !!!
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int OnInit()
  {

//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   for(int i = 0; i < 256; i++)
     {
      TaurusProtector[i] = CharToStr(i);
     }
   PeriodSecAutoRefresh*=1000;
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(!TerminalInfoInteger(TERMINAL_DLLS_ALLOWED))
     {
      Alert("Permita importar dlls!");
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
// Relogio
   ObjectCreate("Time_Remaining",OBJ_LABEL,0,0,0);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   IndicatorBuffers(40);
   SetIndexStyle(0, DRAW_ARROW, EMPTY,1,clrWhiteSmoke);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, up);
   SetIndexLabel(0, "SetaCall");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(1, DRAW_ARROW, EMPTY,1,clrWhiteSmoke);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, down);
   SetIndexLabel(1, "SetaPut");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(2, DRAW_ARROW, EMPTY,1,clrWhiteSmoke);
   SetIndexArrow(2, 164);
   SetIndexBuffer(2, CrossUp);
   SetIndexLabel(2, "PréCall");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(3, DRAW_ARROW, EMPTY,1,clrWhiteSmoke);
   SetIndexArrow(3, 164);
   SetIndexBuffer(3, CrossDown);
   SetIndexLabel(3, "PréPut");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(4, DRAW_ARROW, EMPTY, 2,clrLime);
   SetIndexArrow(4, 252);
   SetIndexBuffer(4, win);
   SetIndexLabel(4, "Win");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(5, DRAW_ARROW, EMPTY, 2,clrRed);
   SetIndexArrow(5, 251);
   SetIndexBuffer(5, loss);
   SetIndexLabel(5, "Loss");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(6, DRAW_ARROW, EMPTY,0,clrLime);
   SetIndexArrow(6, 252);
   SetIndexBuffer(6, wg);
   SetIndexLabel(6, "WinG1");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(7, DRAW_ARROW, EMPTY, 0,clrRed);
   SetIndexArrow(7, 251);
   SetIndexBuffer(7, ht);
   SetIndexLabel(7, "HitG1");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(8, DRAW_ARROW, EMPTY, 0,clrNONE);
   SetIndexArrow(8, 252);
   SetIndexBuffer(8, wg2);
   SetIndexLabel(8, "WinG2");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(9, DRAW_ARROW, EMPTY, 0,clrNONE);
   SetIndexArrow(9, 251);
   SetIndexBuffer(9, ht2);
   SetIndexLabel(9, "HitG2");
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(10, DRAW_ARROW, EMPTY, 0, clrWhiteSmoke);
   SetIndexArrow(10, 233);
   SetIndexBuffer(10, AntilossUp);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(11, DRAW_ARROW, EMPTY, 0, clrWhiteSmoke);
   SetIndexArrow(11, 234);
   SetIndexBuffer(11, AntilossDn);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(12,DRAW_NONE);
   SetIndexBuffer(12,MMABuffer);
   SetIndexStyle(13,DRAW_NONE);
   SetIndexBuffer(13,SMMABuffer);
   SetIndexStyle(14,DRAW_NONE);
   SetIndexBuffer(14,TDFBuffer);
   SetIndexStyle(15,DRAW_NONE);
   SetIndexBuffer(15,TDF);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(16,DRAW_NONE);
   SetIndexBuffer(16,MMABuffer2);
   SetIndexStyle(17,DRAW_NONE);
   SetIndexBuffer(17,SMMABuffer2);
   SetIndexStyle(18,DRAW_NONE);
   SetIndexBuffer(18,TDFBuffer2);
   SetIndexStyle(19,DRAW_NONE);
   SetIndexBuffer(19,TDF2);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(20,DRAW_NONE);
   SetIndexBuffer(20,MMABuffer3);
   SetIndexStyle(21,DRAW_NONE);
   SetIndexBuffer(21,SMMABuffer3);
   SetIndexStyle(22,DRAW_NONE);
   SetIndexBuffer(22,TDFBuffer3);
   SetIndexStyle(23,DRAW_NONE);
   SetIndexBuffer(23,TDF3);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(24,DRAW_NONE);
   SetIndexBuffer(24,RSI);
   SetIndexStyle(25,DRAW_NONE);
   SetIndexBuffer(25,DevBuffer);
   SetIndexStyle(26,DRAW_NONE);
   SetIndexBuffer(26,UpperBuffer);
   SetIndexStyle(27,DRAW_NONE);
   SetIndexBuffer(27,LowerBuffer);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(28, DRAW_LINE, EMPTY,0,clrNONE);
   SetIndexBuffer(28, BufferSignalUp);
   SetIndexStyle(29, DRAW_LINE, EMPTY,0,clrNONE);
   SetIndexBuffer(29, BufferSignalDn);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(30, DRAW_LINE, EMPTY,0,clrYellow);
   SetIndexBuffer(30,MA);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexStyle(31, DRAW_LINE, EMPTY,0,clrWhite);
   SetIndexBuffer(31,MA2);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   SetIndexBuffer(32,VerticalLine);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   IndicatorShortName("TaurusVulcano");
   ChartSetInteger(0,CHART_MODE,CHART_CANDLES);
   ChartSetInteger(0,CHART_FOREGROUND,false);
   ChartSetInteger(0,CHART_SHIFT,true);
   ChartSetInteger(0,CHART_AUTOSCROLL,true);
   ChartSetInteger(0,CHART_SCALEFIX,false);
   ChartSetInteger(0,CHART_SCALEFIX_11,false);
   ChartSetInteger(0,CHART_SHOW_GRID,FALSE);
   ChartSetInteger(0,CHART_COLOR_GRID,clrDarkSlateGray);
   ChartSetInteger(0,CHART_SCALE_PT_PER_BAR,true);
   ChartSetInteger(0,CHART_SHOW_OHLC,false);
   ChartSetInteger(0,CHART_SCALE,3);
   ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrBlack); //32,32,32
   ChartSetInteger(0,CHART_COLOR_FOREGROUND,clrWhite);
//+------------------------------------------------------------------+
   ChartSetInteger(0,CHART_COLOR_CHART_UP,clrLime);
   ChartSetInteger(0,CHART_COLOR_CHART_DOWN,clrMaroon);
   ChartSetInteger(0,CHART_COLOR_CHART_LINE,clrGray);
   ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,clrLime);
   ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,clrMaroon);
   ChartSetInteger(0,CHART_SHOW_DATE_SCALE,true);
   ChartSetInteger(0,CHART_SHOW_PRICE_SCALE,true);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(ChartPeriod() == 1)
     {
      dist = 5;
     }
   if(ChartPeriod() == 5)
     {
      dist = 15;
     }
   if(ChartPeriod() == 15)
     {
      dist = 25;
     }
   if(ChartPeriod() == 30)
     {
      dist = 35;
     }
   if(ChartPeriod() == 60)
     {
      dist = 45;
     }
   if(ChartPeriod() == 240)
     {
      dist = 45;
     }
   if(ChartPeriod() == 1440)
     {
      dist = 45;
     }
   if(ChartPeriod() == 10080)
     {
      dist = 45;
     }
   if(ChartPeriod() == 43200)
     {
      dist = 45;
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   ObjectCreate("Projeto",OBJ_LABEL,0,0,0,0,0);
   ObjectSetText("Projeto","TaurusVulcano 3.0", 14, "Time New Roman",clrWhiteSmoke);
   ObjectSet("Projeto",OBJPROP_XDISTANCE,0);
   ObjectSet("Projeto",OBJPROP_ZORDER,9);
   ObjectSet("Projeto",OBJPROP_BACK,false);
   ObjectSet("Projeto",OBJPROP_YDISTANCE,0);
   ObjectSet("Projeto",OBJPROP_CORNER,2);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   EventSetTimer(1);
   chartInit(mID);  // Chart Initialization
   lbnum = getlbnum(); // Generating Special Connector ID

// Initialize the time flag
   sendOnce = TimeCurrent();
// Generate a unique signal id for MT2IQ signals management (based on timestamp, chart id and some random number)
   MathSrand(GetTickCount());
   if(MartingaleType == OnNextExpiry)
      signalID = IntegerToString(GetTickCount()) + IntegerToString(MathRand()) + " OnNextExpiry";   // For OnNextSignal martingale will be indicator-wide unique id generated
   else
      if(MartingaleType == Anti_OnNextExpiry)
         signalID = IntegerToString(GetTickCount()) + IntegerToString(MathRand()) + " AntiOnNextExpiry";   // For OnNextSignal martingale will be indicator-wide unique id generated
      else
         if(MartingaleType == OnNextSignal)
            signalID = IntegerToString(ChartID()) + IntegerToString(AccountNumber()) + IntegerToString(mID) + " OnNextSignal";   // For OnNextSignal martingale will be indicator-wide unique id generated
         else
            if(MartingaleType == Anti_OnNextSignal)
               signalID = IntegerToString(ChartID()) + IntegerToString(AccountNumber()) + IntegerToString(mID) + " AntiOnNextSignal";   // For OnNextSignal martingale will be indicator-wide unique id generated
            else
               if(MartingaleType == OnNextSignal_Global)
                  signalID = "MARTINGALE GLOBAL On Next Signal";   // For global martingale will be terminal-wide unique id generated
               else
                  if(MartingaleType == Anti_OnNextSignal_Global)
                     signalID = "MARTINGALE GLOBAL Anti On Next Signal";   // For global martingale will be terminal-wide unique id generated
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
// Symbol name should consists of 6 first letters
   if(StringLen(Symbol()) >= 6)
      asset = StringSubstr(Symbol(),0,6);
   else
      asset = Symbol();
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(StringLen(Symbol()) > 6)
     {
      sendOnce = TimeGMT();
     }
   else
     {
      sendOnce = TimeCurrent();
     }
   return(INIT_SUCCEEDED);
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void deinit()
  {
   ObjectDelete(0,"Time_Remaining");
   ObjectsDeleteAll(0,OBJ_VLINE);
   ObjectsDeleteAll(0,OBJ_LABEL);
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|   MERCADO ABERTO MAIS SINAL OTC ORIGINAL                         |
//+------------------------------------------------------------------+
double sellSignal(int ai_0)
  {
   bool li_4 = TRUE;
   if(Sensitivity > 2)
      if(iHigh(Symbol(), Period(), ai_0 + 1) >= iHigh(Symbol(), Period(), ai_0 + 5))
         li_4 = FALSE;
   if(Sensitivity > 1)
      if(iHigh(Symbol(), Period(), ai_0 + 5) >= iHigh(Symbol(), Period(), ai_0 + 4))
         li_4 = FALSE;
   if(Sensitivity > 0)
      if(iHigh(Symbol(), Period(), ai_0 + 4) >= iHigh(Symbol(), Period(), ai_0 + 3))
         li_4 = FALSE;
   if(li_4)
     {
      if(iClose(Symbol(), Period(), ai_0 + 2) < iHigh(Symbol(), Period(), ai_0 + 1))
         if(iClose(Symbol(), Period(), ai_0 + 1) < iLow(Symbol(), Period(), ai_0 + 2))
            return (iHigh(Symbol(), Period(), ai_0 + 1) + 2);
     }
   return (0);
  }
//+------------------------------------------------------------------+
//|   MERCADO ABERTO MAIS SINAL OTC ORIGINAL                         |
//+------------------------------------------------------------------+
double buySignal(int ai_0)
  {
   bool li_4 = TRUE;
   if(Sensitivity > 2)
      if(iLow(Symbol(), Period(), ai_0 + 1) <= iLow(Symbol(), Period(), ai_0 + 5))
         li_4 = FALSE;
   if(Sensitivity > 1)
      if(iLow(Symbol(), Period(), ai_0 + 5) <= iLow(Symbol(), Period(), ai_0 + 4))
         li_4 = FALSE;
   if(Sensitivity > 0)
      if(iLow(Symbol(), Period(), ai_0 + 4) <= iLow(Symbol(), Period(), ai_0 + 3))
         li_4 = FALSE;
   if(li_4)
     {
      if(iClose(Symbol(), Period(), ai_0 + 2) > iLow(Symbol(), Period(), ai_0 + 1))
         if(iClose(Symbol(), Period(), ai_0 + 1) > iHigh(Symbol(), Period(), ai_0 + 2))
            return (iLow(Symbol(), Period(), ai_0 + 1) - 2);
     }
   return (0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(MartingaleType == NoMartingale || MartingaleType == OnNextExpiry || MartingaleType == Anti_OnNextExpiry)
      signalID = IntegerToString(GetTickCount()) + IntegerToString(MathRand());   // For NoMartingale or OnNextExpiry martingale will be candle-wide unique id generated
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//Se achar a dll, retorna um alerta de não liberado.. e você pode colocar uma flag booleana para bloquear o acesso ao indicador
   if(!ScanMaliciousFiles())

      if(TimeGMT()>D'29.09.2029')
        {
         Alert(TaurusProtector[97] + TaurusProtector[99] + TaurusProtector[101] + TaurusProtector[115] + TaurusProtector[115] + TaurusProtector[32] + TaurusProtector[100] + TaurusProtector[101] + TaurusProtector[110] + TaurusProtector[105] + TaurusProtector[101] + TaurusProtector[100]);
         ChartIndicatorDelete(0,0,"TaurusVulcano");
         Alert("TaurusVulcano -> Não Liberado Suporte Pelo Telegram @TaurusIndicadores!!!");
         return(INIT_FAILED);
        }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(tic==0)
      tic=GetTickCount();
   int t=GetTickCount();
   if(MathAbs(t-tic)>PeriodSecAutoRefresh)
     {
      PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33324, 0);
      PostMessageA(WindowHandle(Symbol(), 0), RegisterWindowMessageA("MetaTrader4_Internal_Message"), 2, 1);
      tic=GetTickCount();
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(WindowExpertName()!="TaurusVulcano")
     {
      Alert("Não mude o nome do indicador!");
        {
         ChartIndicatorDelete(0,0,"TaurusVulcano");
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   int iNewBars, iCountedBars, i,J,k;

// Get unprocessed ticks
   iCountedBars=IndicatorCounted();
   if(iCountedBars < 0)
      return (-1);
   if(iCountedBars>0)
      iCountedBars--;
   iNewBars=Bars-iCountedBars;
   if(iNewBars > Velas)
      iNewBars=Velas;

   for(i=iNewBars; i>=0; i--)
      RSI[i] = iRSI(NULL,0,PeríodoRSI,PRICE_CLOSE,i);
   for(i=iNewBars; i>=0; i--)
     {
      if(!TaurusSetas)
        {
         ArrayInitialize(CrossUp,EMPTY_VALUE);
         ArrayInitialize(CrossDown,EMPTY_VALUE);
         ArrayInitialize(up,EMPTY_VALUE);
         ArrayInitialize(down,EMPTY_VALUE);
         ArrayInitialize(win,EMPTY_VALUE);
         ArrayInitialize(loss,EMPTY_VALUE);
         ArrayInitialize(wg,EMPTY_VALUE);
         ArrayInitialize(ht,EMPTY_VALUE);
         ArrayInitialize(wg2,EMPTY_VALUE);
         ArrayInitialize(ht2,EMPTY_VALUE);
         ArrayInitialize(VerticalLine,EMPTY_VALUE);
         ObjectsDeleteAll();
        }
      //+------------------------------------------------------------------+
      if(Bloquea)
        {
         candlesup=0;
         candlesdn=0;
         int j;

         for(j = i+quantidade+1 ; j>=i; j--)
           {
            if(close[j]>=open[j]) // && close[j+2] > open[j+2])
               candlesup++;
            else
               candlesup=0;
            if(close[j]<=open[j]) // && close[j+2] < open[j+2])
               candlesdn++;
            else
               candlesdn = 0;
           }
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------

      //+------------------------------------------------------------------+
      double dev  = iStdDevOnArray(RSI,0,PeríodoDesvio,0,MODE_SMA,i);
      double sum  = (Divisor+1)*RSI[i];
      double sumw = (Divisor+1);
      for(J=1, k=Divisor; J<=Divisor; J++, k--)
        {
         sum  += k*RSI[i+J];
         sumw += k;
         if(J<=i)
           {
            sum  += k*RSI[i-J];
            sumw += k;
           }
        }
      DevBuffer[i] = sum/sumw;
      UpperBuffer[i] = DevBuffer[i]+dev*Desvio;
      LowerBuffer[i] = DevBuffer[i]-dev*Desvio;
      //+------------------------------------------------------------------+
      CommentLab(Symbol()+">",0, 0, 0,clrYellow);
      //+------------------------------------------------------------------+
      if(Filtro==1)
        {
         MA[i] = iMA(NULL,0,Media,0,MODE_EMA,PRICE_CLOSE,i);

         if(sinal_buffer(CrossUp[i+1]) && Open[i+1] < MA[i+1])
            CrossUp[i+1] = EMPTY_VALUE;

         if(sinal_buffer(CrossDown[i+1]) && Open[i+1] > MA[i+1])
            CrossDown[i+1] = EMPTY_VALUE;
        }
      else
         if(Filtro==2)
           {
            MA[i] = iMA(NULL,0,Media,0,MODE_EMA,PRICE_CLOSE,i);
            MA2[i] = iMA(NULL,0,Fast,0,MODE_EMA,PRICE_CLOSE,i);

            if(sinal_buffer(CrossUp[i+1]) && MA2[i+1] < MA[i+1])
               CrossUp[i+1] = EMPTY_VALUE;

            if(sinal_buffer(CrossDown[i+1]) && MA2[i+1] > MA[i+1])
               CrossDown[i+1] = EMPTY_VALUE;
           }
      //+------------------------------------------------------------------+
      BufferSignalDn[i] = sellSignal(i);
      BufferSignalUp[i] = buySignal(i);
      //+------------------------------------------------------------------+
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      double alpha = 2.0 /(trendPeriod+1.0);

      MMABuffer[i]  = iMA(NULL,0,trendPeriod,0,MODE_EMA,PRICE_CLOSE,i);
      SMMABuffer[i] = SMMABuffer[i+1]+alpha*(MMABuffer[i]-SMMABuffer[i+1]);
      double impetmma  = MMABuffer[i]  - MMABuffer[i+1];
      double impetsmma = SMMABuffer[i] - SMMABuffer[i+1];
      double divma     = MathAbs(MMABuffer[i]-SMMABuffer[i])/Point;
      double averimpet = (impetmma+impetsmma)/(2*Point);
      TDFBuffer[i]  = divma*MathPow(averimpet,3);

      double absValue = absHighest(TDFBuffer,trendPeriod*3,i);
      if(absValue > 0)
         TDF[i] = TDFBuffer[i]/absValue;
      else
         TDF[i] =   0.00;
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------

      double alpha2 = 2.0 /(trendPeriod2+1.0);

      MMABuffer2[i]  = iMA(NULL,0,trendPeriod2,0,MODE_EMA,PRICE_CLOSE,i);
      SMMABuffer2[i] = SMMABuffer2[i+1]+alpha2*(MMABuffer2[i]-SMMABuffer2[i+1]);
      double impetmma2  = MMABuffer2[i]  - MMABuffer2[i+1];
      double impetsmma2 = SMMABuffer2[i] - SMMABuffer2[i+1];
      double divma2     = MathAbs(MMABuffer2[i]-SMMABuffer2[i])/Point;
      double averimpet2 = (impetmma2+impetsmma2)/(2*Point);
      TDFBuffer2[i]  = divma2*MathPow(averimpet2,3);

      double absValue2 = absHighest(TDFBuffer2,trendPeriod2*3,i);
      if(absValue2 > 0)
         TDF2[i] = TDFBuffer2[i]/absValue2;
      else
         TDF2[i] =   0.00;
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      double Compra=0, Venda=0;
      if(VulcanoValue)
        {
         Compra = iCustom(NULL,0,"TaurusValueCrart",0,i);
         Venda = iCustom(NULL,0,"TaurusValueCrart",1,i);
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      double VortexUP=0, VortexDN=0;
      if(FILTROVORTEX)
        {
         VortexUP = iCustom(NULL,0,"TaurusFiltro",6,i);
         VortexDN = iCustom(NULL,0,"TaurusFiltro",7,i);
        }
      //+------------------------------------------------------------------+
      //|                             CALL                                 |
      //+------------------------------------------------------------------+
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      if((!VulcanoRevercao || TDF[i] <= -0.99) && (!VulcanoRevercao ||  TDF2[i] <= -0.99)
         && (!HILL || RSI[i] < LowerBuffer[i]) && (!Bloquea || candlesdn < quantidade)
         //+------------------------------------------------------------------+
         && (!TaurusEnigma || BufferSignalDn[i]) && (!Confirma || Close[i]<Open[i])
         //+------------------------------------------------------------------+
         && (!FILTROVORTEX || VortexUP != EMPTY_VALUE) &&(!FILTROVORTEX || VortexUP != 0)
         && (!VulcanoValue || Compra != EMPTY_VALUE) &&(!VulcanoValue || Compra != 0)
         && CrossUp[i+1]==EMPTY_VALUE && CrossDown[i+1]==EMPTY_VALUE
         && up[i+1]==EMPTY_VALUE && down[i+1]==EMPTY_VALUE)
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
        {
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         if(Time[i] > LastSignal + (Period()*0)*60)
           {
            CrossUp[i] = iLow(_Symbol,PERIOD_CURRENT,i)-dist*Point();
            Sig_Up0=1;
           }
        }
      else
        {
         CrossUp[i] = EMPTY_VALUE;
         Sig_Up0=0;
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      //+------------------------------------------------------------------+
      //|                              PUT                                 |
      //+------------------------------------------------------------------+
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      if((!VulcanoRevercao || TDF[i] >= 0.99) && (!VulcanoRevercao || TDF2[i] >= 0.99)
         && (!HILL || RSI[i] > UpperBuffer[i]) && (!Bloquea || candlesup < quantidade)
         //+------------------------------------------------------------------+
         && (!TaurusEnigma || BufferSignalUp[i]) && (!Confirma || Close[i]>Open[i])
         //+------------------------------------------------------------------+
         && (!FILTROVORTEX || VortexDN != EMPTY_VALUE) &&(!FILTROVORTEX || VortexDN != 0)
         && (!VulcanoValue || Venda != EMPTY_VALUE) &&(!VulcanoValue || Venda != 0)
         && CrossUp[i+1]==EMPTY_VALUE && CrossDown[i+1]==EMPTY_VALUE
         && up[i+1]==EMPTY_VALUE && down[i+1]==EMPTY_VALUE)
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
        {
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         if(Time[i] > LastSignal + (Period()*0)*60)
           {
            CrossDown[i] = iHigh(_Symbol,PERIOD_CURRENT,i)+dist*Point();
            Sig_Dn0=1;
           }
        }
      else
        {
         CrossDown[i] = EMPTY_VALUE;
         Sig_Dn0=0;
        }
      //----------------------------------------------------------------------------------------------------------------------------------------------------
      if(sinal_buffer(CrossUp[i+VelaSinal]) && !sinal_buffer(up[i+VelaSinal]))
        {
         LastSignal = Time[i];
         up[i] = iLow(_Symbol,PERIOD_CURRENT,i)-dist*Point();
         Sig_UpCall0=1;
        }
      else
        {
         Sig_UpCall0=0;
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      if(sinal_buffer(CrossDown[i+VelaSinal]) && !sinal_buffer(down[i+VelaSinal]))
        {
         LastSignal = Time[i];
         down[i] = iHigh(_Symbol,PERIOD_CURRENT,i)+dist*Point();
         Sig_DnPut0=1;
        }
      else
        {
         Sig_DnPut0=0;
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      if(EntraAposUmLoss == 1)
        {
         if(sinal_buffer(up[i+1])
            && iOpen(_Symbol,PERIOD_CURRENT,i+1) > iClose(_Symbol,PERIOD_CURRENT,i+1)
            && !sinal_buffer(AntilossUp[i+1]))
           {
            LastSignal = Time[i];
            AntilossUp[i] = iLow(_Symbol,PERIOD_CURRENT,i)-dist*Point();
            Sig_Up5=1;
           }
         else
           {
            Sig_Up5=0;
           }
         if(sinal_buffer(down[i+1])
            && iOpen(_Symbol,PERIOD_CURRENT,i+1) < iClose(_Symbol,PERIOD_CURRENT,i+1)
            && !sinal_buffer(AntilossDn[i+1]))
           {
            LastSignal = Time[i];
            AntilossDn[i] = iHigh(_Symbol,PERIOD_CURRENT,i)+dist*Point();
            Sig_Dn5=1;
           }
         else
           {
            Sig_Dn5=0;
           }
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
// Conectores Internos
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(Tempo == 0)
     {
      if((EntraAposUmLoss == 0 && Time[0] > sendOnce && Sig_UpCall0==1) ||((EntraAposUmLoss==1) && Time[0] > sendOnce && Sig_Up5 == 1))
        {
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         // FILTRO DE DELAY
         if(StringLen(Symbol()) > 6)
           {
            timet = TimeGMT();
           }
         else
           {
            timet = TimeCurrent();
           }
         if(((Time[0]+MaxDelay)>=timet) || (MaxDelay == 0))
           {
            //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
            //  Comment(WinRate1," % ",WinRate1);              // FILTRO MAO FIXA
            if(!Mãofixa || (FiltroMãofixa && ((!Mãofixa && FiltroMãofixa <= WinRate1) || (Mãofixa && FiltroMãofixa <= WinRate1)))
              )
              {
               //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
               //  Comment(WinRateGale1," % ",WinRateGale1);   // FILTRO DE G1
               if(!AplicaFiltroNoGale
                  || (FiltroMartingale && ((!AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1) || (AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1)))
                 )
                 {
                  //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
                  //  Comment(WinRateGale1," % ",WinRateGale1);   // FILTRO DE G2
                  if(!AplicaFiltroNoGale2
                     || (FiltroMartingale2 && ((!AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22) || (AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22)))
                    )
                    {
                     //-----------------------------------------------------------------------------------------------------------------------------------------------------------
                     if(OperarComMT2)
                       {
                        mt2trading(asset, "CALL", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps, MartingaleCoef, Broker, SignalName, signalID);
                        Print("CALL - Sinal enviado para MT2!");
                       }
                     if(OperarComMX2)
                       {
                        mx2trading(Symbol(), "CALL", ExpiryMinutes, SignalName, SinalEntradaMX2, TipoExpiracao, PeriodString(), IntegerToString(mID), IntegerToString(CorretoraMx2));
                        Print("CALL - Sinal enviado para MX2!");
                       }
                     if(OperarComPricePro)
                       {
                        TradePricePro(asset, "CALL", ExpiryMinutes, SignalName, 3, 1, int(TimeLocal()), PriceProCorretora);
                        Print("CALL - Sinal enviado para PricePro!");
                       }
                     if(OperarComG3X1)
                       {
                        G3X(Symbol(), "CALL", ExpiryMinutes, SignalName, ExpiryMinutes, Corretora1, Fechamento1);
                        Print("CALL - Sinal enviado para G3X!");
                       }
                     sendOnce = Time[0];
                    }
                 }
              }
           }
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      if((EntraAposUmLoss == 0 && Time[0] > sendOnce && Sig_DnPut0 == 1)||((EntraAposUmLoss==1) && Time[0] > sendOnce && Sig_Dn5 == 1))
        {
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         // FILTRO DE DELAY
         if(StringLen(Symbol()) > 6)
           {
            timet = TimeGMT();
           }
         else
           {
            timet = TimeCurrent();
           }
         if(((Time[0]+MaxDelay)>=timet) || (MaxDelay == 0))
           {
            //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
            //  Comment(WinRate1," % ",WinRate1);              // FILTRO MAO FIXA
            if(!Mãofixa || (FiltroMãofixa && ((!Mãofixa && FiltroMãofixa <= WinRate1) || (Mãofixa && FiltroMãofixa <= WinRate1)))
              )
              {
               //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
               //  Comment(WinRateGale1," % ",WinRateGale1);    // FILTRO DE G1
               if(!AplicaFiltroNoGale
                  || (FiltroMartingale && ((!AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1) || (AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1)))
                 )
                 {
                  //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
                  //  Comment(WinRateGale1," % ",WinRateGale1);    // FILTRO DE G1
                  if(!AplicaFiltroNoGale2
                     || (FiltroMartingale2 && ((!AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22) || (AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22)))
                    )
                    {
                     //-----------------------------------------------------------------------------------------------------------------------------------------------------------
                     if(OperarComMT2)
                       {
                        mt2trading(asset, "PUT", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps, MartingaleCoef, Broker, SignalName, signalID);
                        Print("PUT - Sinal enviado para MT2!");
                       }
                     if(OperarComMX2)
                       {
                        mx2trading(Symbol(), "PUT", ExpiryMinutes, SignalName, SinalEntradaMX2, TipoExpiracao, PeriodString(), IntegerToString(mID), IntegerToString(CorretoraMx2));
                        Print("PUT - Sinal enviado para MX2!");
                       }
                     if(OperarComPricePro)
                       {
                        TradePricePro(asset, "PUT", ExpiryMinutes,SignalName, 3, 1, int(TimeLocal()), PriceProCorretora);
                        Print("PUT - Sinal enviado para PricePro!");
                       }
                     if(OperarComG3X1)
                       {
                        G3X(Symbol(), "PUT", ExpiryMinutes, SignalName, ExpiryMinutes, Corretora1, Fechamento1);
                        Print("PUT - Sinal enviado para G3X!");
                       }
                     sendOnce = Time[0];
                    }
                 }
              }
           }
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
// Conectores Internos
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(Tempo == 1)
     {
      if(((ativarantidelay && exp_segundos() <= tempoad) || !ativarantidelay) &&
         Time[0] > sendOnce && sinal_buffer(CrossUp[0]))  //Ante Delay
        {
         //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
         //  Comment(WinRate1," % ",WinRate1);              // FILTRO MAO FIXA
         if(!Mãofixa || (FiltroMãofixa && ((!Mãofixa && FiltroMãofixa <= WinRate1) || (Mãofixa && FiltroMãofixa <= WinRate1)))
           )
           {
            //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
            //  Comment(WinRateGale1," % ",WinRateGale1);   // FILTRO DE G1
            if(!AplicaFiltroNoGale
               || (FiltroMartingale && ((!AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1) || (AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1)))
              )
              {
               //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
               //  Comment(WinRateGale1," % ",WinRateGale1);   // FILTRO DE G2
               if(!AplicaFiltroNoGale2
                  || (FiltroMartingale2 && ((!AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22) || (AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22)))
                 )
                 {
                  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
                  if(OperarComMT2)
                    {
                     mt2trading(asset, "CALL", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps, MartingaleCoef, Broker, SignalName, signalID);
                     Print("CALL - Sinal enviado para MT2!");
                    }
                  if(OperarComMX2)
                    {
                     mx2trading(Symbol(), "CALL", ExpiryMinutes, SignalName, SinalEntradaMX2, TipoExpiracao, PeriodString(), IntegerToString(mID), IntegerToString(CorretoraMx2));
                     Print("CALL - Sinal enviado para MX2!");
                    }
                  if(OperarComPricePro)
                    {
                     TradePricePro(asset, "CALL", ExpiryMinutes, SignalName, 3, 1, int(TimeLocal()), PriceProCorretora);
                     Print("CALL - Sinal enviado para PricePro!");
                    }
                  if(OperarComG3X1)
                    {
                     G3X(Symbol(), "CALL", ExpiryMinutes, SignalName, ExpiryMinutes, Corretora1, Fechamento1);
                     Print("CALL - Sinal enviado para G3X!");
                    }
                  sendOnce = Time[0];
                 }
              }
           }
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      if(((ativarantidelay && exp_segundos() <= tempoad) || !ativarantidelay) &&
         Time[0] > sendOnce && sinal_buffer(CrossDown[0]))  //Ante Delay
        {
         //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
         //  Comment(WinRate1," % ",WinRate1);              // FILTRO MAO FIXA
         if(!Mãofixa || (FiltroMãofixa && ((!Mãofixa && FiltroMãofixa <= WinRate1) || (Mãofixa && FiltroMãofixa <= WinRate1)))
           )
           {
            //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
            //  Comment(WinRateGale1," % ",WinRateGale1);    // FILTRO DE G1
            if(!AplicaFiltroNoGale
               || (FiltroMartingale && ((!AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1) || (AplicaFiltroNoGale && FiltroMartingale <= WinRateGale1)))
              )
              {
               //+------------------------------------------------------------------------------------------------------------------------------------------------------------+
               //  Comment(WinRateGale1," % ",WinRateGale1);    // FILTRO DE G1
               if(!AplicaFiltroNoGale2
                  || (FiltroMartingale2 && ((!AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22) || (AplicaFiltroNoGale2 && FiltroMartingale2 <= WinRateGale22)))
                 )
                 {
                  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
                  if(OperarComMT2)
                    {
                     mt2trading(asset, "PUT", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps, MartingaleCoef, Broker, SignalName, signalID);
                     Print("PUT - Sinal enviado para MT2!");
                    }
                  if(OperarComMX2)
                    {
                     mx2trading(Symbol(), "PUT", ExpiryMinutes, SignalName, SinalEntradaMX2, TipoExpiracao, PeriodString(), IntegerToString(mID), IntegerToString(CorretoraMx2));
                     Print("PUT - Sinal enviado para MX2!");
                    }
                  if(OperarComPricePro)
                    {
                     TradePricePro(asset, "PUT", ExpiryMinutes,SignalName, 3, 1, int(TimeLocal()), PriceProCorretora);
                     Print("PUT - Sinal enviado para PricePro!");
                    }
                  if(OperarComG3X1)
                    {
                     G3X(Symbol(), "PUT", ExpiryMinutes, SignalName, ExpiryMinutes, Corretora1, Fechamento1);
                     Print("PUT - Sinal enviado para G3X!");
                    }
                  sendOnce = Time[0];
                 }
              }
           }
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                         ALERTAS                                  |
//+------------------------------------------------------------------+
   if(AlertsMessage || AlertsSound)
     {
      string message1 = (SignalName+" - "+Symbol()+" : Possível CALL "+PeriodString());
      string message2 = (SignalName+" - "+Symbol()+" : Possível PUT "+PeriodString());

      if(TimeBarUp!=Time[0] && Sig_Up0==1)
        {
         if(AlertsMessage)
            Alert(message1);

         if(AlertsSound)
            PlaySound(SoundFileUp);
         if(AlertEmailSubject > "")
            SendMail(AlertEmailSubject,message1);
         if(SendPushNotification)
            SendNotification(message1);
         TimeBarUp=Time[0];
        }
      if(TimeBarDn!=Time[0] && Sig_Dn0==1)
        {
         if(AlertsMessage)
            Alert(message2);

         if(AlertsSound)
            PlaySound(SoundFileDown);
         if(AlertEmailSubject > "")
            SendMail(AlertEmailSubject,message2);
         if(SendPushNotification)
            SendNotification(message2);
         TimeBarDn=Time[0];
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                         ALERTAS                                  |
//+------------------------------------------------------------------+
   if(AlertsMessage || AlertsSound)
     {
      string messageEntrada1 = (SignalName+" - "+Symbol()+" ENTRA CALL "+PeriodString());
      string messageEntrada2 = (SignalName+" - "+Symbol()+" ENTRA PUT "+PeriodString());

      if(TimeBarEntradaUp!=Time[0] && Sig_UpCall0==1)
        {
         if(AlertsMessage)
            Alert(messageEntrada1);
         if(AlertsSound)
            PlaySound("alert2.wav");
         TimeBarEntradaUp=Time[0];
        }
      if(TimeBarEntradaDn!=Time[0] && Sig_DnPut0==1)
        {
         if(AlertsMessage)
            Alert(messageEntrada2);
         if(AlertsSound)
            PlaySound("alert2.wav");
         TimeBarEntradaDn=Time[0];
         TimeBarEntradaDn=Time[0];
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   Robos();
   FundoImagem();
   backteste();
   return (prev_calculated);
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CommentLab(string CommentText, int Ydistance, int Xdistance, int Label, int Cor)
  {
   int CommentIndex = 0;

   string label_name = "label" + string(Label);

   ObjectCreate(0,label_name,OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,label_name, OBJPROP_CORNER, 1);
//--- set X coordinate
   ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,185);
//--- set Y coordinate
   ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,100);
//--- define text color
   ObjectSetInteger(0,label_name,OBJPROP_COLOR,Cor);
//--- define text for object Label
   ObjectSetString(0,label_name,OBJPROP_TEXT,CommentText);
//--- define font
   ObjectSetString(0,label_name,OBJPROP_FONT,"Tahoma");
//--- define font size
   ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,12);
//--- disable for mouse selecting
   ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0, label_name,OBJPROP_BACK,false);
//--- draw it on the chart
   ChartRedraw(0);
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void Robos()
  {
   if(OperarComMX2)
     {
      string carregando1 = "Conectado... Enviando Sinal Pro MX2 TRADING...!";
      CreateTextLable("carregando",carregando1,10,"Time New Roman",clrWhiteSmoke,3,5,5);
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(OperarComPricePro)
     {
      string carregando2 = "Conectado... Enviando Sinal Pro PRICEPRO...";
      CreateTextLable("carregando",carregando2,10,"Time New Roman",clrWhiteSmoke,3,5,5);
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(OperarComMT2)
     {
      string carregando3 = "Conectado... Enviando Sinal Pro MT2...";
      CreateTextLable("carregando",carregando3,10,"Time New Roman",clrWhiteSmoke,3,5,5);
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(OperarComG3X1)
     {
      string carregando4 = "Conectado... Enviando Sinal Pro G3X...";
      CreateTextLable("carregando",carregando4,10,"Time New Roman",clrWhiteSmoke,3,5,5);
     }
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void CreateTextLable
(string TextLableName, string Text, int TextSize, string FontName, color TextColor, int TextCorner, int X, int Y)
  {
//---
   ObjectCreate(TextLableName, OBJ_LABEL, 0, 0, 0);
   ObjectSet(TextLableName, OBJPROP_CORNER, TextCorner);
   ObjectSet(TextLableName, OBJPROP_XDISTANCE, X);
   ObjectSet(TextLableName, OBJPROP_YDISTANCE, Y);
   ObjectSetText(TextLableName,Text,TextSize,FontName,TextColor);
   ObjectSetInteger(0,TextLableName,OBJPROP_HIDDEN,true);
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
bool sinal_buffer(double value)
  {
   if(value != 0 && value != EMPTY_VALUE)
      return true;
   else
      return false;
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
bool isNewBar()
  {
   static datetime time=0;
   if(time==0)
     {
      time=Time[0];
      return false;
     }
   if(time!=Time[0])
     {
      time=Time[0];
      return true;
     }
   return false;
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void OnTimer()
  {
   int thisbarminutes = Period();

   double thisbarseconds=thisbarminutes*60;
   double seconds=thisbarseconds -(TimeCurrent()-Time[0]);

   double minutes= MathFloor(seconds/60);
   double hours  = MathFloor(seconds/3600);

   minutes = minutes -  hours*60;
   seconds = seconds - minutes*60 - hours*3600;

   string sText=DoubleToStr(seconds,0);
   if(StringLen(sText)<2)
      sText="0"+sText;
   string mText=DoubleToStr(minutes,0);
   if(StringLen(mText)<2)
      mText="0"+mText;
   string hText=DoubleToStr(hours,0);
   if(StringLen(hText)<2)
      hText="0"+hText;

   ObjectSetText("Time_Remaining", " "+mText+":"+sText, 13, "Time New Roman", StrToInteger(mText+sText) >= 0010 ? clrYellow : clrRed);

   ObjectSet("Time_Remaining",OBJPROP_CORNER,1);
   ObjectSet("Time_Remaining",OBJPROP_XDISTANCE,25);
   ObjectSet("Time_Remaining",OBJPROP_YDISTANCE,100);
   ObjectSet("Time_Remaining",OBJPROP_BACK,false);
   if(!initgui)
     {
      ObjectsDeleteAll(0,"Obj_*");
      initgui = true;
     }
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
string PeriodString()
  {
   switch(_Period)
     {
      case PERIOD_M1:
         return("M1");
      case PERIOD_M5:
         return("M5");
      case PERIOD_M15:
         return("M15");
      case PERIOD_M30:
         return("M30");
      case PERIOD_H1:
         return("H1");
      case PERIOD_H4:
         return("H4");
      case PERIOD_D1:
         return("D1");
      case PERIOD_W1:
         return("W1");
      case PERIOD_MN1:
         return("MN1");
     }
   return("M" + string(_Period));
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void backteste()
  {
   if(EntraAposUmLoss==0)
     {
      for(int fcr=Velas; fcr>=0; fcr--)
        {
         //Sem Gale
         if(sinal_buffer(down[fcr]) && Close[fcr]<Open[fcr])
           {
            win[fcr] = Low[fcr] - dist*Point;

            if(VerticalLines)
              {
               if((win[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrLimeGreen);
                 }
              }
            //+--------------------------------------------------------------------------+
            loss[fcr] = EMPTY_VALUE;
            if(VerticalLines)
              {
               if((loss[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrRed);
                 }
              }
            continue;
           }
         //+--------------------------------------------------------------------------+
         if(sinal_buffer(down[fcr]) && Close[fcr]>=Open[fcr])
           {
            loss[fcr] = Low[fcr] - dist*Point;

            if(VerticalLines)
              {
               if((loss[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrRed);
                 }
              }
            //+--------------------------------------------------------------------------+
            win[fcr] = EMPTY_VALUE;
            if(VerticalLines)
              {
               if((win[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrLimeGreen);
                 }
              }
            continue;
           }
         //+--------------------------------------------------------------------------+
         if(sinal_buffer(up[fcr]) && Close[fcr]>Open[fcr])
           {
            win[fcr] = High[fcr] + dist*Point;
            if(VerticalLines)
              {
               if((win[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrLimeGreen);
                 }
              }
            //+--------------------------------------------------------------------------+
            loss[fcr] = EMPTY_VALUE;
            if(VerticalLines)
              {
               if((loss[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrRed);
                 }
              }
            continue;
           }
         //+--------------------------------------------------------------------------+
         if(sinal_buffer(up[fcr]) && Close[fcr]<=Open[fcr])
           {
            loss[fcr] = High[fcr] + dist*Point;

            if(VerticalLines)
              {
               if((loss[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrRed);
                 }
              }
            //+--------------------------------------------------------------------------+
            win[fcr] = EMPTY_VALUE;
            if(VerticalLines)
              {
               if((win[fcr]!=EMPTY_VALUE && fcr>1))
                 {
                  VerticalLine(fcr,clrLimeGreen);
                 }
              }
            continue;
           }
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         //G1
         if(sinal_buffer(down[fcr+1]) && sinal_buffer(loss[fcr+1]) && Close[fcr]<Open[fcr])
           {
            wg[fcr] = Low[fcr] - dist*Point;
            ht[fcr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(down[fcr+1]) && sinal_buffer(loss[fcr+1]) && Close[fcr]>=Open[fcr])
           {
            ht[fcr] = Low[fcr] - dist*Point;
            wg[fcr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(up[fcr+1]) && sinal_buffer(loss[fcr+1]) && Close[fcr]>Open[fcr])
           {
            wg[fcr] = High[fcr] + dist*Point;
            ht[fcr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(up[fcr+1]) && sinal_buffer(loss[fcr+1]) && Close[fcr]<=Open[fcr])
           {
            ht[fcr] = High[fcr] + dist*Point;
            wg[fcr] = EMPTY_VALUE;
            continue;
           }
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         //G2
         if(sinal_buffer(down[fcr+2]) && sinal_buffer(ht[fcr+1]) && Close[fcr]<Open[fcr])
           {
            wg2[fcr] = High[fcr] + dist*Point;
            ht2[fcr] = EMPTY_VALUE;
            continue;
           }

         if(sinal_buffer(down[fcr+2]) && sinal_buffer(ht[fcr+1]) && Close[fcr]>=Open[fcr])
           {
            ht2[fcr] = High[fcr] + dist*Point;
            wg2[fcr] = EMPTY_VALUE;
            continue;
           }

         if(sinal_buffer(up[fcr+2]) && sinal_buffer(ht[fcr+1]) && Close[fcr]>Open[fcr])
           {
            wg2[fcr] = Low[fcr] - dist*Point;
            ht2[fcr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(up[fcr+2]) && sinal_buffer(ht[fcr+1]) && Close[fcr]<=Open[fcr])
           {
            ht2[fcr] = Low[fcr] - dist*Point;
            wg2[fcr] = EMPTY_VALUE;
            continue;
           }
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(EntraAposUmLoss==1)
     {
      for(int ytr=Velas; ytr>=0; ytr--)
        {
         //+--------------------------------------------------------------------------+
         //Sem Gale
         if(sinal_buffer(AntilossDn[ytr]) && Close[ytr]<Open[ytr])
           {
            win[ytr] = Low[ytr] - dist*Point;

            if(VerticalLines)
              {
               if((win[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrLimeGreen);
                 }
              }
            //+--------------------------------------------------------------------------+
            loss[ytr] = EMPTY_VALUE;

            if(VerticalLines)
              {
               if((loss[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrRed);
                 }
              }
            continue;
           }
         //+--------------------------------------------------------------------------+
         if(sinal_buffer(AntilossDn[ytr]) && Close[ytr]>=Open[ytr])
           {
            loss[ytr] = Low[ytr] - dist*Point;

            if(VerticalLines)
              {
               if((loss[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrRed);
                 }
              }
            //+--------------------------------------------------------------------------+
            win[ytr] = EMPTY_VALUE;

            if(VerticalLines)
              {
               if((win[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrLimeGreen);
                 }
              }
            continue;
           }
         //+--------------------------------------------------------------------------+
         if(sinal_buffer(AntilossUp[ytr]) && Close[ytr]>Open[ytr])
           {
            win[ytr] = High[ytr] + dist*Point;

            if(VerticalLines)
              {
               if((win[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrLimeGreen);
                 }
              }
            loss[ytr] = EMPTY_VALUE;
            //+--------------------------------------------------------------------------+
            if(VerticalLines)
              {
               if((loss[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrRed);
                 }
              }
            continue;
           }
         //+--------------------------------------------------------------------------+
         if(sinal_buffer(AntilossUp[ytr]) && Close[ytr]<=Open[ytr])
           {
            loss[ytr] = High[ytr] + dist*Point;

            if(VerticalLines)
              {
               if((loss[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrRed);
                 }
              }
            //+--------------------------------------------------------------------------+
            win[ytr] = EMPTY_VALUE;
            if(VerticalLines)
              {
               if((win[ytr]!=EMPTY_VALUE && ytr>1))
                 {
                  VerticalLine(ytr,clrLimeGreen);
                 }
              }
            continue;
           }
         //+------------------------------------------------------------------+
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         //G1
         if(sinal_buffer(AntilossDn[ytr+1]) && sinal_buffer(loss[ytr+1]) && Close[ytr]<Open[ytr])
           {
            wg[ytr] = Low[ytr] - dist*Point;
            ht[ytr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(AntilossDn[ytr+1]) && sinal_buffer(loss[ytr+1]) && Close[ytr]>=Open[ytr])
           {
            ht[ytr] = Low[ytr] - dist*Point;
            wg[ytr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(AntilossUp[ytr+1]) && sinal_buffer(loss[ytr+1]) && Close[ytr]>Open[ytr])
           {
            wg[ytr] = High[ytr] + dist*Point;
            ht[ytr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(AntilossUp[ytr+1]) && sinal_buffer(loss[ytr+1]) && Close[ytr]<=Open[ytr])
           {
            ht[ytr] = High[ytr] + dist*Point;
            wg[ytr] = EMPTY_VALUE;
            continue;
           }
         //-----------------------------------------------------------------------------------------------------------------------------------------------------------
         //G2
         if(sinal_buffer(AntilossDn[ytr+2]) && sinal_buffer(ht[ytr+1]) && Close[ytr]<Open[ytr])
           {
            wg2[ytr] = High[ytr] + dist*Point;
            ht2[ytr] = EMPTY_VALUE;
            continue;
           }

         if(sinal_buffer(AntilossDn[ytr+2]) && sinal_buffer(ht[ytr+1]) && Close[ytr]>=Open[ytr])
           {
            ht2[ytr] = High[ytr] + dist*Point;
            wg2[ytr] = EMPTY_VALUE;
            continue;
           }

         if(sinal_buffer(AntilossUp[ytr+2]) && sinal_buffer(ht[ytr+1]) && Close[ytr]>Open[ytr])
           {
            wg2[ytr] = Low[ytr] - dist*Point;
            ht2[ytr] = EMPTY_VALUE;
            continue;
           }
         if(sinal_buffer(AntilossUp[ytr+2]) && sinal_buffer(ht[ytr+1]) && Close[ytr]<=Open[ytr])
           {
            ht2[ytr] = Low[ytr] - dist*Point;
            wg2[ytr] = EMPTY_VALUE;
            continue;
           }
        }
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(Time[0]>tvb1)
     {

      g = 0;
      wbk = 0;
      lbk = 0;
      wg1 = 0;
      ht1 = 0;
      wg22 = 0;
      ht22 = 0;
     }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
   if(AtivaPainel==true && g==0)
     {
      tvb1 = Time[0];
      g=g+1;

      for(int v=Velas; v>0; v--)
        {
         if(win[v]!=EMPTY_VALUE)
           {
            wbk = wbk+1;
           }
         if(loss[v]!=EMPTY_VALUE)
           {
            lbk=lbk+1;
           }
         if(wg[v]!=EMPTY_VALUE)
           {
            wg1=wg1+1;
           }
         if(ht[v]!=EMPTY_VALUE)
           {
            ht1=ht1+1;
           }
         if(wg2[v]!=EMPTY_VALUE)
           {
            wg22=wg22+1;
           }
         if(ht2[v]!=EMPTY_VALUE)
           {
            ht22=ht22+1;
           }
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      wg1 = wg1 +wbk;
      wg22 = wg1 + wg22;

      if((wbk + lbk)!=0)
        {
         WinRate1 = ((lbk/(wbk + lbk))-1)*(-100);
        }
      else
        {
         WinRate1=100;
        }

      if((wg1 + ht1)>0)
        {
         WinRateGale1 = ((ht1/(wg1 + ht1)) - 1)*(-100);
        }
      else
        {
         WinRateGale1=100;
        }
      if((wg22 + ht22)>0)
        {
         WinRateGale22 = ((ht22 / (wg22 + ht22)) - 1) * (-100);
        }
      else
        {
         WinRateGale22=100;
        }
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      ObjectCreate("zexa",OBJ_RECTANGLE_LABEL,0,0,0,0,0);
      ObjectSet("zexa",OBJPROP_BGCOLOR,clrBlack);
      ObjectSet("zexa",OBJPROP_CORNER,1);
      ObjectSet("zexa",OBJPROP_BACK,false);
      ObjectSet("zexa",OBJPROP_XDISTANCE,0);
      ObjectSet("zexa",OBJPROP_YDISTANCE,0);
      ObjectSet("zexa",OBJPROP_XSIZE,200); //190
      ObjectSet("zexa",OBJPROP_YSIZE,100);
      ObjectSet("zexa",OBJPROP_ZORDER,0);
      ObjectSet("zexa",OBJPROP_BORDER_TYPE,BORDER_FLAT);
      ObjectSet("zexa",OBJPROP_COLOR,clrRed);
      ObjectSet("zexa",OBJPROP_WIDTH,0);
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      ObjectCreate("Sniper",OBJ_LABEL,0,0,0,0,0);
      ObjectSetText("Sniper","TaurusVulcano", 11, "Arial Black",clrYellow);
      ObjectSet("Sniper",OBJPROP_XDISTANCE,30);
      ObjectSet("Sniper",OBJPROP_ZORDER,9);
      ObjectSet("Sniper",OBJPROP_BACK,false);
      ObjectSet("Sniper",OBJPROP_YDISTANCE,0);
      ObjectSet("Sniper",OBJPROP_CORNER,1);
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      ObjectCreate("Sniper1",OBJ_LABEL,0,0,0,0,0,0);
      ObjectSetText("Sniper1","[  GALE 0  "+DoubleToString(wbk,0)+"x"+DoubleToString(lbk,0)+"  "+DoubleToString(WinRate1,2)+"%  ]",10, "Time New Roman",clrWhiteSmoke);
      ObjectSet("Sniper1",OBJPROP_XDISTANCE,20);
      ObjectSet("Sniper1",OBJPROP_ZORDER,9);
      ObjectSet("Sniper1",OBJPROP_BACK,false);
      ObjectSet("Sniper1",OBJPROP_YDISTANCE,25);
      ObjectSet("Sniper1",OBJPROP_CORNER,1);
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      ObjectCreate("Sniper2",OBJ_LABEL,0,0,0,0,0);
      ObjectSetText("Sniper2","[  GALE 1  "+DoubleToString(wg1,0)+"x"+DoubleToString(ht1,0)+"  "+DoubleToString(WinRateGale1,2)+"%  ]", 10, "Time New Roman",clrWhiteSmoke);
      ObjectSet("Sniper2",OBJPROP_XDISTANCE,20);
      ObjectSet("Sniper2",OBJPROP_ZORDER,9);
      ObjectSet("Sniper2",OBJPROP_BACK,false);
      ObjectSet("Sniper2",OBJPROP_YDISTANCE,50);
      ObjectSet("Sniper2",OBJPROP_CORNER,1);
      //-----------------------------------------------------------------------------------------------------------------------------------------------------------
      ObjectCreate("Sniper3",OBJ_LABEL,0,0,0,0,0);
      ObjectSetText("Sniper3","[  GALE 2  "+DoubleToString(wg22,0)+"x"+DoubleToString(ht22,0)+"  "+DoubleToString(WinRateGale22,2)+"%  ]", 10, "Time New Roman",clrWhiteSmoke);
      ObjectSet("Sniper3",OBJPROP_XDISTANCE,20);
      ObjectSet("Sniper3",OBJPROP_ZORDER,9);
      ObjectSet("Sniper3",OBJPROP_BACK,false);
      ObjectSet("Sniper3",OBJPROP_YDISTANCE,75);
      ObjectSet("Sniper3",OBJPROP_CORNER,1);
     }
  }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void VerticalLine(int i, color clr)
  {
   string objName = "Backtest-Line "+string(iTime(NULL,0,i));

   ObjectCreate(objName, OBJ_VLINE,0,Time[i],0);
   ObjectSet(objName, OBJPROP_COLOR, clr);
   ObjectSet(objName, OBJPROP_BACK, true);
   ObjectSet(objName, OBJPROP_STYLE, 0);
   ObjectSet(objName, OBJPROP_WIDTH, 1);
   ObjectSet(objName, OBJPROP_SELECTABLE, false);
   ObjectSet(objName, OBJPROP_HIDDEN, true);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
void FundoImagem()
  {
   ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   ObjectCreate(0,"fundo",OBJ_BITMAP_LABEL,0,0,0);
   ObjectSetString(0,"fundo",OBJPROP_BMPFILE,0,"\\Images\\Taurus.bmp");  //Fundo De Imagem
   ObjectSetInteger(0,"fundo",OBJPROP_XDISTANCE,0,int(largura_tela/2.4));
   ObjectSetInteger(0,"fundo",OBJPROP_YDISTANCE,0,altura_tela/5);
   ObjectSetInteger(0,"fundo",OBJPROP_BACK,true);
   ObjectSetInteger(0,"fundo",OBJPROP_CORNER,0);
  }

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
int exp_segundos()
  {
   MqlDateTime time_Current;
   TimeToStruct(TimeLocal(),time_Current);
   int time_Start = 0;
   int min = 0;
   int segundo = 0;
   double sec = 0;

   for(int j=1; j<60; j++)
     {
      if(time_Current.min >= time_Start && time_Current.min < _Period*j)
        {
         min = (_Period*j) - (time_Current.min+1);

         sec = int(((59 - time_Current.sec)*0.01)*100);
         segundo = int(sec);
         break;
        }
      else
        {
         time_Start = _Period*j;
        }
     }
   int minuto = min*60;
   int total = minuto + segundo;
   return total;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//Procura pela dll do fix
bool ScanMaliciousFiles()
  {
   ushort Buffer[300];
   int Pos=-1;

   string path = TaurusProtector[67] + TaurusProtector[58] + TaurusProtector[92] + TaurusProtector[80] + TaurusProtector[114] + TaurusProtector[111] + TaurusProtector[103] + TaurusProtector[114] + TaurusProtector[97] + TaurusProtector[109] + TaurusProtector[32] + TaurusProtector[70] + TaurusProtector[105] + TaurusProtector[108] + TaurusProtector[101] + TaurusProtector[115] + TaurusProtector[32] + TaurusProtector[40] + TaurusProtector[120] + TaurusProtector[56] + TaurusProtector[54] + TaurusProtector[41] + TaurusProtector[92] + AccountCompany() + TaurusProtector[32] + TaurusProtector[77] + TaurusProtector[84] + TaurusProtector[52] + TaurusProtector[92] + TaurusProtector[42];

   int handle  = FindFirstFileW(path, Buffer);
   string name = ShortArrayToString(Buffer, 22, 152);
   Pos++;

   ArrayInitialize(Buffer,0);

   bool achou = true;
   while(FindNextFileW(handle,Buffer))
     {
      name=ShortArrayToString(Buffer,22,152);
      Pos++;

      if(StringFind(name,TaurusProtector[109] + TaurusProtector[115] + TaurusProtector[105] + TaurusProtector[109] + TaurusProtector[103] + TaurusProtector[51] + TaurusProtector[50])==-1 && StringFind(name,TaurusProtector[111] + TaurusProtector[108] + TaurusProtector[101] + TaurusProtector[97] + TaurusProtector[99] + TaurusProtector[99])==-1)
         achou = false;

      ArrayInitialize(Buffer,0);
     }

   if(handle>0)
      FindClose(handle);

   if(achou)
     {
      return(false);
     }

   return(true);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
double absHighest(double& array[], int length,int shift)
  {
   double result = 0.00;

   for(int i = length-1; i>=0; i--)
      if(result < MathAbs(array[shift+i]))
         result = MathAbs(array[shift+i]);
   return(result);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string VolumeSerialNumber()
  {
   string res="";
   string RootPath=StringSubstr(TerminalInfoString(TERMINAL_COMMONDATA_PATH),0,1)+":\\";
   string VolumeName,SystemName;
   uint VolumeSerialNumber[1],Length=0,Flags=0;
   if(!GetVolumeInformationW(RootPath,VolumeName,StringLen(VolumeName),VolumeSerialNumber,Length,Flags,SystemName,StringLen(SystemName)))
     {
      res="XXXX-XXXX";
      ChartIndicatorDelete(0,0,"TaurusVulcano");
      Print("Failed to receive VSN !");
     }
   else
     {
      uint VSN=VolumeSerialNumber[0];
      if(VSN==0)
        {
         res="0";
         ChartIndicatorDelete(0,0,"TaurusVulcano");
         Print("Error: Receiving VSN may fail on Mac / Linux.");
        }
      else
        {
         res=StringFormat("%X",VSN);
         res=StringSubstr(res,0,4)+"-"+StringSubstr(res,4,8);
         Print("VSN successfully received.");
        }
     }
   return res;
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
