draw a currency strength line

To add comments, please log in or register
SirFency
173
SirFency  

I have been working on a custom indicator (currency strength) as my first programming project. I am doing quite well.

I am trying to mimic this http://completecurrencytrader.com/currency-strength-indicator.html

I have gotten to the point now that my gathered data is matching the graphs endpoint which I'm very happy about. Now I would like to show it graphically in my platform. Could someone please point me in the right direction as to how I would draw these lines? I looked at using the iMA or the iMACD but i'm not sure that is the correct approach.

I'm also wondering about when I do draw the lines how do I add more data in between the iopen and the current ask so I can more accurately mimic the online graph I am referencing. I assume if I just draw the lines based of the data i'm currently collecting they will just be straight lines. they will still work but wont be as helpful as they could be if I sample more candles from the iopen to the current ask.


Please keep in mind I'm brand new to programming and using this forum as another educational tool to help me grow as a programmer.  Here is my code if you want to look at it.


//+------------------------------------------------------------------+
//|                               My_Currency_Strength_Indicator.mq4 |
//|                                               Erick_Fenstermaker |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Erick_Fenstermaker"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 clrPurple
#property indicator_color2 clrRed
#property indicator_color3 clrOrange
#property indicator_color4 clrWhite
#property indicator_color5 clrBlue
#property indicator_color6 clrGreen
#property indicator_color7 clrLightBlue
#property indicator_color8 clrYellow
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 2
#property indicator_width7 2
#property indicator_width8 2

double EUR_Band[];





//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
SetIndexBuffer (0,EUR_Band);
SetIndexStyle (0, DRAW_LINE);
SetIndexLabel (0, "EUR Band: ");

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
int counted_bars = IndicatorCounted();
int limit = Bars - counted_bars;
for(int i = 0; i < limit; i++);
{

}

//Sets how far you look into the past (15 min incremints 4 = 1hr)
   int lookBack = 16 + 1;


//+------------------------------------------------------------------+
//|           Gathers the open and current price info                |
//+------------------------------------------------------------------+

//Gathers the EUR Symbol open values from the past   
   double lookBackEURGBP = iOpen("EURGBP",PERIOD_M15,lookBack);
   double lookBackEURAUD = iOpen("EURAUD",PERIOD_M15,lookBack);
   double lookBackEURNZD = iOpen("EURNZD",PERIOD_M15,lookBack);
   double lookBackEURUSD = iOpen("EURUSD",PERIOD_M15,lookBack);
   double lookBackEURCAD = iOpen("EURCAD",PERIOD_M15,lookBack);
   double lookBackEURCHF = iOpen("EURCHF",PERIOD_M15,lookBack);
   double lookBackEURJPY = iOpen("EURJPY",PERIOD_M15,lookBack);

//Gathers the GBP Symbol open values from the past   
   double lookBackGBPAUD = iOpen("GBPAUD",PERIOD_M15,lookBack);
   double lookBackGBPNZD = iOpen("GBPNZD",PERIOD_M15,lookBack);
   double lookBackGBPUSD = iOpen("GBPUSD",PERIOD_M15,lookBack);
   double lookBackGBPCAD = iOpen("GBPCAD",PERIOD_M15,lookBack);
   double lookBackGBPCHF = iOpen("GBPCHF",PERIOD_M15,lookBack);
   double lookBackGBPJPY = iOpen("GBPJPY",PERIOD_M15,lookBack);

//Gathers the AUD Symbol open values from the past   
   double lookBackAUDNZD = iOpen("AUDNZD",PERIOD_M15,lookBack);
   double lookBackAUDUSD = iOpen("AUDUSD",PERIOD_M15,lookBack);
   double lookBackAUDCAD = iOpen("AUDCAD",PERIOD_M15,lookBack);
   double lookBackAUDCHF = iOpen("AUDCHF",PERIOD_M15,lookBack);
   double lookBackAUDJPY = iOpen("AUDJPY",PERIOD_M15,lookBack);

//Gathers the NZD Symbol open values from the past   
   double lookBackNZDUSD = iOpen("NZDUSD",PERIOD_M15,lookBack);
   double lookBackNZDCAD = iOpen("NZDCAD",PERIOD_M15,lookBack);
   double lookBackNZDCHF = iOpen("NZDCHF",PERIOD_M15,lookBack);
   double lookBackNZDJPY = iOpen("NZDJPY",PERIOD_M15,lookBack);

