• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 Ilpropio, Yesterday, 09:45 PM
1 response
4 views
0 likes
Last Post NinjaTrader_EricB  
Started by sgordet, Yesterday, 10:31 PM
1 response
3 views
0 likes
Last Post NinjaTrader_EricB  
Started by Revan, Yesterday, 05:44 PM
1 response
14 views
0 likes
Last Post NinjaTrader_Marco  
Started by superg3, Yesterday, 07:57 PM
0 responses
4 views
0 likes
Last Post superg3
by superg3
 
Started by Longhornmark, Yesterday, 07:06 AM
5 responses
37 views
0 likes
Last Post nkhoi
by nkhoi
 
Working...
X