Sentiment_Cpair_v2

Author: OnTheRoad
Sentiment_Cpair_v2
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Sentiment_Cpair_v2
//+------------------------------------------------------------------+
//|                        Sentiment_Cpair_alp_x_Flt_GJEJ_DeltaV.mq4 |
//+------------------------------------------------------------------+

#property copyright "OnTheRoad"
#property link      "ontheroad7069@yahoo.com"



#define  MAX_CPAIRS  29
#define  MAX_SPAIRS  9

#define  EUR   0
#define  USD   1
#define  JPY   2
#define  GBP   3
#define  CAD   4
#define  CHF   5
#define  AUD   6
#define  NZD   7

#define  GOLD  8

#property indicator_separate_window
#property indicator_buffers 3

#property indicator_color1 DimGray
#property indicator_color2 SteelBlue
#property indicator_color3 Gainsboro

#property indicator_level1 0
#property indicator_levelcolor   Silver
#property indicator_levelwidth   1
#property indicator_levelstyle   STYLE_DOT

static    color   CNcolor[]={
         Red,
         DarkViolet,
         Chocolate,
         Green,
         DodgerBlue,
         Aqua,
         Chartreuse,
         Gold
         } ;

static    color   colort = Gainsboro;

static   string   CName[]={
         "EUR",
         "USD",
         "JPY",
         "GBP",
         "CAD",
         "CHF",
         "AUD",
         "NZD",
         "GOLD"};
         
//---- input parameters

extern int       MA_Per=12;
extern int       Flt_Per=3;
extern int       Candle_Back=1;
extern int       History=144;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

static int    Pairsel1 , Pairsel2;

static string CPair , sname ;

static string indic_name = "Sentiment_all_v2";

static string symbols[MAX_CPAIRS]={

   "EURUSD",
   "USDJPY",
   "GBPUSD",
   "USDCAD",
   "USDCHF",
   "AUDUSD",
   "NZDUSD",
   
   "EURJPY",
   "EURGBP",
   "EURCAD",
   "EURCHF",
   "EURAUD",
   "EURNZD",
   
   "GBPJPY",
   "CADJPY",
   "CHFJPY",
   "AUDJPY",
   "NZDJPY",
   
   "GBPCAD",
   "GBPCHF",
   "GBPAUD",
   "GBPNZD",
   
   "CADCHF",
   "AUDCAD",
   "NZDCAD",
   
   "AUDCHF",
   "NZDCHF",
   
   "AUDNZD" 

   "GOLD",

   };

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   for( int i=0 ; i<MAX_CPAIRS ; i++ )
      {
      if ( Symbol() == symbols[i] )
       {
       switch (i)
         {
         case  0:       //EURUSD
            Pairsel1 = EUR;
            Pairsel2 = USD;
            break;

         case  1:       //USDJPY
            Pairsel1 = USD;
            Pairsel2 = JPY;
            break;

         case  2:       //GBPUSD
            Pairsel1 = GBP;
            Pairsel2 = USD;
            break;

         case  3:       //USDCAD
            Pairsel1 = USD;
            Pairsel2 = CAD;
            break;

         case  4:       //USDCHF
            Pairsel1 = USD;
            Pairsel2 = CHF;
            break;

         case  5:       //AUDUSD
            Pairsel1 = AUD;
            Pairsel2 = USD;
            break;

         case  6:       //NZDUSD
            Pairsel1 = NZD;
            Pairsel2 = USD;
            break;

         case  7:       //EURJPY
            Pairsel1 = EUR;
            Pairsel2 = JPY;
            break;

         case  8:       //EURGBP
            Pairsel1 = EUR;
            Pairsel2 = GBP;
            break;

         case  9:       //EURCAD
            Pairsel1 = EUR;
            Pairsel2 = CAD;
            break;

         case  10:       //EURCHF
            Pairsel1 = EUR;
            Pairsel2 = CHF;
            break;

         case  11:       //EURAUD
            Pairsel1 = EUR;
            Pairsel2 = AUD;
            break;

         case  12:       //EURNZD
            Pairsel1 = EUR;
            Pairsel2 = NZD;
            break;

         case  13:       //GBPJPY
            Pairsel1 = GBP;
            Pairsel2 = JPY;
            break;

         case  14:       //CADJPY
            Pairsel1 = CAD;
            Pairsel2 = JPY;
            break;

         case  15:       //CHFJPY
            Pairsel1 = CHF;
            Pairsel2 = JPY;
            break;

         case  16:       //AUDJPY
            Pairsel1 = AUD;
            Pairsel2 = JPY;
            break;

         case  17:       //NZDJPY
            Pairsel1 = NZD;
            Pairsel2 = JPY;
            break;

         case  18:       //GBPCAD
            Pairsel1 = GBP;
            Pairsel2 = CAD;
            break;

         case  19:       //GBPCHF
            Pairsel1 = GBP;
            Pairsel2 = CHF;
            break;

         case  20:       //GBPAUD
            Pairsel1 = GBP;
            Pairsel2 = AUD;
            break;

         case  21:       //GBPNZD
            Pairsel1 = GBP;
            Pairsel2 = NZD;
            break;

         case  22:       //CADCHF
            Pairsel1 = CAD;
            Pairsel2 = CHF;
            break;

         case  23:       //AUDCAD
            Pairsel1 = AUD;
            Pairsel2 = CAD;
            break;

         case  24:       //NZDCAD
            Pairsel1 = NZD;
            Pairsel2 = CAD;
            break;

         case  25:       //AUDCHF
            Pairsel1 = AUD;
            Pairsel2 = CHF;
            break;

         case  26:       //NZDCHF
            Pairsel1 = NZD;
            Pairsel2 = CHF;
            break;

         case  27:       //AUDNZD
            Pairsel1 = AUD;
            Pairsel2 = NZD;
            break;

         case  28:       //GOLD
            Pairsel1 = GOLD;
            Pairsel2 = USD;
            break;

         }
       CPair = symbols[i] ;
       sname = "SA_CPair_V2_"+symbols[i] ;
       }
     }

   sname = sname + "_" + MA_Per + "_" + Flt_Per + "_" + Candle_Back;

