RSI-R2_voting_Ron4a

Author: Ron Thompson
RSI-R2_voting_Ron4a
Indicators Used
Relative strength index
0 Views
0 Downloads
0 Favorites
RSI-R2_voting_Ron4a
//+-----------------------------------+
//| RSI multi-period voting indicator | 
//+-----------------------------------+

#property copyright "Ron Thompson"
#property link      "http://www.ForexMT4.com/forex"

// This INDICATOR is NEVER to be SOLD individually 
// This INDICATOR is NEVER to be INCLUDED as part of a collection that is SOLD

#property indicator_chart_window
#property indicator_buffers 6


//---- input parameters
extern int    numvotes              =  20;
extern int    votecount             =   0;

extern int    Day1_Rsi_low          =  65;
extern int    Day1_Rsi_hi           =  35;

extern bool   ObjDelete             =  true;


int uniq=0;
int bartime;


//+------+
//| Init |
//+------+
int init()
  {
  }


//+------+
//|DeInit|
//+------+
int deinit()
  {
   if(ObjDelete)ObjectsDeleteAll();
  } 


//+------+
//|Start |
//+------+
int start()
  {
   int     buy_vote;
   int     sell_vote;
   int     voting;
   
   double  RSI1=0;
   double  RSI2=0;
   double  RSI3=0;

   // draw once at open of bar for all previous bars 
   if(bartime!=Time[0])
     {
      bartime=Time[0];

      for (int i=Bars; i>=0; i--)
        {
         buy_vote=0;
         sell_vote=0;
         for(voting=numvotes+1; voting>=2; voting--)
           { 
            RSI1 = iRSI(Symbol(), PERIOD_D1, voting, PRICE_OPEN, i+0);
            RSI2 = iRSI(Symbol(), PERIOD_D1, voting, PRICE_OPEN, i+1);
            RSI3 = iRSI(Symbol(), PERIOD_D1, voting, PRICE_OPEN, i+2);
            if (RSI1 < Day1_Rsi_low && RSI2 < RSI1 && RSI3 < RSI2 )
              {
               buy_vote++;
              }
            if (RSI1 > Day1_Rsi_hi && RSI2 > RSI1 && RSI3 > RSI2 )
              {
               sell_vote++;
              }
           }//for voting
     
         if (  buy_vote>votecount )
           {
            ObjectCreate("myx"+DoubleToStr(uniq,0), OBJ_TEXT, 0, Time[i], Open[i] );
            ObjectSetText("myx"+DoubleToStr(uniq,0),DoubleToStr(buy_vote,0),15,"Arial",White);
            uniq++;
           }

         if ( sell_vote>votecount )
           {
            ObjectCreate("myx"+DoubleToStr(uniq,0), OBJ_TEXT, 0, Time[i], Open[i] );
            ObjectSetText("myx"+DoubleToStr(uniq,0),DoubleToStr(sell_vote,0),15,"Arial",Red);
            uniq++;
           }

        }//for i
     
     }//if bartime

  }//start

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---