Indicators Used
0
Views
0
Downloads
0
Favorites
iBollingerAndRSI_Alert
//+------------------------------------------------------------------+
//| iBollingerAndRSI_Alert.mq4 |
//| Copyright 2020, komposter |
//| mailto:komposter@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, komposter"
#property link "mailto:komposter@gmail.com"
#property version "1.00"
#property strict
#property indicator_chart_window
sinput string Signal_Properties = ""; // Signal properties:
input int Signal_Bar = 1; // * Signal bar
input bool AttachScreenshot = true; // * Attach screenshot
sinput string RSI_Properties = ""; // RSI properties:
input int RSI_Period = 14; // * RSI period
input ENUM_APPLIED_PRICE RSI_Price = PRICE_CLOSE; // * RSI price
input double RSI_Level_UP = 71.0; // * RSI level UP
input double RSI_Level_DN = 29.0; // * RSI level DN
sinput string BB_Properties = ""; // BB properties:
input int BB_Period = 20; // * BB period
input double BB_Deviation = 2.0; // * BB deviation
input ENUM_APPLIED_PRICE BB_Price = PRICE_CLOSE; // * BB price
input int BB_Pips = 1; // * BB break points
int MinBars = 0;
int SignalBar = 0;
datetime LastSignal = 0;
int OnInit()
{
MinBars = (RSI_Period > BB_Period ? RSI_Period : BB_Period);
SignalBar = (Signal_Bar >= 0 ? Signal_Bar : 0);
LastSignal = 0;
return(INIT_SUCCEEDED);
}
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 ( rates_total <= MinBars ) return(0);
ArraySetAsSeries( time, true );
ArraySetAsSeries( close, true );
if ( LastSignal <= 0 ) LastSignal = time[0];
if ( time[0] <= LastSignal ) return(rates_total);
if ( iRSI( _Symbol, _Period, RSI_Period, RSI_Price, SignalBar ) >= RSI_Level_UP &&
close[SignalBar] - iBands( _Symbol, _Period, BB_Period, BB_Deviation, 0, BB_Price, MODE_UPPER, SignalBar ) >= BB_Pips*_Point &&
close[SignalBar+1] - iBands( _Symbol, _Period, BB_Period, BB_Deviation, 0, BB_Price, MODE_UPPER, SignalBar+1 ) >= BB_Pips*_Point )
{
LastSignal = time[0];
ToGrammy( "Bolindger-RSI " + _Symbol + " buy at " + DoubleToString( Ask, _Digits ), AttachScreenshot );
}
if ( iRSI( _Symbol, _Period, RSI_Period, RSI_Price, SignalBar ) <= RSI_Level_DN &&
iBands( _Symbol, _Period, BB_Period, BB_Deviation, 0, BB_Price, MODE_LOWER, SignalBar ) - close[SignalBar] >= BB_Pips*_Point &&
iBands( _Symbol, _Period, BB_Period, BB_Deviation, 0, BB_Price, MODE_LOWER, SignalBar+1 ) - close[SignalBar+1] >= BB_Pips*_Point )
{
LastSignal = time[0];
ToGrammy( "Bolindger-RSI " + _Symbol + " sell at " + DoubleToString( Bid, _Digits ), AttachScreenshot );
}
if ( SignalBar > 0 ) LastSignal = time[0];
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include <fxsaber\Event_Message\Event_Message.mqh> // https://www.mql5.com/ru/code/28835
void ToGrammy( const string text, const bool attach_screen, const ushort code = 4000 )
{
Print( text );
union ULD
{
long long_value;
double double_value;
};
ULD grammy_chart_id;
grammy_chart_id.double_value = GlobalVariableGet( "GrammyChartId" );
if ( grammy_chart_id.long_value != 0 )
{
EVENT_MESSAGE::SetEventID( code );
EVENT_MESSAGE::Send( text + (attach_screen ? "attach_screenshot=" + (string)ChartID() : ""),
grammy_chart_id.long_value );
}
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---