//Gathers the USD Symbol open values from the past   
   double lookBackUSDCAD = iOpen("USDCAD",PERIOD_M15,lookBack);
   double lookBackUSDCHF = iOpen("USDCHF",PERIOD_M15,lookBack);
   double lookBackUSDJPY = iOpen("USDJPY",PERIOD_M15,lookBack);

//Gathers the CAD Symbol open values from the past   
   double lookBackCADCHF = iOpen("CADCHF",PERIOD_M15,lookBack);
   double lookBackCADJPY = iOpen("CADJPY",PERIOD_M15,lookBack);

//Gathers the CHF Symbol open values from the past   
   double lookBackCHFJPY =iOpen("CHFJPY",PERIOD_M15,lookBack);

//Gathers the current EUR Symbol Ask Values
   double EURGBP = SymbolInfoDouble("EURGBP",SYMBOL_ASK);
   double EURAUD = SymbolInfoDouble("EURAUD",SYMBOL_ASK);
   double EURNZD = SymbolInfoDouble("EURNZD",SYMBOL_ASK);
   double EURUSD = SymbolInfoDouble("EURUSD",SYMBOL_ASK);
   double EURCAD = SymbolInfoDouble("EURCAD",SYMBOL_ASK);
   double EURCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double EURJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the current GBP Symbol Ask Values
   double GBPAUD = SymbolInfoDouble("GBPAUD",SYMBOL_ASK);
   double GBPNZD = SymbolInfoDouble("GBPNZD",SYMBOL_ASK);
   double GBPUSD = SymbolInfoDouble("GBPUSD",SYMBOL_ASK);
   double GBPCAD = SymbolInfoDouble("GBPCAD",SYMBOL_ASK);
   double GBPCHF = SymbolInfoDouble("GBPCHF",SYMBOL_ASK);
   double GBPJPY = SymbolInfoDouble("GBPJPY",SYMBOL_ASK);
//Gathers the current AUD Symbol Ask Values
   double AUDNZD = SymbolInfoDouble("AUDNZD",SYMBOL_ASK);
   double AUDUSD = SymbolInfoDouble("AUDUSD",SYMBOL_ASK);
   double AUDCAD = SymbolInfoDouble("AUDCAD",SYMBOL_ASK);
   double AUDCHF = SymbolInfoDouble("AUDCHF",SYMBOL_ASK);
   double AUDJPY = SymbolInfoDouble("AUDJPY",SYMBOL_ASK);
//Gathers the current NZD Symbol Ask Values
   double NZDUSD = SymbolInfoDouble("NZDUSD",SYMBOL_ASK);
   double NZDCAD = SymbolInfoDouble("NZDCAD",SYMBOL_ASK);
   double NZDCHF = SymbolInfoDouble("NZDCHF",SYMBOL_ASK);
   double NZDJPY = SymbolInfoDouble("NZDJPY",SYMBOL_ASK);
//Gathers the current USD Symbol Ask Values
   double USDCAD = SymbolInfoDouble("USDCAD",SYMBOL_ASK);
   double USDCHF = SymbolInfoDouble("USDCHF",SYMBOL_ASK);
   double USDJPY = SymbolInfoDouble("USDJPY",SYMBOL_ASK);
//Gathers the current CAD Symbol Ask Values
   double CADCHF = SymbolInfoDouble("CADCHF",SYMBOL_ASK);
   double CADJPY = SymbolInfoDouble("CADJPY",SYMBOL_ASK);
//Gathers the current CHF Symbol Ask Values
   double CHFJPY=SymbolInfoDouble("CHFJPY",SYMBOL_ASK);
   
   
//+------------------------------------------------------------------+
//|          Calculates the percent of change over time              |
//+------------------------------------------------------------------+
   

//calculating the percent change from the past open till the current ask of the EUR values
   double perEURGBP = (EURGBP - lookBackEURGBP)/lookBackEURGBP*100;
   double perEURAUD = (EURAUD - lookBackEURAUD)/lookBackEURAUD*100;
   double perEURNZD = (EURNZD - lookBackEURNZD)/lookBackEURNZD*100;
   double perEURUSD = (EURUSD - lookBackEURUSD)/lookBackEURUSD*100;
   double perEURCAD = (EURCAD - lookBackEURCAD)/lookBackEURCAD*100;
   double perEURCHF = (EURCHF - lookBackEURCHF)/lookBackEURCHF*100;
   double perEURJPY = (EURJPY - lookBackEURJPY)/lookBackEURJPY*100;