//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,CNcolor[Pairsel1]);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,CNcolor[Pairsel2]);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2,colort);
   SetIndexBuffer(2,ExtMapBuffer3);
   
   SetLevelValue( 0, 0 ) ;
   SetLevelStyle( STYLE_DOT , 1 , Silver ) ;
   
//----

   IndicatorShortName(sname);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i , j , limit , counted_bars ;

   
   counted_bars = IndicatorCounted() ;

   if(counted_bars<0) return(-1);
   
   if(counted_bars>0) counted_bars--;


   limit = Bars-counted_bars;
   if ( limit > History ) limit = History;
   
   //return;
   
   if ( limit <= 0 ) return(0);
   
   Comment ( " RefreshRates( )...." );
   RefreshRates( );

   if ( MA_Per < 1 ) MA_Per = 1 ;
   if ( Flt_Per < 1 ) Flt_Per = 0 ; 
   if ( Candle_Back < 1 ) Candle_Back = 0;


   for ( i = limit ; i >= 0 ; i -- ) 
      {
      ExtMapBuffer1[i]=0;
      ExtMapBuffer2[i]=0;
      ExtMapBuffer3[i]=0;
      }


   for ( i = limit ; i >= 0 ; i -- ) 
      {
      ExtMapBuffer1[i]= iCustom(NULL,0,indic_name,MA_Per,Flt_Per,Candle_Back,History,Pairsel1,i);
      ExtMapBuffer2[i]= iCustom(NULL,0,indic_name,MA_Per,Flt_Per,Candle_Back,History,Pairsel2,i);
      ExtMapBuffer3[i]=ExtMapBuffer1[i]-ExtMapBuffer2[i];
      }
   

        ObjectCreate( CPair , OBJ_LABEL, WindowFind(sname), 0, 0);
        ObjectSetText(CPair,CPair,12, "Arial Bold");
        ObjectSet(CPair, OBJPROP_COLOR, colort);
        ObjectSet(CPair, OBJPROP_CORNER, 0);
        ObjectSet(CPair, OBJPROP_XDISTANCE, 270);
        ObjectSet(CPair, OBJPROP_YDISTANCE, 3);
        
        ObjectCreate(CName[Pairsel1], OBJ_LABEL, WindowFind(sname), 0, 0);
        ObjectSetText(CName[Pairsel1],CName[Pairsel1],12, "Arial Bold");
        ObjectSet(CName[Pairsel1], OBJPROP_COLOR, CNcolor[Pairsel1]);
        ObjectSet(CName[Pairsel1], OBJPROP_CORNER, 0);
        ObjectSet(CName[Pairsel1], OBJPROP_XDISTANCE, 350);
        ObjectSet(CName[Pairsel1], OBJPROP_YDISTANCE, 3);

        ObjectCreate(CName[Pairsel2], OBJ_LABEL, WindowFind(sname), 0, 0);
        ObjectSetText(CName[Pairsel2],CName[Pairsel2],12, "Arial Bold");
        ObjectSet(CName[Pairsel2], OBJPROP_COLOR, CNcolor[Pairsel2]);
        ObjectSet(CName[Pairsel2], OBJPROP_CORNER, 0);
        ObjectSet(CName[Pairsel2], OBJPROP_XDISTANCE, 390);
        ObjectSet(CName[Pairsel2], OBJPROP_YDISTANCE, 3);
        
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


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