Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Mutli Time Frame using DataSeries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Mutli Time Frame using DataSeries

    Edit: This is for NT7. Sorry.

    I have attempted to turn the TRIX indicator into a MTF using DataSeries. I put the TRIX on an ES 7500 Volume Chart. Then I put the following code on the ES 2500 Volume chart. The OutputWindow from this code does not match the Data Window from the 7500 Chart. The Bar time stamps and the Inputs[0] do match but the indicator values do not. Can you tell me where this thing went off the rails. Help would be much appreciated because I am lost. Probably something super simple and I will be wearing a dunce cap.

    #region Variables
    private int period = 14;
    private int signalPeriod = 3;

    private DataSeries Default;
    private DataSeries Signal;

    private PeriodType chartType = PeriodType.Volume;
    private int chartInterval = 7500;
    #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()
    {
    Overlay = true;

    // Add Secondary Chart. Bars Array 1
    Add(ChartType, ChartInterval);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Sync Secondary DataSeries
    if (Default == null)
    {
    Default = new DataSeries(SMA(BarsArray[1], 2));
    Signal = new DataSeries(SMA(BarsArray[1], 2));
    }
    if (BarsInProgress == 1)
    {
    if (CurrentBar == 0)
    {
    Value.Set(Input[0]);
    return;
    }
    EMA tripleEma = EMA(EMA(EMA(Inputs[0], Period), Period), Period);
    double trix = 100 * ((tripleEma[0] - tripleEma[1]) / tripleEma[0]);

    Default.Set(trix);
    Signal.Set(EMA(Default, SignalPeriod)[0]);
    Print(String.Format("{0,20} Inputs[0] {1,7:0000.00} Default {2:0.0000000} Signal {3:0.0000000}",
    Time[0], Inputs[0], Default[0], Signal[0]));
    }
    }

    #region Properties
    [Description("Numbers of bars used for calculations.")]
    [GridCategory("Parameters")]
    public int Period
    {
    get { return period; }
    set { period = Math.Max(1, value); }
    }

    [Description("Period for the signal line.")]
    [GridCategory("Parameters")]
    [Gui.Design.DisplayNameAttribute("Signal period")]
    public int SignalPeriod
    {
    get { return signalPeriod; }
    set { signalPeriod = Math.Max(1, value); }
    }


    [Description("")]
    [GridCategory("Parameters")]
    [Gui.Design.DisplayNameAttribute("Chart Type")]
    public PeriodType ChartType
    {
    get { return chartType; }
    set { chartType = value; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    [Gui.Design.DisplayNameAttribute("Bar Period")]
    public int ChartInterval
    {
    get { return chartInterval; }
    set { chartInterval = Math.Max(1, value); }
    }
    #endregion

Latest Posts

Collapse

Topics Statistics Last Post
Started by geddyisodin, Today, 05:20 AM
3 responses
20 views
0 likes
Last Post NinjaTrader_Gaby  
Started by lorem, Today, 09:18 AM
1 response
4 views
0 likes
Last Post lorem
by lorem
 
Started by bmartz, Today, 09:30 AM
0 responses
3 views
0 likes
Last Post bmartz
by bmartz
 
Started by GussJ, 03-04-2020, 03:11 PM
14 responses
3,245 views
0 likes
Last Post GussJ
by GussJ
 
Started by ArkansasClint, Today, 09:28 AM
0 responses
2 views
0 likes
Last Post ArkansasClint  
Working...
X