//calculating the percent change from the past open till the current ask of the GBP values
   double perGBPAUD = (GBPAUD - lookBackGBPAUD)/lookBackGBPAUD*100;
   double perGBPNZD = (GBPNZD - lookBackGBPNZD)/lookBackGBPNZD*100;
   double perGBPUSD = (GBPUSD - lookBackGBPUSD)/lookBackGBPUSD*100;
   double perGBPCAD = (GBPCAD - lookBackGBPCAD)/lookBackGBPCAD*100;
   double perGBPCHF = (GBPCHF - lookBackGBPCHF)/lookBackGBPCHF*100;
   double perGBPJPY = (GBPJPY - lookBackGBPJPY)/lookBackGBPJPY*100;

//calculating the percent change from the past open till the current ask of the AUD values
   double perAUDNZD = (AUDNZD - lookBackAUDNZD)/lookBackAUDNZD*100;
   double perAUDUSD = (AUDUSD - lookBackAUDUSD)/lookBackAUDUSD*100;
   double perAUDCAD = (AUDCAD - lookBackAUDCAD)/lookBackAUDCAD*100;
   double perAUDCHF = (AUDCHF - lookBackAUDCHF)/lookBackAUDCHF*100;
   double perAUDJPY = (AUDJPY - lookBackAUDJPY)/lookBackAUDJPY*100;

//calculating the percent change from the past open till the current ask of the NZD values
   double perNZDUSD = (NZDUSD - lookBackNZDUSD)/lookBackNZDUSD*100;
   double perNZDCAD = (NZDCAD - lookBackNZDCAD)/lookBackNZDCAD*100;
   double perNZDCHF = (NZDCHF - lookBackNZDCHF)/lookBackNZDCHF*100;
   double perNZDJPY = (NZDJPY - lookBackNZDJPY)/lookBackNZDJPY*100;

//calculating the percent change from the past open till the current ask of the USD values
   double perUSDCAD = (USDCAD - lookBackUSDCAD)/lookBackUSDCAD*100;
   double perUSDCHF = (USDCHF - lookBackUSDCHF)/lookBackUSDCHF*100;
   double perUSDJPY = (USDJPY - lookBackUSDJPY)/lookBackUSDJPY*100;

//calculating the percent change from the past open till the current ask of the CAD values
   double perCADCHF = (CADCHF - lookBackCADCHF)/lookBackCADCHF*100;
   double perCADJPY = (CADJPY - lookBackCADJPY)/lookBackCADJPY*100;

//calculating the percent change from the past open till the current ask of the JPY values
   double perCHFJPY=(CHFJPY-lookBackCHFJPY)/lookBackCHFJPY*100;

//Adds all the percentages from all the pairs together with thier respective pairs
   double perEUR = (perEURGBP + perEURAUD + perEURNZD + perEURUSD + perEURCAD + perEURCHF + perEURJPY);
   double perGBP = ((-perEURGBP) + perGBPAUD + perGBPNZD + perGBPUSD + perGBPCAD + perGBPCHF + perGBPJPY);
   double perAUD = (((-perEURAUD) + (-perGBPAUD)) + perAUDNZD + perAUDUSD + perAUDCAD + perAUDCHF + perAUDJPY);
   double perNZD = (((-perEURNZD) + (-perGBPNZD) + (-perAUDNZD)) + perNZDUSD + perNZDCAD + perNZDCHF + perNZDJPY);
   double perUSD = (((-perEURUSD) + (-perGBPUSD) + (-perAUDUSD) + (-perNZDUSD)) + perUSDCAD + perUSDCHF + perUSDJPY);
   double perCAD = (((-perEURCAD) + (-perGBPCAD) + (-perAUDCAD) + (-perNZDCAD) + (-perUSDCAD)) + perCADCHF + perCADJPY);
   double perCHF = (((-perEURCHF) + (-perGBPCHF) + (-perAUDCHF) + (-perNZDCHF) + (-perUSDCHF) + (-perCADCHF)) + perCHFJPY);
   double perJPY = ((-perEURJPY) + (-perGBPJPY) + (-perAUDJPY) + (-perNZDJPY) + (-perUSDJPY) + (-perCADJPY) + (-perCHFJPY));
   
   
