MTF - Determining the TF - NinjaTrader | futures io social day trading
futures io futures trading


MTF - Determining the TF
Updated: Views / Replies:85 / 1
Created: by patfaninba Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

MTF - Determining the TF

  #1 (permalink)
san francisco, CA / USA
 
Trading Experience: Beginner
Platform: TOS
Favorite Futures: Dow
 
Posts: 12 since Jan 2019
Thanks: 3 given, 0 received

MTF - Determining the TF

Hello,

I am working on a custom multi time frame indicator that has many plots across different time frames..

Some plots should appear only if they belong to a time frame higher than the time frame of the base chart..

in other words, lets say I have plots that are based on 1 hour, 4 hour and day time frames.. if the base chart is on 4 hour time frame, the lines based on 1 hour time frame should be suppressed.

Given both time frames are user selectable options at run time...I have 2 questions..from within the indicator,

1. How do I check what the plot's time frame is?
2. How do I check what the chart's base time frame is?

Note: using the example i cited above, I have created 3 data series using AddDataSeries function in OnStateChange / Configure. The plots were created using the wizard.

Appreciate your help in advance.

Reply With Quote
 
  #2 (permalink)
Kansas City, MO/US
 
Trading Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Futures
 
Barz's Avatar
 
Posts: 16 since Jul 2018
Thanks: 26 given, 8 received


patfaninba View Post
Hello,

I am working on a custom multi time frame indicator that has many plots across different time frames..

Some plots should appear only if they belong to a time frame higher than the time frame of the base chart..

in other words, lets say I have plots that are based on 1 hour, 4 hour and day time frames.. if the base chart is on 4 hour time frame, the lines based on 1 hour time frame should be suppressed.

Given both time frames are user selectable options at run time...I have 2 questions..from within the indicator,

1. How do I check what the plot's time frame is?
2. How do I check what the chart's base time frame is?

Note: using the example i cited above, I have created 3 data series using AddDataSeries function in OnStateChange / Configure. The plots were created using the wizard.

Appreciate your help in advance.

A bit late, but perhaps this will help others who stumble on this thread.

First, note that the primary (or base) series is always the 0th series in the BarsArray property of a NinjaScript.

Next, the trick is to convert the bar period for each series to a TimeSpan so that we can easily compare them.

Here is the full strategy code (for NT8). Should be similar for an Indicator:

 
Code
using System;
using System.Windows.Media;
using NinjaTrader.Data;

//This namespace holds strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies.Barz.Sandbox.FuturesIO
{
    public class FIO_DetermineTimeFrame : Strategy
    {
        private TimeSpan[] _PeriodSpans;

        protected override void OnBarUpdate()
        {
            if (CurrentBar < BarsRequiredToTrade) { return; }

            // Conditionally populate plots based on whether the period is less
            // than or greater than the primary period.
            if (BarsInProgress == 0)
            {
                if (_PeriodSpans[1] > _PeriodSpans[0])
                {
                    Values[0][0] = Closes[1][0] + 20;
                }
                if (_PeriodSpans[2] < _PeriodSpans[0])
                {
                    Values[1][0] = Closes[2][0] - 20;
                }
            }

        }
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Name = "FIO_DetermineTimeFrame";

                // This creates a plot whose current value can be set in
                // OnBarUpdate using Values[0][0] = 25.1.
                AddPlot(Brushes.Yellow, "Larger Period");

                // This creates a plot whose current value can be set in
                // OnBarUpdate using Values[1][0] = 25.1.
                AddPlot(Brushes.Red, "Smaller Period");
            }
            else if (State == State.Configure)
            {
                // Ensure a 4 hour series has been added to your chart to serve
                // as the primary (base) series.

                // Add day chart here
                AddDataSeries(BarsPeriodType.Day, 1);

                // Add the 60 minute chart here
                AddDataSeries(BarsPeriodType.Minute, 60);
            }
            else if (State == State.DataLoaded)
            {
                _PeriodSpans = new TimeSpan[BarsArray.Length];

                for (int i = 0; i < BarsArray.Length; i++)
                {
                    BarsPeriod period = BarsArray[i].BarsPeriod;
                    Print(i + ": Period=" + period.BarsPeriodType.ToString()
                        + ", TimeSpan=" + period.ToTimeSpan());

                    // Capture the period for each series as a time span so we
                    // can easily do comparisons later.
                    _PeriodSpans[i] = period.ToTimeSpan();
                }

            }
        }

    }

    public static class BarsPeriodExtensions
    {
        public static TimeSpan ToTimeSpan(this BarsPeriod period)
        {
            switch (period.BarsPeriodType)
            {
                case BarsPeriodType.Second:
                    return TimeSpan.FromSeconds(period.Value);
                case BarsPeriodType.Minute:
                    return TimeSpan.FromMinutes(period.Value);
                case BarsPeriodType.Day:
                    return TimeSpan.FromDays(period.Value);
                case BarsPeriodType.Week:
                    return TimeSpan.FromDays(7 * period.Value);
                default:
                    throw new ArgumentException("BarsPeriodType not supported for conversion to TimeSpan: "
                        + period.BarsPeriodType);
            }
        }
    }
}

Reply With Quote

Reply



futures io > > > > MTF - Determining the TF

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$1,000 in Amazon Gift Cards being given away right now from GFF Brokers

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Show us your trading desks and win over $5,000 in prizes w/Jigsaw Trading

August
 

Webinar: AutoTrading World Cup Advisor w/GFF Brokers

Aug 22
 

Webinar: Suri Duddella (TBA)

Elite only
 

Webinar: Richard Bailey (TBA)

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP in determining the Gain/Loss per move in SI,PL,NG,LE,etc..... mdsvtr Emini and Emicro Index Futures Trading 2 February 20th, 2013 07:34 PM
Determining the 'Last' Bar srgtroy NinjaTrader Programming 4 July 11th, 2011 10:06 PM
Determining Status Bar Text jondrus NinjaTrader 0 June 19th, 2011 02:13 PM
Determining Areas of Interest EDGE Elite Automated Trading 1 March 5th, 2011 06:14 PM
Determining range expansion for the ES (S&P eminis) aquarian1 Emini and Emicro Index Futures Trading 18 January 19th, 2011 09:11 AM


All times are GMT -4. The time now is 07:55 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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