NexusFi: Find Your Edge


Home Menu

 





FXCorrelator


Discussion in NinjaTrader

Updated
    1. trending_up 8,089 views
    2. thumb_up 8 thanks given
    3. group 4 followers
    1. forum 20 posts
    2. attach_file 5 attachments




 
Search this Thread

FXCorrelator

  #1 (permalink)
 danjuma 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker: IB, Kinetic
Trading: Stocks, Forex
Posts: 98 since Nov 2011
Thanks Given: 47
Thanks Received: 16

Hello,

There is a forex indicator for Metatrader called 'FXCorrelator' from a popular member on T2W called NVP. Just wondered if anybody knows whether somebody has managed to code this in Ninja Trader? I am interested in the indicator, but I use IB for my data feed and Metatrader don't work with IB. Further info about the indicator can be got from the links below:

The FXCorrelator |FXCORRELATOR
Best Thread: Correlation Trading - Basic Ideas and Strategies
FXCorrelator - [AUTOLINK]Scalping[/AUTOLINK] system @ Forex Factory


Many thanks.
Dan

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
80 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Tao te Trade: way of the WLD
46 thanks
Just another trading journal: PA, Wyckoff & Trends
35 thanks
The Program
19 thanks
  #2 (permalink)
 danjuma 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker: IB, Kinetic
Trading: Stocks, Forex
Posts: 98 since Nov 2011
Thanks Given: 47
Thanks Received: 16

File attached. Hoping some NT Script expert with some free time to spare can assist in converting this to work on NT. A hundred thanks in advance.

Attached Files
Elite Membership required to download: FXCORRELATOR_BASIC_FREE_VERSION.mq4
Started this thread Reply With Quote
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


The indicator is relatively easy to code. It just looks at a slow linear weighted moving average of the major currency pairs now and 1 period ago. Then the results are added up for each currency pair to calculate an index representing the strength of that currency.


The indicator has two conceptual weaknesses:

(1) When evaluating the strength of the USD, its relative position against the NZ dollar is considered as important as its relative position against the EUR. I do not believe that this makes sense, but that the different currency pairs need to weighted according to their liquidity.

(2) The different positions are weighted by using an arithmetical mean. An arithmetical mean is quite sensitive to outliers, a geometrical mean would have been the better choice.

An example, how to define a currency index is the US dollar index. It does not take into account the NZD, but takes the EUR, JPY, GBP, CAD, SEK and CHF. The Euro accounts for over 50%.

A more complex example is the Broad Index, which is published by the FED. It has a higher weighting of the Japanese Yen, as the Chinese currency is not yet freely convertible.


It is relatively easy to convert the indicator to NinjaTrader and improve it at the same time.

Reply With Quote
Thanked by:
  #4 (permalink)
 danjuma 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker: IB, Kinetic
Trading: Stocks, Forex
Posts: 98 since Nov 2011
Thanks Given: 47
Thanks Received: 16


Fat Tails View Post
It is relatively easy to convert the indicator to NinjaTrader and improve it at the same time.

Would you be willing to spare some of your precious time and do this my dear sir?

Started this thread Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


danjuma View Post
Would you be willing to spare some of your precious time and do this my dear sir?

I am certainly willing, but will not find the time during the next weeks.

Reply With Quote
  #6 (permalink)
 danjuma 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker: IB, Kinetic
Trading: Stocks, Forex
Posts: 98 since Nov 2011
Thanks Given: 47
Thanks Received: 16


Fat Tails View Post
I am certainly willing, but will not find the time during the next weeks.

No problem sir, when never you find the time. Be warned though, I will be on your back until you do

Started this thread Reply With Quote
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


danjuma View Post
No problem sir, when never you find the time. Be warned though, I will be on your back until you do

Why don't you code it yourself. It would be a rewarding exercise to start with.

Reply With Quote
  #8 (permalink)
 danjuma 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker: IB, Kinetic
Trading: Stocks, Forex
Posts: 98 since Nov 2011
Thanks Given: 47
Thanks Received: 16