//+------------------------------------------------------------------+
//|          Currently printing results to the experts log           |
//+------------------------------------------------------------------+


   perEUR = NormalizeDouble(perEUR,2);
   Print("rounded percent of the eur: ",perEUR);
   perGBP = NormalizeDouble(perGBP,2);
   Print("rounded percent of the gbp: ",perGBP);
   perAUD = NormalizeDouble(perAUD,2);
   Print("rounded percent of the aud: ",perAUD);
   perNZD = NormalizeDouble(perNZD,2);
   Print("rounded percent of the nzd: ",perNZD);
   perUSD = NormalizeDouble(perUSD,2);
   Print("rounded percent of the usd: ",perUSD);
   perCAD = NormalizeDouble(perCAD,2);
   Print("rounded percent of the cad: ",perCAD);
   perCHF = NormalizeDouble(perCHF,2);
   Print("rounded percent of the chf: ",perCHF);
   perJPY = NormalizeDouble(perJPY,2);
   Print("rounded percent of the jpy: ",perJPY);
   
   Print("Sum of all percent changes: ", perEUR + perGBP + perAUD + perNZD + perUSD + perCAD + perCHF + perJPY);

 
   return(rates_total);
  }
//+------------------------------------------------------------------+
Currency Strength Indicator
  • completecurrencytrader.com
Select TF:  Look Back:
William Roeder
20248
William Roeder  

SirFency:

I am trying to mimic this http://completecurrencytrader.com/currency-strength-indicator.html

//|                               My_Currency_Strength_Indicator.mq4 |
I'm also wondering about when I do draw the lines how do I add more data in between the iopen and the current ask
  1. Please use the link button Use the link button See the difference?  http://completecurrencytrader.com/currency-strength-indicator.html
              Messages Editor

  2. Why did you post your MT4 question in the Root / MT5 Indicators section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. Stop using SymbolInfoDouble and start using iClose. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

Alain Verleyen
38752
Alain Verleyen  
whroeder1:
  1. ...
  2. ...
  3. Stop using SymbolInfoDouble and start using iClose. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

Why is that ?

Actually the recommended way to get current market price is SymbolInfoTick().

SymbolInfoTick - Market Info - MQL4 Reference
SymbolInfoTick - Market Info - MQL4 Reference
  • docs.mql4.com
SymbolInfoTick - Market Info - MQL4 Reference
SirFency
173
SirFency  
Thank you for the info about using the forum. I'll keep getting better. I will switch to SymbolInfoTick and try iClose as well to see what happens. I'm not seeing any problems as of yet with the SymbolInfoDouble but I want my code to be done properly. No sense in learning something the wrong way. I'm still not sure how to go about drawing the lines. Where do I even look to figure this out? So far I'm only seeing lines that are based off already existing oscillators.
William Roeder
20248
William Roeder  
Alain Verleyen: Why is that ?

OP wants other bars also.

SirFency
173
SirFency  

OK I have made some progress however I'm still not there. Like I suspected Im getting a straight line. I have adjusted the code to use iClose rather than SymbolInfoDouble. I am thinking I may need to create a custom array that stores all the values from the lookBack till the current price. I'm not sure how to do this. I'm stalling out. I'm trying my best to comment the hell out of this thing to make life easier for those in the know to help.

//+------------------------------------------------------------------+
//|                               My_Currency_Strength_Indicator.mq4 |
//|                                               Erick_Fenstermaker |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Erick_Fenstermaker"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//Opening a separate window and setting the parameters of the window extents
#property indicator_separate_window
#property indicator_maximum 3.5
#property indicator_minimum -3.5
#property indicator_level1 0
#property indicator_level2 2
#property indicator_level3 -2
//Setting up the memory allocation and default settings for the indicator lines
#property indicator_buffers 8
#property indicator_color1 clrPurple
#property indicator_color2 clrRed
#property indicator_color3 clrOrange
#property indicator_color4 clrWhite
#property indicator_color5 clrBlue
#property indicator_color6 clrGreen
#property indicator_color7 clrLightBlue
#property indicator_color8 clrYellow
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 2
#property indicator_width7 2
#property indicator_width8 2

//Declaring the arrays that will draw the lines for the indicator
double EUR_Band[];





//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
SetIndexBuffer (0, EUR_Band);
SetIndexStyle (0, DRAW_LINE);
SetIndexLabel (0, "EUR Band: ");

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

