139 lines
No EOL
11 KiB
Text
139 lines
No EOL
11 KiB
Text
//+------------------------------------------------------------------+
|
|
//| RenkoBR.mq5 |
|
|
//| Copyright 2019, RenkoBR |
|
|
//| https://www.renkobr.com.br |
|
|
//+------------------------------------------------------------------+
|
|
#property service
|
|
#property copyright "© RenkoBR"
|
|
#property link "https://www.renkobr.com.br/"
|
|
//#property icon "\\Images\\RenkoBR.ico";
|
|
#define VersaoCodigo "220.719"
|
|
#property version VersaoCodigo
|
|
|
|
#property description "RenkoBR"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| INCLUDES PRINCIPAIS |
|
|
//+------------------------------------------------------------------+
|
|
#include "CustomCharts.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| PARAMETROS DE ENTRADA DO USUÁRIO |
|
|
//+------------------------------------------------------------------+
|
|
input string P_Ativo_Base = "WIN$N"; // Ativo Base
|
|
//input ENUM_R_TYPE P_Tipo_Box = RENKO_TYPE_R; // Tipo de Box Renko
|
|
input ENUM_CUSTOM_TYPE P_Tipo_Box = RENKO_TYPE_R; // Tipo de Box Renko
|
|
input int P_Tamanho_Box = 20; // Tamanho Box
|
|
input bool P_Sombras = true; // Mostrar Sombra
|
|
input bool P_Assimetrica = true; // Reversões assimétricas (Abertura Box Artificial na reversão)
|
|
input bool P_Gap = false; // Mostrar o Gap?
|
|
input bool P_Nivelar = false; // Nivelar Box na Abertura do dia?
|
|
input bool P_Avancar = true; // Avançar Box no tempo
|
|
|
|
input datetime P_RatesHistory = 0; // Histórico: Taxas (o padrão é 7 dias 1M taxas de OHLC.)
|
|
input bool P_RealTicks = true; // Histórico: Ticks reais (Histórico baseado em ticks reais. MAIS LENTO!)
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| INICIO DO PROCESSAMENTO DO SERVICE RENKO |
|
|
//+------------------------------------------------------------------+
|
|
int OnStart()
|
|
{
|
|
ResetLastError();
|
|
|
|
string NomeAtivo = P_Ativo_Base;
|
|
|
|
if (!SymbolInfoInteger(NomeAtivo,SYMBOL_EXIST))
|
|
{
|
|
string s_Msg = "O Ativo base: "+NomeAtivo+" - informado no parametro não existe!";
|
|
Print(s_Msg);
|
|
MessageBox(s_Msg,"RenkoBR", MB_OK);
|
|
return(INIT_FAILED);
|
|
}
|
|
|
|
if(SymbolInfoInteger(NomeAtivo, SYMBOL_CUSTOM))
|
|
{
|
|
string s_Msg = "O Ativo base: "+NomeAtivo+" - não pode ser um custom symbol!";
|
|
Print(s_Msg);
|
|
MessageBox(s_Msg,"RenkoBR", MB_OK);
|
|
return(INIT_FAILED);
|
|
}
|
|
|
|
if (P_Tamanho_Box <= 2)
|
|
{
|
|
string s_Msg = "Tamanho Mínimo para geração do box renko é 2, favor ajustar!";
|
|
Print(s_Msg);
|
|
MessageBox(s_Msg,"RenkoBR", MB_OK);
|
|
return(INIT_FAILED);
|
|
}
|
|
|
|
string m_AtivoRenko = "";
|
|
|
|
switch(P_Tipo_Box)
|
|
{
|
|
case RENKO_TYPE_R: m_AtivoRenko = StringFormat("%s.%gR", NomeAtivo, P_Tamanho_Box); break;
|
|
case RENKO_TYPE_PIPS: m_AtivoRenko = StringFormat("%s.%gpip", NomeAtivo, P_Tamanho_Box); break;
|
|
case RENKO_TYPE_POINTS:m_AtivoRenko = StringFormat("%s.%gpoint", NomeAtivo, P_Tamanho_Box); break;
|
|
case RENKO_TYPE_TICKS: m_AtivoRenko = StringFormat("%s.%gtks", NomeAtivo, P_Tamanho_Box); break;
|
|
}
|
|
|
|
//crie o símbolo
|
|
if(!CustomSymbolCreate(m_AtivoRenko,"\\RenkoBR",NomeAtivo))
|
|
{
|
|
if(!SymbolInfoInteger(m_AtivoRenko,SYMBOL_CUSTOM))
|
|
{
|
|
string s_Msg = "Erro ao criar símbolo Renko. Código de erro: "+(string)GetLastError();
|
|
Print(s_Msg);
|
|
MessageBox(s_Msg,"RenkoBR", MB_OK);
|
|
}
|
|
}
|
|
|
|
CustomSymbolSetInteger(m_AtivoRenko,SYMBOL_BACKGROUND_COLOR,clrLightSalmon);
|
|
|
|
if (!SymbolSelect(m_AtivoRenko,true))
|
|
{
|
|
Print("Não foi possivel gerar o ativo customizado pelo Renko! Código de erro: ",GetLastError());
|
|
return(INIT_FAILED);
|
|
}
|
|
|
|
CustomCharts *CustomChartsOffline;
|
|
CustomChartsOffline = new CustomCharts();
|
|
|
|
CustomChartsOffline.CreateCustomSymbol(m_AtivoRenko);
|
|
|
|
if(CustomChartsOffline == NULL)
|
|
{
|
|
string s_Msg = "Erro ao criar Classe do Renko. Código de erro: "+(string)GetLastError();
|
|
Print(s_Msg);
|
|
MessageBox(s_Msg,"RenkoBR", MB_OK);
|
|
return(INIT_FAILED);
|
|
}
|
|
|
|
if(!CustomChartsOffline.Setup(NomeAtivo, P_Tipo_Box, P_Tamanho_Box, P_Sombras, P_Assimetrica, P_Gap, P_Nivelar, P_Avancar, P_RatesHistory, P_RealTicks, true))
|
|
{
|
|
string s_Msg = "Erro ao Capturar ticks iniciais do Renko. Código de erro: "+(string)GetLastError();
|
|
Print(s_Msg);
|
|
MessageBox(s_Msg,"RenkoBR", MB_OK);
|
|
return(INIT_FAILED);
|
|
}
|
|
|
|
CustomChartsOffline.Refresh();
|
|
SymbolSelect(m_AtivoRenko,false);
|
|
CustomSymbolSetInteger(m_AtivoRenko,SYMBOL_BACKGROUND_COLOR,clrLightGreen);
|
|
SymbolSelect(m_AtivoRenko,true);
|
|
|
|
// Loop para geração de cada novo tick no ativo personalizado
|
|
while(!IsStopped())
|
|
{
|
|
CustomChartsOffline.Refresh();
|
|
Sleep(1);
|
|
}
|
|
|
|
// Desinicializacao
|
|
if(CustomChartsOffline != NULL)
|
|
{
|
|
delete CustomChartsOffline;
|
|
}
|
|
|
|
//FIM
|
|
return(INIT_SUCCEEDED);
|
|
} |