source code
source code
// https://fxcodebase.com/code/viewtopic.php?f=38&t=75041
//
+----------------------------------------------------------------------------------
--------------+
//| Copyright © 2024,
Gehtsoft USA LLC |
//|
http://fxcodebase.com |
//
+----------------------------------------------------------------------------------
--------------+
//| Developed
by : Mario Jemic |
//|
mario.jemic@gmail.com |
//|
https://appliedmachinelearning.systems/contact/ |
//
+----------------------------------------------------------------------------------
--------------+
//
+----------------------------------------------------------------------------------
--------------+
//| Our work would not be possible
without your support. |
//
+----------------------------------------------------------------------------------
--------------+
//| Paypal:
https://goo.gl/9Rj74e |
//| Patreon :
http://tiny.cc/1ybwxz |
//| Buy Me a Coffee:
http://tiny.cc/bj7vxz |
//
+----------------------------------------------------------------------------------
--------------+
#property indicator_buffers 0
#property indicator_plots 0
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int c = 0;
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[])
{
int limit;
if(rates_total < 50 + 1)
return(0);
if(rates_total != prev_calculated)
c = 0;
if(c > 2)
limit = rates_total - prev_calculated + 1;
else
limit = MathMin(rates_total - 50, BarLimit);
c++;
iCustom_handle = iCustom(NULL, 0, custom_indicator, BarLimit, 0, 0);
if(notificationsOn > 0)
checkAlert();
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool alerted;
void checkAlert()
{
bool nb = IsNewBar();
if(nb)
alerted = false;
if(notificationsOn == 1 && !alerted)
{
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bull Cross" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
0)
{
Notify(1);
alerted = true;
}
}
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bull Harami" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
0)
{
Notify(2);
alerted = true;
}
}
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bear Cross" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
0)
{
Notify(-1);
alerted = true;
}
}
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bear Harami" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
0)
{
Notify(-2);
alerted = true;
}
}
}
if(notificationsOn == 2 && nb)
{
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bull Cross" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
1)
{
Notify(11);
}
}
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bull Harami" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
1)
{
Notify(22);
}
}
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bear Cross" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
1)
{
Notify(-11);
}
}
for(int i = ObjectsTotal(0) - 1; i >= 0; i--)
{
string n = ObjectName(0, i);
if(ObjectGetString(0, n, OBJPROP_TEXT) == "Bear Harami" &&
iBarShift(Symbol(), Period(), ObjectGetInteger(0, n, OBJPROP_TIME)) ==
1)
{
Notify(-22);
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool IsValue(double val)
{
return val > 0 && val != EMPTY_VALUE;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool IsNewBar()
{
static datetime lastbar;
datetime curbar = (datetime)SeriesInfoInteger(_Symbol, _Period,
SERIES_LASTBAR_DATE);
if(lastbar != curbar)
{
lastbar = curbar;
return true;
}
return false;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Notify(int type)
{
string text = "Bheurekso Pattern: ";
switch(type)
{
case 1:
text += " Bull Cross before bar closes - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
case 2:
text += " Bull Harami before bar closes - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
case -1:
text += " Bear Cross before bar closes - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
case -2:
text += " Bear Harami before bar closes - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
//
case 11:
text += " Bull Cross after closed - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
case 22:
text += " Bull Harami after closed - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
case -11:
text += " Bear Cross after closed - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
case -22:
text += " Bear Harami after closed - " + _Symbol + " " +
GetTimeFrame(_Period);
break;
}
text += " ";
if(desktop_notifications)
Alert(text);
if(push_notifications)
SendNotification(text);
if(email_notifications)
SendMail("MetaTrader Notification", text);
if(sound_notifications)
{
if(type == 1 || type == -1 || type == 11 || type == -11)
PlaySound(sound_file1);
if(type == 2 || type == -2 || type == 22 || type == -22)
PlaySound(sound_file2);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string GetTimeFrame(int lPeriod)
{
switch(lPeriod)
{
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");
default:
return((string)PERIOD_CURRENT);
}
return IntegerToString(lPeriod);
}
//+------------------------------------------------------------------+
//
+----------------------------------------------------------------------------------
--------------+
//| We
appreciate your support. |
//
+----------------------------------------------------------------------------------
--------------+
//| Paypal:
https://goo.gl/9Rj74e |
//| Patreon :
http://tiny.cc/1ybwxz |
//| Buy Me a Coffee:
http://tiny.cc/bj7vxz |
//
+----------------------------------------------------------------------------------
--------------+
//| Cryptocurrency | Network | Address
|
//+------------------------------------------------
+-----------------------------------------------+
//| USDT | ERC20 (ETH Ethereum) |
0xe53aab6bc468a963a02d1319660ee60cf80fc8e7 |
//| USDT | TRC20 (Tron) |
TTBXsfuPm2rk36AkdemY7muNXGjyziC86g |
//| USDT | BEP20 (BSC BNB Smart Chain)|
0xe53aab6bc468a963a02d1319660ee60cf80fc8e7 |
//| USDT | Matic Polygon |
0xe53aab6bc468a963a02d1319660ee60cf80fc8e7 |
//| USDT | SOL Solana |
3nh5rpUKopcYLNU4zGCdUFAkM3iRQq8VVUmuzVG6VDf2 |
//| USDT | ARBITRUM Arbitrum One |
0xe53aab6bc468a963a02d1319660ee60cf80fc8e7 |
//+------------------------------------------------
+-----------------------------------------------+