Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Goslin Trigger

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

    Goslin Trigger

    Does anyone have the Goslin Trigger coded and wouldn't mind sharing? This is what I've come up with but it won't compile.


    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class GoslinTrigger2 : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // 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()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "GosOsc"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "GosTrig"));
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    { If (CurrentBar < 16) return;
    //Calculate Goslin Osc.
    double GosOsc = SMA(Close[0],3)[0];
    //Calculate Goslin Trigger
    double GosTrig = SMA(SMA(Close[0],3)[0]-SMA(Close[0],10),16)[0];
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    GosOsc.Set(GosOsc);
    GosTrig.Set(GosTrig);
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries GosOsc
    {
    get { return Values[0]; }
    }

    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries GosTrig
    {
    get { return Values[1]; }
    }

    [Description("")]
    [Category("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, 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 GoslinTrigger2[] cacheGoslinTrigger2 = null;

    private static GoslinTrigger2 checkGoslinTrigger2 = new GoslinTrigger2();

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public GoslinTrigger2 GoslinTrigger2(int myInput0)
    {
    return GoslinTrigger2(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public GoslinTrigger2 GoslinTrigger2(Data.IDataSeries input, int myInput0)
    {
    checkGoslinTrigger2.MyInput0 = myInput0;
    myInput0 = checkGoslinTrigger2.MyInput0;

    if (cacheGoslinTrigger2 != null)
    for (int idx = 0; idx < cacheGoslinTrigger2.Length; idx++)
    if (cacheGoslinTrigger2[idx].MyInput0 == myInput0 && cacheGoslinTrigger2[idx].EqualsInput(input))
    return cacheGoslinTrigger2[idx];

    GoslinTrigger2 indicator = new GoslinTrigger2();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    indicator.Input = input;
    indicator.MyInput0 = myInput0;
    indicator.SetUp();

    GoslinTrigger2[] tmp = new GoslinTrigger2[cacheGoslinTrigger2 == null ? 1 : cacheGoslinTrigger2.Length + 1];
    if (cacheGoslinTrigger2 != null)
    cacheGoslinTrigger2.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheGoslinTrigger2 = tmp;
    Indicators.Add(indicator);

    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>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.GoslinTrigger2 GoslinTrigger2(int myInput0)
    {
    return _indicator.GoslinTrigger2(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Indicator.GoslinTrigger2 GoslinTrigger2(Data.IDataSeries input, int myInput0)
    {
    return _indicator.GoslinTrigger2(input, myInput0);
    }

    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.GoslinTrigger2 GoslinTrigger2(int myInput0)
    {
    return _indicator.GoslinTrigger2(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Indicator.GoslinTrigger2 GoslinTrigger2(Data.IDataSeries input, int myInput0)
    {
    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.GoslinTrigger2(input, myInput0);
    }

    }
    }
    #endregion
    Last edited by Lobo; 12-11-2009, 06:50 PM. Reason: Included code.

    #2
    Hi Lobo,

    For starters, you have the same name doing multiple things.

    EX.

    GosOsc.Set(GosOsc);
    GosTrig.Set(GosTrig);

    Rename your doubles to something else.

    EX. GosOsc1, GosTrig1.

    If that doesn't fix it, do the following...

    Define your doubles in the variables section.

    EX.

    private double GosOsc1 = 0;
    private double GosTrig1 = 0;


    Your code in the update area to look like this.

    //Calculate Goslin Osc.
    GosOsc1 = SMA(Close[0],3)[0];
    //Calculate Goslin Trigger
    dGosTrig1 = SMA(SMA(Close[0],3)[0]-SMA(Close[0],10),16)[0];

    RJay
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Thanks for your speedy reply Ray. Still not compiling though. I am not a programmer although I do fairly well with EasyLanguage so I'm wondering why the declared variable
      "private double GosTrig1 = 0;" has a "d" in front of it when assignig a value to it."dGosTrig1="and the other variable doesn't."GosOsc1=".
      I am getting 2 errors both being CS1002. Colon missing, although they appear all there to me. Also, what would be the best route to learn some basic NinjaScript syntax. I'm gathering that NinjaScript is far from it's own language but more like C+ is that right?Not sure where to start. Thanks again for your help.

      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      [Description("Enter the description of your new custom indicator here")]
      public class GoslinTrigger2 : Indicator
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #endregion
      private double GosOsc1 = 0;
      private double GosTrig1 = 0;
      /// <summary>
      /// This method is used to configure the indicator and is called once before any bar data is loaded.
      /// </summary>
      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "GosOsc"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "GosTrig"));
      CalculateOnBarClose = true;
      Overlay = false;
      PriceTypeSupported = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      { If (CurrentBar < 16) return;
      //Calculate Goslin Osc.
      GosOsc1 = SMA(Close[0],3)[0];
      //Calculate Goslin Trigger
      dGosTrig1 = SMA(SMA(Close[0],3)[0]-SMA(Close[0],10),16)[0];
      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      GosOsc.Set(GosOsc1);
      GosTrig.Set(dGosTrig1);
      }

      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries GosOsc
      {
      get { return Values[0]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries GosTrig
      {
      get { return Values[1]; }
      }

      [Description("")]
      [Category("Parameters")]
      public int MyInput0
      {
      get { return myInput0; }
      set { myInput0 = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Comment


        #4
        Lobo,

        You Have


        #region Variables
        // Wizard generated variables
        private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion
        private double GosOsc1 = 0;
        private double GosTrig1 = 0;

        Do This

        #region Variables
        // Wizard generated variables
        private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)

        private double GosOsc1 = 0;
        private double GosTrig1 = 0;

        #endregion

        ----------------------------------------------

        dGosTrig1 = SMA(SMA(Close[0],3)[0]-SMA(Close[0],10),16)[0];

        GosTrig.Set(dGosTrig1);

        Yes, the d is a typo get rid of it!!!

        -----------------------------------------------

        Recompile and highlight error lines in red and post code.

        RJay
        RJay
        NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

        Comment


          #5
          Thanks, lesson learned there, open up the +'s. Ahh, the joy's of being a newbie again. Here's the code with errors.

          Two errors are:
          Indicator\GoslinTrigger2.cs_;expected_CS1002_Line 47_Colum 32
          Indicator\GoslinTrigger2.cs_;expected_CS1002_Line 46_Colum 31

          I have added numbers 46-47 to the side of the code below. Thanks for your help.

          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          [Description("Enter the description of your new custom indicator here")]
          public class GoslinTrigger2 : Indicator
          {
          #region Variables
          // Wizard generated variables
          private int myInput0 = 1; // Default setting for MyInput0
          // User defined variables (add any user defined variables below)

          private double GosOsc1 = 0;
          private double GosTrig1 = 0;
          #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()
          {
          Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "GosOsc"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "GosTrig"));
          CalculateOnBarClose = true;
          Overlay = false;
          PriceTypeSupported = false;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          46 protected override void OnBarUpdate()
          47 { If (CurrentBar < 16) return;

          //Calculate Goslin Osc.
          GosOsc1 = SMA(Close[0],3)[0];
          //Calculate Goslin Trigger
          GosTrig1 = SMA(SMA(Close[0],3)[0]-SMA(Close[0],10),16)[0];
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          GosOsc.Set(GosOsc1);
          GosTrig.Set(GosTrig1);
          }

          Comment


            #6
            You Have

            47 { If (CurrentBar < 16) return;

            Try

            47 { if (CurrentBar < 16) return;
            RJay
            NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

            Comment


              #7
              Hello Ray,I have modified the code to simplify hopefully. Added 2 new variables AvgOne and AvgTwo.
              I am getting errors on lines 49, 50, 53. See below.
              Each line has same 2 errors each=CS1502 & NT1503.
              Your help is appreciated. I will have to leave now but will resume tomorrow morning.Thanks.

              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              [Description("Enter the description of your new custom indicator here")]
              public class GoslinTrigger2 : Indicator
              {
              #region Variables
              // Wizard generated variables
              private int myInput0 = 1; // Default setting for MyInput0
              // User defined variables (add any user defined variables below)
              private double AvgOne = 0;
              private double AvgTwo = 0;
              private double GosTrig1 = 0;
              private double GosOsc1 = 0;
              #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()
              {
              Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "GosOsc"));
              Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "GosTrig"));
              CalculateOnBarClose = true;
              Overlay = false;
              PriceTypeSupported = false;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              { if (CurrentBar < 16) return;
              //Calculate Goslin Osc.
              49 AvgOne = SMA(Close[0],3);
              50 AvgTwo = SMA(Close[0],10);
              GosOsc1 = (AvgOne-AvgTwo) ;
              //Calculate Goslin Trigger
              53 GosTrig1 = SMA((AvgOne-AvgTwo),16);
              // Use this method for calculating your indicator values. Assign a value to each
              // plot below by replacing 'Close[0]' with your own formula.
              GosOsc.Set(GosOsc1);
              GosTrig.Set(GosTrig1);
              }

              #region Properties
              [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
              [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
              public DataSeries GosOsc
              {
              get { return Values[0]; }
              }

              [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
              [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
              public DataSeries GosTrig
              {
              get { return Values[1]; }
              }

              [Description("")]
              [Category("Parameters")]
              public int MyInput0
              {
              get { return myInput0; }
              set { myInput0 = Math.Max(1, 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 GoslinTrigger2[] cacheGoslinTrigger2 = null;

              private static GoslinTrigger2 checkGoslinTrigger2 = new GoslinTrigger2();

              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public GoslinTrigger2 GoslinTrigger2(int myInput0)
              {
              return GoslinTrigger2(Input, myInput0);
              }

              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public GoslinTrigger2 GoslinTrigger2(Data.IDataSeries input, int myInput0)
              {
              checkGoslinTrigger2.MyInput0 = myInput0;
              myInput0 = checkGoslinTrigger2.MyInput0;

              if (cacheGoslinTrigger2 != null)
              for (int idx = 0; idx < cacheGoslinTrigger2.Length; idx++)
              if (cacheGoslinTrigger2[idx].MyInput0 == myInput0 && cacheGoslinTrigger2[idx].EqualsInput(input))
              return cacheGoslinTrigger2[idx];

              GoslinTrigger2 indicator = new GoslinTrigger2();
              indicator.BarsRequired = BarsRequired;
              indicator.CalculateOnBarClose = CalculateOnBarClose;
              indicator.Input = input;
              indicator.MyInput0 = myInput0;
              indicator.SetUp();

              GoslinTrigger2[] tmp = new GoslinTrigger2[cacheGoslinTrigger2 == null ? 1 : cacheGoslinTrigger2.Length + 1];
              if (cacheGoslinTrigger2 != null)
              cacheGoslinTrigger2.CopyTo(tmp, 0);
              tmp[tmp.Length - 1] = indicator;
              cacheGoslinTrigger2 = tmp;
              Indicators.Add(indicator);

              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>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.GoslinTrigger2 GoslinTrigger2(int myInput0)
              {
              return _indicator.GoslinTrigger2(Input, myInput0);
              }

              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public Indicator.GoslinTrigger2 GoslinTrigger2(Data.IDataSeries input, int myInput0)
              {
              return _indicator.GoslinTrigger2(input, myInput0);
              }

              }
              }

              // This namespace holds all strategies and is required. Do not change it.
              namespace NinjaTrader.Strategy
              {
              public partial class Strategy : StrategyBase
              {
              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.GoslinTrigger2 GoslinTrigger2(int myInput0)
              {
              return _indicator.GoslinTrigger2(Input, myInput0);
              }

              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public Indicator.GoslinTrigger2 GoslinTrigger2(Data.IDataSeries input, int myInput0)
              {
              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.GoslinTrigger2(input, myInput0);
              }

              }
              }
              #endregion

              Comment


                #8
                You Have

                49 AvgOne = SMA(Close[0],3);
                50 AvgTwo = SMA(Close[0],10);

                53 GosTrig1 = SMA((AvgOne-AvgTwo),16);

                Try

                49 AvgOne = SMA(Close,3)[0];
                50 AvgTwo = SMA(Close,10)[0];


                Then move 53 GosTrig1 = SMA((AvgOne-AvgTwo),16); to new location then change to.

                GosOsc.Set(GosOsc1);

                53 GosTrig1 = SMA(GosOsc,16)[0]);

                GosTrig.Set(GosTrig1);
                RJay
                NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                Comment


                  #9
                  That's got it Ray, learned some things.Big thank's to you.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,604 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X