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

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

      JesseNinjaTrader Customer Service

      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 cre8able, Today, 09:15 PM
        0 responses
        1 view
        0 likes
        Last Post cre8able  
        Started by cummish, Today, 08:43 PM
        0 responses
        6 views
        0 likes
        Last Post cummish
        by cummish
         
        Started by Option Whisperer, Today, 07:58 PM
        4 responses
        18 views
        0 likes
        Last Post Option Whisperer  
        Started by ETFVoyageur, 05-07-2024, 07:05 PM
        13 responses
        86 views
        0 likes
        Last Post ETFVoyageur  
        Started by cupir2, Today, 07:44 PM
        0 responses
        11 views
        0 likes
        Last Post cupir2
        by cupir2
         
        Working...
        X