0% found this document useful (0 votes)
26 views

source code

This document outlines a custom indicator developed by Mario Jemic for MetaTrader, which includes features for notifications on specific trading patterns such as Bull Cross and Bear Harami. It provides options for desktop, email, push, and sound notifications, as well as the ability to customize alert settings. The document also includes links for support and contributions to the developer's work.

Uploaded by

Abdullah Akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

source code

This document outlines a custom indicator developed by Mario Jemic for MetaTrader, which includes features for notifications on specific trading patterns such as Bull Cross and Bear Harami. It provides options for desktop, email, push, and sound notifications, as well as the ability to customize alert settings. The document also includes links for support and contributions to the developer's work.

Uploaded by

Abdullah Akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

// More information about this indicator can be found at:

// 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 copyright "Copyright © 2024, Gehtsoft USA LLC"


#property link "http://fxcodebase.com"
#property version "1.0"
#property strict
#property indicator_chart_window

#property indicator_buffers 0
#property indicator_plots 0

input int BarLimit = 50; // Calc Bars


enum alert
{
Off = 0, // Off
Current = 1, // At current bar
Previous = 2 // At previous closed bar
};
input alert notificationsOn = 2; // Notifications
input bool desktop_notifications = true; // Desktop MT4
notifications
input bool email_notifications = false; // Email notifications
input bool push_notifications = false; // Push mobile
notifications
input bool sound_notifications = false; // Sound notifications
input string sound_file1 = "Tick.wav"; // Choose a sound file
for "cross" notifications
input string sound_file2 = "Tick.wav"; // Choose a sound file
for "harami" notifications
//
int iCustom_handle;
string custom_indicator = "#4X Bheurekso Pattern";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
ResetLastError();
if(custom_indicator != "")
{
iCustom_handle = iCustom(NULL, 0, custom_indicator, BarLimit, 0, 0);
if(iCustom_handle < 0)
{
Alert("Please install the: " + custom_indicator + " indicator to the
MQL4/Indicators folder");
}
}
return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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 |
//+------------------------------------------------
+-----------------------------------------------+

You might also like