//Used with SimbolInfoTick to get the price at every tick
//MqlTick last_tick;
  

   
//int counted_bars = IndicatorCounted();
//int limit = Bars - counted_bars;


//for(int i = 0; i < lookBack; i++)
//{
//   int    counted_bars=IndicatorCounted();



//Sets how far you look into the past (15 min incremints 4 = 1hr)
int lookBack = 16 + 1;


//+------------------------------------------------------------------+
//|           Gathers the open and current price info                |
//+------------------------------------------------------------------+

//Gathers the EUR Symbol open values from the past   
   double lookBackEURGBP = iOpen("EURGBP",PERIOD_M15,lookBack);
   double lookBackEURAUD = iOpen("EURAUD",PERIOD_M15,lookBack);
   double lookBackEURNZD = iOpen("EURNZD",PERIOD_M15,lookBack);
   double lookBackEURUSD = iOpen("EURUSD",PERIOD_M15,lookBack);
   double lookBackEURCAD = iOpen("EURCAD",PERIOD_M15,lookBack);
   double lookBackEURCHF = iOpen("EURCHF",PERIOD_M15,lookBack);
   double lookBackEURJPY = iOpen("EURJPY",PERIOD_M15,lookBack);

//Gathers the GBP Symbol open values from the past   
   double lookBackGBPAUD = iOpen("GBPAUD",PERIOD_M15,lookBack);
   double lookBackGBPNZD = iOpen("GBPNZD",PERIOD_M15,lookBack);
   double lookBackGBPUSD = iOpen("GBPUSD",PERIOD_M15,lookBack);
   double lookBackGBPCAD = iOpen("GBPCAD",PERIOD_M15,lookBack);
   double lookBackGBPCHF = iOpen("GBPCHF",PERIOD_M15,lookBack);
   double lookBackGBPJPY = iOpen("GBPJPY",PERIOD_M15,lookBack);

//Gathers the AUD Symbol open values from the past   
   double lookBackAUDNZD = iOpen("AUDNZD",PERIOD_M15,lookBack);
   double lookBackAUDUSD = iOpen("AUDUSD",PERIOD_M15,lookBack);
   double lookBackAUDCAD = iOpen("AUDCAD",PERIOD_M15,lookBack);
   double lookBackAUDCHF = iOpen("AUDCHF",PERIOD_M15,lookBack);
   double lookBackAUDJPY = iOpen("AUDJPY",PERIOD_M15,lookBack);

//Gathers the NZD Symbol open values from the past   
   double lookBackNZDUSD = iOpen("NZDUSD",PERIOD_M15,lookBack);
   double lookBackNZDCAD = iOpen("NZDCAD",PERIOD_M15,lookBack);
   double lookBackNZDCHF = iOpen("NZDCHF",PERIOD_M15,lookBack);
   double lookBackNZDJPY = iOpen("NZDJPY",PERIOD_M15,lookBack);

//Gathers the USD Symbol open values from the past   
   double lookBackUSDCAD = iOpen("USDCAD",PERIOD_M15,lookBack);
   double lookBackUSDCHF = iOpen("USDCHF",PERIOD_M15,lookBack);
   double lookBackUSDJPY = iOpen("USDJPY",PERIOD_M15,lookBack);

//Gathers the CAD Symbol open values from the past   
   double lookBackCADCHF = iOpen("CADCHF",PERIOD_M15,lookBack);
   double lookBackCADJPY = iOpen("CADJPY",PERIOD_M15,lookBack);

//Gathers the CHF Symbol open values from the past   
   double lookBackCHFJPY =iOpen("CHFJPY",PERIOD_M15,lookBack);

//Gathers the current EUR Symbol Ask Values
   double EURGBP = iClose("EURGBP", PERIOD_M15, lookBack);
   double EURAUD = iClose("EURAUD", PERIOD_M15, lookBack);
   double EURNZD = iClose("EURNZD", PERIOD_M15, lookBack);
   double EURUSD = iClose("EURUSD", PERIOD_M15, lookBack);
   double EURCAD = iClose("EURCAD", PERIOD_M15, lookBack);
   double EURCHF = iClose("EURCHF", PERIOD_M15, lookBack);
   double EURJPY = iClose("EURJPY", PERIOD_M15, lookBack);
