ROC_multi
Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
ROC_multi
//+------------------------------------------------------------------+
//|                      Rate of Change for Multi Currency Pairs.mq4 |                                     |
//|                                              Ernst van der Merwe |
//+------------------------------------------------------------------+
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 4

extern int TimeFrame=0;  //1=1minute;5=5minutes;15=15minutes;30=30minutes;60=1Hour;240=4Hour;1440=Daily; 

extern double level1= 300;
extern double level2= 200; 
extern double level3= 100;
extern double level4=-100; 
extern double level5=-200;
extern double level6=-300; 
//---- indicator buffers
double  ROC_EURUSD[];
double  ROC_GBPUSD[];
double  ROC_USDJPY[];
double  ROC_USDCHF[];

string pair1="EURUSD";
string pair2="GBPUSD";
string pair3="USDJPY";
string pair4="USDCHF";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetLevelStyle(STYLE_DOT,1,LightSlateGray); 
   SetLevelValue(0,level1); 
   SetLevelValue(1,level2); 
   SetLevelValue(2,level3); 
   SetLevelValue(3,level4); 
   SetLevelValue(4,level5); 
   SetLevelValue(5,level6); 
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,RoyalBlue);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,LimeGreen);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1,Yellow);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1,Red);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,0);
   SetIndexDrawBegin(1,0);
   SetIndexDrawBegin(2,0);
   SetIndexDrawBegin(3,0);
//---- 
   SetIndexBuffer(0,ROC_EURUSD);
   SetIndexBuffer(1,ROC_GBPUSD);
   SetIndexBuffer(2,ROC_USDJPY);
   SetIndexBuffer(3,ROC_USDCHF);
//---- 
   switch(TimeFrame)
     {
      case 1 : string TimeFrameStr="M1"; break;
      case 5 : TimeFrameStr="M5"; break;
      case 15 : TimeFrameStr="M15"; break;
      case 30 : TimeFrameStr="M30"; break;
      case 60 : TimeFrameStr="H1"; break;
      case 240 : TimeFrameStr="H4"; break;
      case 1440 : TimeFrameStr="D1"; break;
      case 10080 : TimeFrameStr="W1"; break;
      case 43200 : TimeFrameStr="MN1"; break;
      default : TimeFrameStr="";
     }
   IndicatorShortName("ROC "+TimeFrameStr);
   SetIndexLabel(0,pair1);
   SetIndexLabel(1,pair2);
   SetIndexLabel(2,pair3);
   SetIndexLabel(3,pair4);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int      i,limit=1000;

   double   EURUSD[1000];
   double   GBPUSD[1000];
   double   USDJPY[1000];
   double   USDCHF[1000];
    
   int   limitEURUSD=ArraySize(EURUSD);
   ArraySetAsSeries(EURUSD,true);
   for(i=0; i<limitEURUSD; i++)
   EURUSD[i]=((iClose(pair1,TimeFrame,i)-iClose(pair1,TimeFrame,i+1))/iClose(pair1,TimeFrame,i+1))*1000;   

   ROC_EURUSD[1000]=0;
   for(i=limit-1; i>=0; i--)
   ROC_EURUSD[i]=ROC_EURUSD[i+1]+EURUSD[i];

   int   limitGBPUSD=ArraySize(GBPUSD);
   ArraySetAsSeries(GBPUSD,true);
   for(i=0; i<limitGBPUSD; i++)
   GBPUSD[i]=((iClose(pair2,TimeFrame,i)-iClose(pair2,TimeFrame,i+1))/iClose(pair2,TimeFrame,i+1))*1000;   

   ROC_GBPUSD[1000]=0;
   for(i=limit-1; i>=0; i--)
   ROC_GBPUSD[i]=ROC_GBPUSD[i+1]+GBPUSD[i];

   int   limitUSDJPY=ArraySize(USDJPY);
   ArraySetAsSeries(USDJPY,true);
   for(i=0; i<limitUSDJPY; i++)
   USDJPY[i]=((iClose(pair3,TimeFrame,i)-iClose(pair3,TimeFrame,i+1))/iClose(pair3,TimeFrame,i+1))*1000;   

   ROC_USDJPY[1000]=0;
   for(i=limit-1; i>=0; i--)
   ROC_USDJPY[i]=ROC_USDJPY[i+1]+USDJPY[i];
 
   int   limitUSDCHF=ArraySize(USDCHF);
   ArraySetAsSeries(USDCHF,true);
   for(i=0; i<limitUSDCHF; i++)
   USDCHF[i]=((iClose(pair4,TimeFrame,i)-iClose(pair4,TimeFrame,i+1))/iClose(pair4,TimeFrame,i+1))*1000;   

   ROC_USDCHF[1000]=0;
   for(i=limit-1; i>=0; i--)
   ROC_USDCHF[i]=ROC_USDCHF[i+1]+USDCHF[i];
//---- done
   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 ---