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

Clone a Script

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

    Clone a Script

    I would like to clone the following script so that i can use the exact same framework but define different conditions depending on time frame for example 60 minute, 1 day 1 week etc..

    Can someone who is familiar with programming in NT tell me what needs to be changed so that I can create multiple instances of this indicator, I'm sure it's just a question of renaming a few of the functions but through trial and error I can't seem to find the correct ones to change...



    #region Using declarations
    using System;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.ComponentModel;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;

    #endregion

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Candle Stick Pattern Recognittion
    /// </summary>


    [Description("Inside Bar Indicator")]
    public class InsideBar : Indicator
    {
    #region Variables
    // Wizard generated variables

    private DataSeries insidebar;
    private Color upcolor;
    private Color dncolor;
    private bool soundon;
    private double range1 =0;
    private double range2 =0;
    private double range3 =0;
    private double range4 =0;

    // User defined variables (add any user defined variables below)
    #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()
    {
    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = false;
    upcolor = Color.Blue;
    dncolor = Color.Black;
    insidebar = new DataSeries(this);
    soundon = false;


    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // define conditions here
    }

    #region Properties
    [CategoryAttribute("Plots")]
    [DescriptionAttribute("Inside Bar Up Color")]
    [XmlIgnoreAttribute()]
    [NinjaTrader.Gui.Design.DisplayNameAttribute("Insid e Bar Up Color")]
    public Color UpColor

    {
    get { return upcolor; }
    set { upcolor = value; }
    }

    [BrowsableAttribute(false)]
    public string UpColorSerialize


    {
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString( upcolor); }
    set { upcolor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Insidebar
    {
    get
    {
    Update();
    return insidebar;

    }
    }

    [NinjaTrader.Gui.Design.DisplayNameAttribute("Sound on?")]
    [DescriptionAttribute("Sound on?")]
    [CategoryAttribute("Parameters")]
    public bool SoundOn

    {
    get { return soundon ; }
    set { soundon = value; }
    }
    [CategoryAttribute("Plots")]
    [DescriptionAttribute("Inside Bar Dn Color")]
    [XmlIgnoreAttribute()]
    [NinjaTrader.Gui.Design.DisplayNameAttribute("Insid e Bar Dn Color")]
    public Color DNColor

    {
    get { return dncolor; }
    set { dncolor = value; }
    }

    [BrowsableAttribute(false)]
    public string DNColorSerialize


    {
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString( dncolor); }
    set { dncolor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
    }

    #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 InsideBar[] cacheInsideBar = null;

    private static InsideBar checkInsideBar = new InsideBar();

    /// <summary>
    /// Inside Bar Indicator
    /// </summary>
    /// <returns></returns>
    public InsideBar InsideBar()
    {
    return InsideBar(Input);
    }

    /// <summary>
    /// Inside Bar Indicator
    /// </summary>
    /// <returns></returns>
    public InsideBar InsideBar(Data.IDataSeries input)
    {
    if (cacheInsideBar != null)
    for (int idx = 0; idx < cacheInsideBar.Length; idx++)
    if (cacheInsideBar[idx].EqualsInput(input))
    return cacheInsideBar[idx];

    lock (checkInsideBar)
    {
    if (cacheInsideBar != null)
    for (int idx = 0; idx < cacheInsideBar.Length; idx++)
    if (cacheInsideBar[idx].EqualsInput(input))
    return cacheInsideBar[idx];

    InsideBar indicator = new InsideBar();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    #if NT7
    indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
    indicator.MaximumBarsLookBack = MaximumBarsLookBack;
    #endif
    indicator.Input = input;
    Indicators.Add(indicator);
    indicator.SetUp();

    InsideBar[] tmp = new InsideBar[cacheInsideBar == null ? 1 : cacheInsideBar.Length + 1];
    if (cacheInsideBar != null)
    cacheInsideBar.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheInsideBar = 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>
    /// Inside Bar Indicator
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.InsideBar InsideBar()
    {
    return _indicator.InsideBar(Input);
    }

    /// <summary>
    /// Inside Bar Indicator
    /// </summary>
    /// <returns></returns>
    public Indicator.InsideBar InsideBar(Data.IDataSeries input)
    {
    return _indicator.InsideBar(input);
    }
    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Inside Bar Indicator
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.InsideBar InsideBar()
    {
    return _indicator.InsideBar(Input);
    }

    /// <summary>
    /// Inside Bar Indicator
    /// </summary>
    /// <returns></returns>
    public Indicator.InsideBar InsideBar(Data.IDataSeries input)
    {
    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.InsideBar(input);
    }
    }
    }
    #endregion

    #2
    ryebank, you would right click in the script and select then 'save as', enter a new name to which a copy will be saved to, you could then modify this script and have the original one still present.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      and

      the new script i save can be added as well so both scripts can be run on the same chart?

      if this is the case then it's easier than i thought, however i think i 've already tried this

      anyway i'll try again tonight, thanks for the help

      rye

      Comment


        #4
        Yes, it should ryebank, please give it a try and let us know then.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Tim-c, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by FrancisMorro, Today, 03:24 AM
        0 responses
        2 views
        0 likes
        Last Post FrancisMorro  
        Started by Segwin, 05-07-2018, 02:15 PM
        10 responses
        1,771 views
        0 likes
        Last Post Leafcutter  
        Started by Rapine Heihei, 04-23-2024, 07:51 PM
        2 responses
        31 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        945 views
        0 likes
        Last Post spwizard  
        Working...
        X