Strong vs Weak Analysis

by 4x.dunder in category Other at 15/08/2019
Description

Based on the method as used in the following BP thread: https://forums.babypips.com/t/trading-the-trend-with-strong-weak-analysis/

A few notes:

  • Calculates and displays the strength of each currency relative to JPY.
  • Calculation is performed on 4HR timeframe against the 200SMA
  • JPY strength will always be 0 relative to the other currencies
  • Can be ran on any chart, as it will always look at the same currencies
  • I recommend you run it on the Daily timeframe
  • Can take 30 to 60s to load

Suggested screen setup:

Download
180 downloads
How to install
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Levels(-4, -2, 0, 2, 4)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CurrencyStrengthJPY : Indicator
    {
        [Output("USD", LineColor = "DarkGreen")]
        public IndicatorDataSeries USD { get; set; }

        [Output("AUD", LineColor = "Red")]
        public IndicatorDataSeries AUD { get; set; }

        [Output("CAD", LineColor = "Blue")]
        public IndicatorDataSeries CAD { get; set; }

        [Output("NZD", LineColor = "Brown")]
        public IndicatorDataSeries NZD { get; set; }

        [Output("CHF", LineColor = "White")]
        public IndicatorDataSeries CHF { get; set; }

        [Output("EUR", LineColor = "GreenYellow")]
        public IndicatorDataSeries EUR { get; set; }

        [Output("GBP", LineColor = "Gold")]
        public IndicatorDataSeries GBP { get; set; }

        private MarketSeries sUSD, sAUD, sCAD, sNZD, sCHF, sEUR, sGBP;

        protected override void Initialize()
        {
            TimeFrame tf = TimeFrame.Hour4;

            sUSD = MarketData.GetSeries("USDJPY", tf);
            sAUD = MarketData.GetSeries("AUDJPY", tf);
            sCAD = MarketData.GetSeries("CADJPY", tf);
            sNZD = MarketData.GetSeries("NZDJPY", tf);
            sCHF = MarketData.GetSeries("CHFJPY", tf);
            sEUR = MarketData.GetSeries("EURJPY", tf);
            sGBP = MarketData.GetSeries("GBPJPY", tf);

            Chart.DrawStaticText("1", "1. Identify strongest pair (must be >2% difference)", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Yellow);
            Chart.DrawStaticText("2", "\n" + "2. Confirm trade is in daily/weekly direction", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Yellow);
            Chart.DrawStaticText("3", "\n\n" + "3. Draw Support/Resistance", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Yellow);
            Chart.DrawStaticText("4", "\n\n\n" + "4. Plot on H1 against 200SMA", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Yellow);
            Chart.DrawStaticText("5", "\n\n\n\n" + "5. Idenitify Entry/Exit", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Yellow);
        }

        public override void Calculate(int index)
        {
            var dUSD = (double)(getResult(sUSD, USD, index)) / 100;
            var dAUD = (double)(getResult(sAUD, AUD, index)) / 100;
            var dCAD = (double)(getResult(sCAD, CAD, index)) / 100;
            var dNZD = (double)(getResult(sNZD, NZD, index)) / 100;
            var dCHF = (double)(getResult(sCHF, CHF, index)) / 100;
            var dEUR = (double)(getResult(sEUR, EUR, index)) / 100;
            var dGBP = (double)(getResult(sGBP, GBP, index)) / 100;

            Chart.DrawStaticText("Labels", "USD:" + "\t\t\n" + "AUD:" + "\t\t\n" + "CAD:" + "\t\t\n" + "NZD:" + "\t\t\n" + "CHF:" + "\t\t\n" + "EUR:" + "\t\t\n" + "GBP:" + "\t\t", VerticalAlignment.Top, HorizontalAlignment.Right, Color.Yellow);
            Chart.DrawStaticText("USD", "\t" + dUSD, VerticalAlignment.Top, HorizontalAlignment.Right, Color.DarkGreen);
            Chart.DrawStaticText("AUD", "\n\t" + dAUD, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Red);
            Chart.DrawStaticText("CAD", "\n\n\t" + dCAD, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Blue);
            Chart.DrawStaticText("NZD", "\n\n\n\t" + dNZD, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Brown);
            Chart.DrawStaticText("CHF", "\n\n\n\n\t" + dCHF, VerticalAlignment.Top, HorizontalAlignment.Right, Color.White);
            Chart.DrawStaticText("EUR", "\n\n\n\n\n\t" + dEUR, VerticalAlignment.Top, HorizontalAlignment.Right, Color.GreenYellow);
            Chart.DrawStaticText("GBP", "\n\n\n\n\n\n\t" + dGBP, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Gold);
        }

        private int getResult(MarketSeries Ticker, IndicatorDataSeries result, int index)
        {
            MovingAverage ma = Indicators.SimpleMovingAverage(Ticker.Close, 200);

            int index2 = GetIndexByDate(Ticker, MarketSeries.OpenTime[index]);
            result[index] = ((Ticker.Close[index2] - ma.Result[index2]) / Ticker.Close[index2]) * 100;

            return (int)(((Ticker.Close.LastValue - ma.Result.LastValue) / Ticker.Close.LastValue) * 10000);
        }

        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i >= 0; i--)
                if (time == series.OpenTime[i])
                    return i;
            return -1;
        }
    }
}
Comments
0