• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:01am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:01am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Metatrader 4 vs Metatrader 5! 22 replies

Have Metatrader open to a specific profile 3 replies

Metatrader 5 is going to wipe out your Metatrader 4 indicators / systems 13 replies

VIX - Volality Index for MetaTrader 1 reply

Does MetaTrader have... 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Metatrader - How to have an index of 2 assets?
Exit Attachments
Tags: Metatrader - How to have an index of 2 assets?
Cancel

Metatrader - How to have an index of 2 assets?

  • Post #1
  • Quote
  • First Post: May 6, 2010 1:28pm May 6, 2010 1:28pm
  •  salvador_
  • | Joined Jul 2009 | Status: Member | 52 Posts
Hello everyone.

I saw on another forum a graph of Metatrader BUT it was a graph of a ratio between 2 assets... In this case it was the Dow Jones/GOLD

My question is, how can I or is there a way to plot in Metatrader these type of graphs?

Let's say I want Crude Oil in Euros. I would just put the CL contract divided by the EURUSD ...

Thanks in advance...
  • Post #2
  • Quote
  • May 6, 2010 1:47pm May 6, 2010 1:47pm
  •  salvador_
  • | Joined Jul 2009 | Status: Member | 52 Posts
here's an example:

http://www.elitetrader.com/vb/attach...postid=2801073
 
 
  • Post #3
  • Quote
  • Last Post: May 8, 2010 12:28pm May 8, 2010 12:28pm
  •  antoine
  • | Joined Oct 2008 | Status: mobydickInc. Import Export Mnfctr | 19 Posts
You've got it: ratio=priceA/priceB
Though sometimes you gotta invert priceB to 1/priceB, if instrumentB is in the form USDxxx. However, EURUSD is xxxUSD, so don't need to invert it.

Inserted Code
//antoine ff 2010
#property indicator_separate_window
#property indicator_buffers 1

extern string  instrumentA = "#CLM0",
               instrumentB = "EURUSD";
extern bool    invertA     = false,
               invertB     = false;
double ratio[], priceA, priceB;

void init() {
   SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ratio);
   string labelA="", labelB="";
   if (invertA) labelA="(1/"+instrumentA+")"; else labelA=instrumentA;
   if (invertB) labelB="(1/"+instrumentB+")"; else labelB=instrumentB;  
   IndicatorShortName("abRatio "+labelA+" / "+labelB+" ");
}

void start() {
   int limit = Bars-IndicatorCounted()-1;
   for(int i=limit;i>=0;i--) {
      priceA = iClose(instrumentA,0,i);
      priceB = iClose(instrumentB,0,i);
      if(invertA) if(priceA!=0) priceA=1/priceA;
      if(invertB) if(priceB!=0) priceB=1/priceB;
      if(priceB!=0)  ratio[i]=priceA/priceB;
   }
}
Attached File(s)
File Type: mq4 __abRatio.mq4   < 1 KB | 190 downloads
 
 
  • Platform Tech
  • /
  • Metatrader - How to have an index of 2 assets?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023