//Gathers the current GBP Symbol Ask Values
   double GBPAUD = iClose("GBPAUD", PERIOD_M15, lookBack);
   double GBPNZD = iClose("GBPNZD", PERIOD_M15, lookBack);
   double GBPUSD = iClose("GBPUSD", PERIOD_M15, lookBack);
   double GBPCAD = iClose("GBPCAD", PERIOD_M15, lookBack);
   double GBPCHF = iClose("GBPCHF", PERIOD_M15, lookBack);
   double GBPJPY = iClose("GBPJPY", PERIOD_M15, lookBack);
//Gathers the current AUD Symbol Ask Values
   double AUDNZD = iClose("AUDNZD", PERIOD_M15, lookBack);
   double AUDUSD = iClose("AUDUSD", PERIOD_M15, lookBack);
   double AUDCAD = iClose("AUDCAD", PERIOD_M15, lookBack);
   double AUDCHF = iClose("AUDCHF", PERIOD_M15, lookBack);
   double AUDJPY = iClose("AUDJPY", PERIOD_M15, lookBack);
//Gathers the current NZD Symbol Ask Values
   double NZDUSD = iClose("NZDUSD", PERIOD_M15, lookBack);
   double NZDCAD = iClose("NZDCAD", PERIOD_M15, lookBack);
   double NZDCHF = iClose("NZDCHF", PERIOD_M15, lookBack);
   double NZDJPY = iClose("NZDJPY", PERIOD_M15, lookBack);
//Gathers the current USD Symbol Ask Values
   double USDCAD = iClose("USDCAD", PERIOD_M15, lookBack);
   double USDCHF = iClose("USDCHF", PERIOD_M15, lookBack);
   double USDJPY = iClose("USDJPY", PERIOD_M15, lookBack);
//Gathers the current CAD Symbol Ask Values
   double CADCHF = iClose("CADCHF", PERIOD_M15, lookBack);
   double CADJPY = iClose("CADJPY", PERIOD_M15, lookBack);
//Gathers the current CHF Symbol Ask Values
   double CHFJPY = iClose("CHFJPY", PERIOD_M15, lookBack);
   
   
//+------------------------------------------------------------------+
//|          Calculates the percent of change over time              |
//+------------------------------------------------------------------+
   

//calculating the percent change from the past open till the current ask of the EUR values
   double perEURGBP = (EURGBP - lookBackEURGBP)/lookBackEURGBP*100;
   double perEURAUD = (EURAUD - lookBackEURAUD)/lookBackEURAUD*100;
   double perEURNZD = (EURNZD - lookBackEURNZD)/lookBackEURNZD*100;
   double perEURUSD = (EURUSD - lookBackEURUSD)/lookBackEURUSD*100;
   double perEURCAD = (EURCAD - lookBackEURCAD)/lookBackEURCAD*100;
   double perEURCHF = (EURCHF - lookBackEURCHF)/lookBackEURCHF*100;
   double perEURJPY = (EURJPY - lookBackEURJPY)/lookBackEURJPY*100;

//calculating the percent change from the past open till the current ask of the GBP values
   double perGBPAUD = (GBPAUD - lookBackGBPAUD)/lookBackGBPAUD*100;
   double perGBPNZD = (GBPNZD - lookBackGBPNZD)/lookBackGBPNZD*100;
   double perGBPUSD = (GBPUSD - lookBackGBPUSD)/lookBackGBPUSD*100;
   double perGBPCAD = (GBPCAD - lookBackGBPCAD)/lookBackGBPCAD*100;
   double perGBPCHF = (GBPCHF - lookBackGBPCHF)/lookBackGBPCHF*100;
   double perGBPJPY = (GBPJPY - lookBackGBPJPY)/lookBackGBPJPY*100;

//calculating the percent change from the past open till the current ask of the AUD values
   double perAUDNZD = (AUDNZD - lookBackAUDNZD)/lookBackAUDNZD*100;
   double perAUDUSD = (AUDUSD - lookBackAUDUSD)/lookBackAUDUSD*100;
   double perAUDCAD = (AUDCAD - lookBackAUDCAD)/lookBackAUDCAD*100;
   double perAUDCHF = (AUDCHF - lookBackAUDCHF)/lookBackAUDCHF*100;
   double perAUDJPY = (AUDJPY - lookBackAUDJPY)/lookBackAUDJPY*100;

