Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help to convert script from version 7 to 8

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

    Need help to convert script from version 7 to 8

    Hi,
    I have a some script created in NinjaTrader 7 and I want to convert it to version 8.
    Below is my code which I want to convert into version 8. Can anyone help me. I will really be thankful to you.
    Thanks in advance

    //
    // Copyright (C) 2006, NinjaTrader LLC <[email protected]>.
    // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
    //
    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion
    
    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    public partial class Indicator : IndicatorBase
    {
    private CustomTrader[] cacheCustomTrader = null;
    
    private static CustomTrader checkCustomTrader = new CustomTrader();
    
    /// <summary>
    /// Pivot Points.
    /// </summary>
    /// <returns></returns>
    public CustomTrader CustomTrader(Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
    {
    return CustomTrader(Input, pivotRangeType, priorDayHLC, userDefinedClose, userDefinedHigh, userDefinedLow, width);
    }
    
    /// <summary>
    /// Pivot Points.
    /// </summary>
    /// <returns></returns>
    public CustomTrader CustomTrader(Data.IDataSeries input, Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
    {
    if (cacheCustomTrader != null)
    for (int idx = 0; idx < cacheCustomTrader.Length; idx++)
    if (cacheCustomTrader[idx].PivotRangeType == pivotRangeType && cacheCustomTrader[idx].PriorDayHLC == priorDayHLC && Math.Abs(cacheCustomTrader[idx].UserDefinedClose - userDefinedClose) <= double.Epsilon && Math.Abs(cacheCustomTrader[idx].UserDefinedHigh - userDefinedHigh) <= double.Epsilon && Math.Abs(cacheCustomTrader[idx].UserDefinedLow - userDefinedLow) <= double.Epsilon && cacheCustomTrader[idx].Width == width && cacheCustomTrader[idx].EqualsInput(input))
    return cacheCustomTrader[idx];
    
    lock (checkCustomTrader)
    {
    checkCustomTrader.PivotRangeType = pivotRangeType;
    pivotRangeType = checkCustomTrader.PivotRangeType;
    checkCustomTrader.PriorDayHLC = priorDayHLC;
    priorDayHLC = checkCustomTrader.PriorDayHLC;
    checkCustomTrader.UserDefinedClose = userDefinedClose;
    userDefinedClose = checkCustomTrader.UserDefinedClose;
    checkCustomTrader.UserDefinedHigh = userDefinedHigh;
    userDefinedHigh = checkCustomTrader.UserDefinedHigh;
    checkCustomTrader.UserDefinedLow = userDefinedLow;
    userDefinedLow = checkCustomTrader.UserDefinedLow;
    checkCustomTrader.Width = width;
    width = checkCustomTrader.Width;
    
    if (cacheCustomTrader != null)
    for (int idx = 0; idx < cacheCustomTrader.Length; idx++)
    if (cacheCustomTrader[idx].PivotRangeType == pivotRangeType && cacheCustomTrader[idx].PriorDayHLC == priorDayHLC && Math.Abs(cacheCustomTrader[idx].UserDefinedClose - userDefinedClose) <= double.Epsilon && Math.Abs(cacheCustomTrader[idx].UserDefinedHigh - userDefinedHigh) <= double.Epsilon && Math.Abs(cacheCustomTrader[idx].UserDefinedLow - userDefinedLow) <= double.Epsilon && cacheCustomTrader[idx].Width == width && cacheCustomTrader[idx].EqualsInput(input))
    return cacheCustomTrader[idx];
    
    CustomTrader indicator = new CustomTrader();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    #if NT7
    indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
    indicator.MaximumBarsLookBack = MaximumBarsLookBack;
    #endif
    indicator.Input = input;
    indicator.PivotRangeType = pivotRangeType;
    indicator.PriorDayHLC = priorDayHLC;
    indicator.UserDefinedClose = userDefinedClose;
    indicator.UserDefinedHigh = userDefinedHigh;
    indicator.UserDefinedLow = userDefinedLow;
    indicator.Width = width;
    Indicators.Add(indicator);
    indicator.SetUp();
    
    CustomTrader[] tmp = new CustomTrader[cacheCustomTrader == null ? 1 : cacheCustomTrader.Length + 1];
    if (cacheCustomTrader != null)
    cacheCustomTrader.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheCustomTrader = tmp;
    return indicator;
    }
    }
    }
    }
    
    // This namespace holds all market analyzer column definitions and is required. Do not change it.
    namespace NinjaTrader.MarketAnalyzer
    {
    public partial class Column : ColumnBase
    {
    /// <summary>
    /// Pivot Points.
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.CustomTrader CustomTrader(Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
    {
    return _indicator.CustomTrader(Input, pivotRangeType, priorDayHLC, userDefinedClose, userDefinedHigh, userDefinedLow, width);
    }
    
    /// <summary>
    /// Pivot Points.
    /// </summary>
    /// <returns></returns>
    public Indicator.CustomTrader CustomTrader(Data.IDataSeries input, Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
    {
    return _indicator.CustomTrader(input, pivotRangeType, priorDayHLC, userDefinedClose, userDefinedHigh, userDefinedLow, width);
    }
    }
    }
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Pivot Points.
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.CustomTrader CustomTrader(Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
    {
    return _indicator.CustomTrader(Input, pivotRangeType, priorDayHLC, userDefinedClose, userDefinedHigh, userDefinedLow, width);
    }
    
    /// <summary>
    /// Pivot Points.
    /// </summary>
    /// <returns></returns>
    public Indicator.CustomTrader CustomTrader(Data.IDataSeries input, Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
    {
    if (InInitialize && input == null)
    throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
    
    return _indicator.CustomTrader(input, pivotRangeType, priorDayHLC, userDefinedClose, userDefinedHigh, userDefinedLow, width);
    }
    }
    }
    #endregion

    #2
    That is not the source code of the indicator 'CustomTrader'.
    (That source code is part of the distribution package, and is
    only designed to provide details of the parameters for calling
    -- it is not the source code of the implementation.)

    What you have cannot be converted since it is incomplete.

    My suggestion?
    Contact the original authors of 'CustomTrader' for an NT8
    version.

    Comment


      #3
      Hello fahadishfaq,

      This is correct, what you provided is just the generated part of a NinjaScript file. If this is from a third party item you would need to reach out to that developer to see if they have an updated version. We generally can assist with guidance on how to convert specific parts of nt7 to nt8 code but we would need the full script to assist with questions. In the future if you do have an open source script which you need to convert and have questions this would be a good place for that.

      You can find a code breaking changes guide in the help guide if you are interested in learning the differences between 7 and 8: https://ninjatrader.com/support/help...ng_changes.htm

      Comment


        #4
        Thanks for your quick response. Actually yes, this is from a third party. I'll try to get the source code file again and will get back to you. Once again thank you so much.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        566 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X