TheSmcIctIndEx/Ex/BosChoch.mq5

107 lines
3.8 KiB
MQL5
Raw Permalink Normal View History

2026-04-15 21:15:54 -05:00
//+------------------------------------------------------------------+
//| BosChoch.mq5 |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com/es/users/nique_372"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Include |
//+------------------------------------------------------------------+
#include "..\\Src\\Defines.mqh"
//+------------------------------------------------------------------+
//| Global variables |
//+------------------------------------------------------------------+
//--- Buffers
double g_bullish_bos_buffer[];
double g_bearish_bos_buffer[];
double g_bullish_choch_buffer[];
double g_bearish_choch_buffer[];
//--- Handle
int g_handle = INVALID_HANDLE;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- Indicator creation
ResetLastError();
g_handle = iCustom(_Symbol, _Period, ICTSMCIND_NAME_RES);
if(g_handle == INVALID_HANDLE)
{
PrintFormat("Failid to load TheSmcIctIndicator, last error = %d", GetLastError());
return INIT_FAILED;
}
else
{
Print("Successful loading TheSmcIctIndicator");
}
//--- Buffers series
ArraySetAsSeries(g_bullish_bos_buffer, true);
ArraySetAsSeries(g_bearish_bos_buffer, true);
ArraySetAsSeries(g_bullish_choch_buffer, true);
ArraySetAsSeries(g_bearish_choch_buffer, true);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
if(g_handle != INVALID_HANDLE)
IndicatorRelease(g_handle);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
static datetime last_time = 0;
const datetime new_time = iTime(_Symbol, _Period, 0);
if(last_time != new_time)
{
//--- Copy indicator data
ResetLastError();
if(CopyBuffer(g_handle, ICTSMCIND_BUFFER_BEARISH_BOS, 1, 1, g_bearish_bos_buffer) != 1 ||
CopyBuffer(g_handle, ICTSMCIND_BUFFER_BEARISH_CHOCH, 1, 1, g_bearish_choch_buffer) != 1 ||
CopyBuffer(g_handle, ICTSMCIND_BUFFER_BULLISH_BOS, 1, 1, g_bullish_bos_buffer) != 1 ||
CopyBuffer(g_handle, ICTSMCIND_BUFFER_BULLISH_CHOCH, 1, 1, g_bullish_choch_buffer) != 1)
{
Print("Error to copy ind data, last error = ", GetLastError());
return;
}
//--- Print values
if(g_bullish_bos_buffer[0] > ICTSMCIND_VOID_BUFFER_VALUE)
{
Print("Bullish bos now, with price = ", g_bullish_bos_buffer[0]);
}
if(g_bullish_choch_buffer[0] > ICTSMCIND_VOID_BUFFER_VALUE)
{
Print("Bullish choch new, with price = ", g_bullish_choch_buffer[0]);
}
if(g_bearish_bos_buffer[0] > ICTSMCIND_VOID_BUFFER_VALUE)
{
Print("Bearish bos bos now, with price = ", g_bearish_bos_buffer[0]);
}
if(g_bearish_choch_buffer[0] > ICTSMCIND_VOID_BUFFER_VALUE)
{
Print("Bearish choch new, with price = ", g_bearish_choch_buffer[0]);
}
//---
last_time = new_time;
}
}
//+------------------------------------------------------------------+