//calculating the percent change from the past open till the current ask of the NZD values
   double perNZDUSD = (NZDUSD - lookBackNZDUSD)/lookBackNZDUSD*100;
   double perNZDCAD = (NZDCAD - lookBackNZDCAD)/lookBackNZDCAD*100;
   double perNZDCHF = (NZDCHF - lookBackNZDCHF)/lookBackNZDCHF*100;
   double perNZDJPY = (NZDJPY - lookBackNZDJPY)/lookBackNZDJPY*100;

//calculating the percent change from the past open till the current ask of the USD values
   double perUSDCAD = (USDCAD - lookBackUSDCAD)/lookBackUSDCAD*100;
   double perUSDCHF = (USDCHF - lookBackUSDCHF)/lookBackUSDCHF*100;
   double perUSDJPY = (USDJPY - lookBackUSDJPY)/lookBackUSDJPY*100;

//calculating the percent change from the past open till the current ask of the CAD values
   double perCADCHF = (CADCHF - lookBackCADCHF)/lookBackCADCHF*100;
   double perCADJPY = (CADJPY - lookBackCADJPY)/lookBackCADJPY*100;

//calculating the percent change from the past open till the current ask of the JPY values
   double perCHFJPY=(CHFJPY-lookBackCHFJPY)/lookBackCHFJPY*100;

//Adds all the percentages from all the pairs together with thier respective pairs
   double perEUR = (perEURGBP + perEURAUD + perEURNZD + perEURUSD + perEURCAD + perEURCHF + perEURJPY);
   double perGBP = ((-perEURGBP) + perGBPAUD + perGBPNZD + perGBPUSD + perGBPCAD + perGBPCHF + perGBPJPY);
   double perAUD = (((-perEURAUD) + (-perGBPAUD)) + perAUDNZD + perAUDUSD + perAUDCAD + perAUDCHF + perAUDJPY);
   double perNZD = (((-perEURNZD) + (-perGBPNZD) + (-perAUDNZD)) + perNZDUSD + perNZDCAD + perNZDCHF + perNZDJPY);
   double perUSD = (((-perEURUSD) + (-perGBPUSD) + (-perAUDUSD) + (-perNZDUSD)) + perUSDCAD + perUSDCHF + perUSDJPY);
   double perCAD = (((-perEURCAD) + (-perGBPCAD) + (-perAUDCAD) + (-perNZDCAD) + (-perUSDCAD)) + perCADCHF + perCADJPY);
   double perCHF = (((-perEURCHF) + (-perGBPCHF) + (-perAUDCHF) + (-perNZDCHF) + (-perUSDCHF) + (-perCADCHF)) + perCHFJPY);
   double perJPY = ((-perEURJPY) + (-perGBPJPY) + (-perAUDJPY) + (-perNZDJPY) + (-perUSDJPY) + (-perCADJPY) + (-perCHFJPY));
 
   
//+------------------------------------------------------------------+
//|          Currently printing results to the experts log           |
//+------------------------------------------------------------------+


   perEUR = NormalizeDouble(perEUR,2);
   Print("rounded percent of the eur: ",perEUR);
   perGBP = NormalizeDouble(perGBP,2);
   Print("rounded percent of the gbp: ",perGBP);
   perAUD = NormalizeDouble(perAUD,2);
   Print("rounded percent of the aud: ",perAUD);
   perNZD = NormalizeDouble(perNZD,2);
   Print("rounded percent of the nzd: ",perNZD);
   perUSD = NormalizeDouble(perUSD,2);
   Print("rounded percent of the usd: ",perUSD);
   perCAD = NormalizeDouble(perCAD,2);
   Print("rounded percent of the cad: ",perCAD);
   perCHF = NormalizeDouble(perCHF,2);
   Print("rounded percent of the chf: ",perCHF);
   perJPY = NormalizeDouble(perJPY,2);
   Print("rounded percent of the jpy: ",perJPY);
   
   
   //This confirms the percentage math. "Correlation" this should most times be zero it will vary when price first shift
   Print("Sum of all percent changes: ", perEUR + perGBP + perAUD + perNZD + perUSD + perCAD + perCHF + perJPY);


//Drawing lines in a saparate window
   for(int i = 0; i < lookBack; i++)
   {  
//This needs to be changed to something that works but I'm not sure how to do it.
      EUR_Band[i] = perEUR;  
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
To add comments, please log in or register