Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
RSIOMA_v2HHLSX__rev_alert
//+--------------------------------------------------------------------------------+
//| RSIOMAv2HHLSX Kalenzo fxtsd.com |
//| Hornet(i-RSI) 2007, FxTSD.com; MetaQuotes Software Corp. ik|
//| Hist & Levels 20/80;30/70 CrossSig web: http://www.fxservice.eu |
//| Rsioma/MaRsioma X sig email: bartlomiej.gorski@gmail.com |
//| please, keep your code tidy. mladen |
//+--------------------------------------------------------------------------------+
// The base for this indicator was orginal RSI attached with Metatrader.
// ^^ removed ^^ :)|-< Hornet
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_minimum -20
#property indicator_maximum 120
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Magenta
#property indicator_color5 DodgerBlue
#property indicator_color6 BlueViolet
#property indicator_color7 SlateBlue
#property indicator_levelcolor SlateGray
#property indicator_width1 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width7 2
#property indicator_level1 100
#property indicator_level4 50
//---- input parameters
//
//
//
//
extern int RSIOMA = 14;
extern int RSIOMA_MODE = MODE_EMA;
extern int RSIOMA_PRICE = PRICE_CLOSE;
extern int Ma_RSIOMA = 21;
extern int Ma_RSIOMA_MODE = MODE_EMA;
extern double BuyTrigger = 80.00;
extern double SellTrigger = 20.00;
extern color BuyTriggerColor = DodgerBlue;
extern color SellTriggerColor = Magenta;
extern bool Alert_On = true;
extern double MainTrendLong = 70.00;
extern double MainTrendShort = 30.00;
extern color MainTrendLongColor = Red;
extern color MainTrendShortColor = Green;
extern double MajorTrend = 50;
extern color marsiomaXSigColor = SlateBlue;
extern int BarsToCount = 500;
//---- buffers
//
//
//
//
double RSIBuffer[];
double MABuffer1[];
double bdn[];
double bup[];
double sdn[];
double sup[];
double marsioma[];
double marsiomaXSig[];
//
//
//
//
//
datetime lastBarTime;
string short_name;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
short_name = StringConcatenate("RSIOMA(",RSIOMA,")");
IndicatorShortName(short_name);
//
//
//
//
//
SetIndexBuffer(0,RSIBuffer);
SetIndexBuffer(2,bup);
SetIndexBuffer(1,bdn);
SetIndexBuffer(3,sdn);//Magnet
SetIndexBuffer(4,sup);//DodgerBlue
SetIndexBuffer(5,marsioma);
SetIndexBuffer(6,marsiomaXSig);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexStyle(4,DRAW_HISTOGRAM);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,159);
SetIndexLabel(0,"Rsioma");
SetIndexLabel(5,"MaRsioma");
SetIndexLabel(1,"TrendDn");
SetIndexLabel(2,"TrendUp");
SetIndexLabel(6,"Up/DnXsig");
//
//
// additional buffer(s)
//
//
BarsToCount = MathMin(Bars,BarsToCount);
ArrayResize( MABuffer1,BarsToCount);
ArraySetAsSeries(MABuffer1,true);
lastBarTime = EMPTY_VALUE;
//
//
//
//
//
drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);
drawLine(SellTrigger,"SellTrigger", SellTriggerColor );
drawLine(MainTrendLong,"MainTrendLong", MainTrendLongColor );
drawLine(MainTrendShort,"MainTrendShort",MainTrendShortColor );
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,i=0;
//
//
//
//
//
if(counted_bars<0) return(-1);
if(lastBarTime != Time[0]) {
lastBarTime = Time[0];
ArrayInitialize(MABuffer1,0.0);
counted_bars = 0;
}
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
limit=MathMin(limit,BarsToCount-1);
//
//
//
//
//
for(i=limit;i>=0;i--) MABuffer1[i]=iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i);
for(i=limit;i>=0;i--)
{
RSIBuffer[i]=iRSIOnArray(MABuffer1,0,RSIOMA,i);
//
//
//
//
//
bup[i] = EMPTY_VALUE; bdn[i] = EMPTY_VALUE;
sup[i] = EMPTY_VALUE; sdn[i] = EMPTY_VALUE;
if(RSIBuffer[i] > 50) bup[i] = 6;
if(RSIBuffer[i] < 50) bdn[i] = -6;
if(RSIBuffer[i] > MainTrendLong) bup[i] = 12;
if(RSIBuffer[i] < MainTrendShort) bdn[i] = -12;
if(RSIBuffer[i]<20 && RSIBuffer[i]>RSIBuffer[i+1]) sup[i] = -3;
if(RSIBuffer[i]>80 && RSIBuffer[i]<RSIBuffer[i+1]) sdn[i] = 4;
if(RSIBuffer[i]>20 && RSIBuffer[i+1]<=20) sup[i] = 5;
if(RSIBuffer[i+1]>=80 && RSIBuffer[i]<80) sdn[i] = -5;
if(RSIBuffer[i+1]<=MainTrendShort && RSIBuffer[i]>MainTrendShort) sup[i] = 12;
if(RSIBuffer[i]<MainTrendLong && RSIBuffer[i+1]>=MainTrendLong) sdn[i] = -12;
}
//
//
//
//
//
for(i=limit;i>=0;i--)
{
marsioma[i] = iMAOnArray(RSIBuffer,0,Ma_RSIOMA,0,Ma_RSIOMA_MODE,i);
marsiomaXSig[i] = EMPTY_VALUE;
if(RSIBuffer[i+1]<=marsioma[i+1]&&RSIBuffer[i]>marsioma[i]) marsiomaXSig[i] = -8;
if(RSIBuffer[i+1]>=marsioma[i+1]&&RSIBuffer[i]<marsioma[i]) marsiomaXSig[i] = 8;
if(Alert_On==true)
{
if(RSIBuffer[i+1]<=marsioma[i+1]&&RSIBuffer[i]>marsioma[i])
AlertOnce(Symbol()+ ":" + " - Up Signal",1);
if(RSIBuffer[i+1]>=marsioma[i+1]&&RSIBuffer[i]<marsioma[i])
AlertOnce(Symbol()+ ":" + " - Down Signal",2);
}}
for (i=0;i<indicator_buffers;i++) SetIndexDrawBegin(i,Bars-BarsToCount);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void drawLine(double lvl,string name, color Col )
{
ObjectDelete(name);
ObjectCreate(name, OBJ_HLINE, WindowFind(short_name), Time[0], lvl,Time[0], lvl);
ObjectSet(name , OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name , OBJPROP_COLOR, Col);
ObjectSet(name , OBJPROP_WIDTH, 1);
}
bool AlertOnce(string alert_msg, int ref)
{
static int LastAlert_1 = 0;
static int LastAlert_2 = 0;
static int LastAlert_3 = 0;
static int LastAlert_4 = 0;
switch(ref)
{
case 1:
if( LastAlert_1 == 0 || LastAlert_1 < Bars )
{
Alert(alert_msg);
LastAlert_1 = Bars;
return (1);
}
break;
case 2:
if( LastAlert_2 == 0 || LastAlert_2 < Bars )
{
Alert(alert_msg);
LastAlert_2 = Bars;
return (1);
}
break;
case 3:
if( LastAlert_3 == 0 || LastAlert_3 < Bars )
{
Alert(alert_msg);
LastAlert_3 = Bars;
return (1);
}
break;
case 4:
if( LastAlert_4 == 0 || LastAlert_4 < Bars )
{
Alert(alert_msg);
LastAlert_4 = Bars;
return (1);
}
break;
}
}
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
---