Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Special RSI ARROW
//+------------------------------------------------------------------+
//| Special_RSI_ARROW.mq4 |
//| Copyright © 2009, leMai |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, leMai"
//----
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Green
#property indicator_color2 White
#property indicator_color3 Blue
#property indicator_color4 LimeGreen
#property indicator_color5 Red
//----
extern int RSIPeriod1 = 14;
extern int RSIPeriod2 = 28;
extern int Cross1 = 10;
extern double difference = 2.0;
extern int Magic = 1;
extern bool Draw_Arrow = true;
extern int WidthArrow = 1;
extern int ArrowUp = 233;
extern int ArrowDown = 234;
extern color colorup = DodgerBlue;
extern color colordown = Red;
double ind_buffer1[];
double MABuffer1[];
double Cross[];
double UpArrow[];
double DnArrow[];
double now=1,last=0;
int direction=0;
int count;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(3, DRAW_ARROW);
SetIndexArrow(3, 233);
SetIndexStyle(4, DRAW_ARROW);
SetIndexArrow(4, 234);
//----
SetIndexBuffer(0, ind_buffer1);
SetIndexBuffer(1, MABuffer1);
SetIndexBuffer(2, Cross);
SetIndexBuffer(3, UpArrow);
SetIndexBuffer(4, DnArrow);
//----
IndicatorShortName(WindowExpertName()+"("+Magic+")");
Comment("leMai");
return(0);
}
int deinit(){
DeleteObjects();
ObjectsDeleteAll(0,OBJ_ARROW);
return(0);}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
DeleteObjects();
double RSI1,RSI2;
int Limit, i, counted_bars = IndicatorCounted();
//----
if(counted_bars < 0)
return(-1);
//----
if(counted_bars > 0)
counted_bars--;
Limit=ArraySize(MABuffer1);
for(i=Limit; i>=0; i--)
{
RSI1 = iRSI(NULL, 0, RSIPeriod1, PRICE_CLOSE, i);
RSI2 = iRSI(NULL, 0, RSIPeriod2, PRICE_CLOSE, i);
MABuffer1[i] = (RSI1-RSI2);
}
for(i=Limit; i>=0; i--)
{
ind_buffer1[i] = iMAOnArray(MABuffer1,0,14,0,MODE_EMA,i);
}
for(i=Limit; i>=0; i--)
{
Cross[i]=iMAOnArray(ind_buffer1,Bars,Cross1,0,MODE_EMA,i);
now=Cross[i];
if(now>(last+(difference/1000)))
{
if(direction<1)
{
if (Draw_Arrow ){
DrawArrow(i,"Up" );
}
UpArrow[i]=Cross[i];
direction=1;
}
}
else
if(now<(last-(difference/1000)))
{
if(direction>-1)
{
if (Draw_Arrow ){
DrawArrow(i,"Down" );
}
DnArrow[i]=Cross[i];
direction=-1;
}
}
last=Cross[i];
}
for(i=Limit; i>=0; i--)
{
MABuffer1[i]=0;
}
return(0);
}
///////////////////////////////////////////////
// DrawArrowFunction //
/////////////////////////////////////////////
void DrawArrow(int i,string type)
{ count++;
string name = StringConcatenate(WindowExpertName(),count);
ObjectCreate(name+Magic,OBJ_ARROW,0,Time[i],0);
if (type=="Up")
{
ObjectSet(name+Magic,OBJPROP_PRICE1,Low[i]-iATR(NULL,0,20,i)/2.0);
ObjectSet(name+Magic,OBJPROP_ARROWCODE,ArrowUp);
ObjectSet(name+Magic,OBJPROP_COLOR,colorup);
ObjectSet(name+Magic,OBJPROP_WIDTH,WidthArrow);
}
else if (type=="Down")
{
ObjectSet(name+Magic,OBJPROP_PRICE1,High[i]+ iATR(NULL,0,20,i)/2.0);
ObjectSet(name+Magic,OBJPROP_ARROWCODE,ArrowDown);
ObjectSet(name+Magic,OBJPROP_WIDTH,WidthArrow);
ObjectSet(name+Magic,OBJPROP_COLOR,colordown);
}
}
///////////////////////////////////////////////
// DeleteFunction //
/////////////////////////////////////////////
void DeleteObjects()
{
while(count>0) {
ObjectDelete(StringConcatenate(WindowExpertName(),count));
count--; }
}
//+------------------------------------------------------------------+
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
---