Fat Tails View Post
Why don't you code it yourself. It would be a rewarding exercise to start with.

Ok, currently learning the basics of NTScripts. Might give it a try if you could give me some pointers to start with

Many thanks.

Started this thread Reply With Quote
  #9 (permalink)
 fctrader 
Fort Collins, Colorado
 
Experience: Intermediate
Platform: NT7
Trading: ES
Posts: 57 since Feb 2011
Thanks Given: 48
Thanks Received: 45

Hi Danjuma, I am not a coding wizard like some of on the site, but it looked like an interesting project, so I coded my own version. I used an SMA instead of a Weighted average, and I found it to be more useful if you change the smoothing out to say, a 50 period SMA, but you can change it to whatever you want.

Something to note, my coding is not clean, in the sense that it is ugly from a programmer's perspective, but it seems to do what your model does, and I didn't want to use his code, since obviously, if this violates someones proprietary code, it has to come down. Also, I didn't compile and export, so if you want to use it, you'll have to copy and paste it into your own ninjascript. (It looks better on a dark chart)

Hope it gives you some ideas for making your own.

Cheers,
FCtrader

 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Replicates the FX Correlator from FXCorrelator.com
    /// </summary>
    [Description("Replicates the FX Correlator from FXCorrelator.com")]
    public class FXcorrelator : Indicator
    {
        #region Variables
        // Wizard generated variables
            private int movAvgLength = 50; // Default setting for MovAvgLength
			private double deltaEURUSD;
			private double deltaGBPUSD;
			private double deltaAUDUSD;
			private double deltaUSDCHF;
			private double deltaUSDJPY;
			private double deltaNZDUSD;
			private double deltaUSDCAD;
			private double USD_strength;
			private double EUR_strength;
			private double GBP_strength;
			private double AUD_strength;
			private double CHF_strength;
			private double JPY_strength;
			private double NZD_strength;
			private double CAD_strength;
		
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            Add("$EURUSD",BarsPeriod.Id,BarsPeriod.Value);
			Add("$GBPUSD",BarsPeriod.Id,BarsPeriod.Value);
			Add("$AUDUSD",BarsPeriod.Id,BarsPeriod.Value);
			Add("$USDCHF",BarsPeriod.Id,BarsPeriod.Value);
			Add("$USDJPY",BarsPeriod.Id,BarsPeriod.Value);
			Add("$NZDUSD",BarsPeriod.Id,BarsPeriod.Value);
			Add("$USDCAD",BarsPeriod.Id,BarsPeriod.Value);
			Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "USD"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "EUR"));
            Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "GBP"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Cyan), PlotStyle.Line, "CAD"));
			Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "CHF"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "JPY"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Pink), PlotStyle.Line, "NZD"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Firebrick), PlotStyle.Line, "AUD"));
			
            Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "ZeroLine"));
            Overlay				= false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            
			if(CurrentBar==0){return;}
			deltaEURUSD = 100*(SMA(Closes[1],MovAvgLength)[0]-SMA(Closes[1],MovAvgLength)[1])/SMA(Closes[1],MovAvgLength)[0];
			deltaGBPUSD = 100*(SMA(Closes[2],MovAvgLength)[0]-SMA(Closes[2],MovAvgLength)[1])/SMA(Closes[2],MovAvgLength)[0];
			deltaAUDUSD = 100*(SMA(Closes[3],MovAvgLength)[0]-SMA(Closes[3],MovAvgLength)[1])/SMA(Closes[3],MovAvgLength)[0];
			deltaUSDCHF = 100*(-(SMA(Closes[4],MovAvgLength)[0]-SMA(Closes[4],MovAvgLength)[1]))/SMA(Closes[4],MovAvgLength)[0];
			deltaUSDJPY = 100*(-(SMA(Closes[5],MovAvgLength)[0]-SMA(Closes[5],MovAvgLength)[1]))/SMA(Closes[5],MovAvgLength)[0];
			deltaNZDUSD = 100*(SMA(Closes[6],MovAvgLength)[0]-SMA(Closes[6],MovAvgLength)[1])/SMA(Closes[6],MovAvgLength)[0];
			deltaUSDCAD = 100*(-(SMA(Closes[7],MovAvgLength)[0]-SMA(Closes[7],MovAvgLength)[1]))/SMA(Closes[7],MovAvgLength)[0];
			
			USD_strength = -(deltaEURUSD+deltaGBPUSD+deltaAUDUSD+deltaNZDUSD+deltaUSDCAD+deltaUSDJPY+deltaUSDCHF)/7;
			EUR_strength = deltaEURUSD-(deltaGBPUSD+deltaAUDUSD+deltaNZDUSD+deltaUSDCAD+deltaUSDJPY+deltaUSDCHF)/6;
			GBP_strength = deltaGBPUSD-(deltaEURUSD+deltaAUDUSD+deltaNZDUSD+deltaUSDCAD+deltaUSDJPY+deltaUSDCHF)/6;
			AUD_strength = deltaAUDUSD-(deltaEURUSD+deltaGBPUSD+deltaNZDUSD+deltaUSDCAD+deltaUSDJPY+deltaUSDCHF)/6;
			CHF_strength = deltaUSDCHF-(deltaEURUSD+deltaAUDUSD+deltaNZDUSD+deltaUSDCAD+deltaUSDJPY+deltaGBPUSD)/6;
			JPY_strength = deltaUSDJPY-(deltaEURUSD+deltaAUDUSD+deltaNZDUSD+deltaUSDCAD+deltaGBPUSD+deltaUSDCHF)/6;
			NZD_strength = deltaNZDUSD-(deltaEURUSD+deltaAUDUSD+deltaGBPUSD+deltaUSDCAD+deltaUSDJPY+deltaUSDCHF)/6;
			CAD_strength = deltaUSDCAD-(deltaEURUSD+deltaAUDUSD+deltaNZDUSD+deltaGBPUSD+deltaUSDJPY+deltaUSDCHF)/6;
			
			
            USD.Set(USD_strength);
            EUR.Set(EUR_strength);
            GBP.Set(GBP_strength);
            CAD.Set(CAD_strength);
			CHF.Set(CHF_strength);
            JPY.Set(JPY_strength);
            NZD.Set(NZD_strength);
            AUD.Set(AUD_strength);
        }

        #region Properties
        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries USD
        {
            get { return Values[0]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries EUR
        {
            get { return Values[1]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries GBP
        {
            get { return Values[2]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries CAD
        {
            get { return Values[3]; }
        }
		[Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries CHF
        {
            get { return Values[4]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries JPY
        {
            get { return Values[5]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries NZD
        {
            get { return Values[6]; }
        }

        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries AUD
        {
            get { return Values[7]; }
        }

        [Description("Defines Smoothing length")]
        [GridCategory("Parameters")]
        public int MovAvgLength
        {
            get { return movAvgLength; }
            set { movAvgLength = Math.Max(1, value); }
        }
        #endregion
    }
}

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #10 (permalink)
 fctrader 
Fort Collins, Colorado
 
Experience: Intermediate
Platform: NT7
Trading: ES
Posts: 57 since Feb 2011
Thanks Given: 48
Thanks Received: 45


After playing with it for a few minutes on a daily chart from the last 3000 days or so, the most interesting aspect seems to be the tendency for these relatively stable currencies to return to parity after they diverge. A contrarian approach might suit it well.

Of course, there is the distinct possibility that I missed the point of the indicator, followed by the equally distinct possibility that I misswrote it when i coded it!

...And then there is what FatTails wrote above. It seems to have some fundamental flaws in it's currency valuations. (again, could be my version, but in my experience, FT is usually pretty good at spotting these things) On the brights side, it makes very pretty multicolored squiggly lines, and that is probably the most important hallmark of a good indicator (again)

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on March 9, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts