MC.net: (Multi-Timeframe) Directly Added Indicators vs BarsOfData/CustomInstrument - futures io
futures io



MC.net: (Multi-Timeframe) Directly Added Indicators vs BarsOfData/CustomInstrument


Discussion in MultiCharts

Updated
    1. trending_up 468 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 0 posts
    2. attach_file 2 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

MC.net: (Multi-Timeframe) Directly Added Indicators vs BarsOfData/CustomInstrument

(login for full post details)
  #1 (permalink)
 rc76 
Taipei
 
Experience: Beginner
Platform: NT
Broker: IB
Trading: ES
 
Posts: 8 since Jul 2018
Thanks: 1 given, 2 received

[Issue]
I am trying to create a multi-timeframe indicator both daily and weekly data-series, plotted on a daily chart. I have identified (at least from my coding knowledge so far) there is discrepancy among the indicator results from the different method I used to create the indicators.

Default Method (Indicator plots are accurate compared to ToS)
(1) Default: Add weekly data-series directly from Chart's "Insert Instrument" menu. Than add existing EMA indicators (Mov_Avg_Exponential) directly against daily and weekly data.



Coded Methods

(2) BarsOfData: Add weekly data-series directly from Chart's "Insert Instrument" menu. Than create a custom indicator using BarsOfData to retrieve weekly data, and plot the daily/weekly EMA using XAverage.

 
Code
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{

    [SameAsSymbol(true)]
    public class _aa_MTF_BarsOfData : IndicatorObject
    {
        public _aa_MTF_BarsOfData(object _ctx) : base(_ctx) { }
        private IPlotObject plot_EMA_d;
        private IPlotObject plot_EMA_w;
        //CustomInstrument m_WeeklyData;

        XAverage ema_day;
        XAverage ema_week;

        protected override void Create()
        {
            plot_EMA_d = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red, Color.Black, 4, EPlotStyle.Solid, false));
            plot_EMA_w = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Cyan, Color.Black, 4, EPlotStyle.Solid, false));
            ema_day = new XAverage(this);
            ema_week = new XAverage(this);
        }

        protected override void StartCalc()
        {
            ema_day.Price = Bars.Close;
            ema_day.Length = 9;

            ema_week.Price = BarsOfData(2).Close;
            ema_week.Length = 9;
        }

        protected override void CalcBar()
        {
            plot_EMA_d.Set(ema_day[0]);
            plot_EMA_w.Set(ema_week[0]);
        }
    }
}
(3) CustomInstrument: Create a custom indicator. Retrieve the weekly data using CustomInstrument. Plot the daily/weekly EMA using XAverage.

 
Code
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{

    [SameAsSymbol(true)]
    public class _aa_MTF_CustomInstrument : IndicatorObject
    {
        public _aa_MTF_CustomInstrument(object _ctx) : base(_ctx) { }
        private IPlotObject plot_EMA_d;
        private IPlotObject plot_EMA_w;
        CustomInstrument m_WeeklyData;

        XAverage ema_day;
        XAverage ema_week;

        protected override void Create()
        {
            plot_EMA_d = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red, Color.Black, 4, EPlotStyle.Solid, false));
            plot_EMA_w = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Cyan, Color.Black, 4, EPlotStyle.Solid, false));
            ema_day = new XAverage(this);
            ema_week = new XAverage(this);
        }

        protected override void StartCalc()
        {
            m_WeeklyData = new CustomInstrument(this, new Resolution(EResolution.Week, 1));

            ema_day.Price = Bars.Close;
            ema_day.Length = 9;

            ema_week.Price = m_WeeklyData.Close;
            ema_week.Length = 9;
        }

        protected override void CalcBar()
        {
            plot_EMA_d.Set(ema_day[0]);
            plot_EMA_w.Set(ema_week[0]);
        }

        protected override void Dispose(bool _b)
        {
            m_WeeklyData.Dispose();
        }
    }
}
[Test Results]
Both BarsOfData and CustomInstrument indicator plot results are the same. However they are different to the default method result, which is accurate as it is compared against ToS's result.



Did I use the BarsOfData/CustomInstrument incorrectly? Any tip or help will be truly appreciated!

Thank you everyone!

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators MultiCharts > MC.net: (Multi-Timeframe) Directly Added Indicators vs BarsOfData/CustomInstrument


Last Updated on June 12, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing

A Transparent Glimpse Into a Prop Traders Life w/Chris Gray @ Earn2Trade

Elite only
 

Our 12-year anniversary w/ $$,$$$ prizes (check soon)

August
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts