Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Just a little code assist needed for entry filter

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

    Just a little code assist needed for entry filter

    Greets!

    This is likely easy ... just cant yet get my head around it. I want to test an entry filter BarsArray==0, NT7, and did get almost there, but cant figure out the final step on how to calculate iGoShortETOPtest so I can test it against iGoShortETOPtotal

    // ENTER SHORT WHEN
    // (( ETOP #bars) * (ETOP average value for ETOPperiod)) >= (ETOPtotal)
    // so.... filter will be iGoShortETOPtest >= iGoShortETOPtotal


    // - this section all good to use
    private int iGoShortETOPperiod = 5;
    [Description("[SHORT Enter] Period Length for ETOP - Minimum 5")]
    [GridCategory("[SHORT Enter]eTOP)"]
    [Gui.Design.DisplayName ("1.a Period Length for ETOP to GO SHORT")]
    public int GoShortETOPperiod
    {
    get { return iGoShortETOPperiod; }
    set { iGoShortETOPperiod = Math.Max(3, value); }
    }

    private double iGoShortETOPtotal = 0.5;
    [Description("[SHORT Enter] TOTAL value for ETOP - Minimum -.5")]
    [GridCategory("[SHORT Enter]eTOP)"]
    [Gui.Design.DisplayName ("1.b TOTAL value for ETOP to GO SHORT")]
    public double GoShortETOPtotal
    {
    get { return iGoShortETOPtotal; }
    set { iGoShortETOPtotal = Math.Max(0.5, value); }
    }

    private int iGoShortETOPbars = 3;
    [Description("[SHORT Enter] #Bars for ETOP - Minimum 3")]
    [GridCategory("[SHORT Enter]eTOP)"]
    [Gui.Design.DisplayName ("1.c #Bars maximum totaled for ETOP to GO SHORT")]
    public int GoShortETOPbars
    {
    get { return iGoShortETOPbars; }
    set { iGoShortETOPbars = Math.Max(3, value); }
    }
    // --------------------------

    //This is the part where my brain is too confused to resolve correctly, and really && annoying me greatly ...
    //(btw, 4 decimal places expected in ETOP output) ..
    //dataseries setup? double?? OnBarUpdate or OnStartUp ??
    // VERY explicit code assist is really needed .. is there more than 1 right answer?

    iGoShortETOPtest = (iGoShortETOPbars * (ETOP(iGoShortETOPperiod)[0]))

    Thanks mightly for assist!
    TJ

    #2
    Hey Trader.Jon,

    Sorry, I don't follow what you're looking for. Are you looking for help expressing something in NinjaScript? What is it you're trying to do?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      Thanks for the response!

      With the code I already posted, I am looking to have a variable 'total' be a (minimum value) filter to compare against the multipled value of ( specific variable # of bars of the MovingAverage 'X' MovingAverage value[0]) ... that value is 'test' and I cant seem to have it compile correctly ...

      iGoShortETOPtest = (iGoShortETOPbars * (ETOP(iGoShortETOPperiod)[0]))


      I need to find out how to properly code it as a double or a dataseries or both .. for some reason its confusing my head and I cant progress on it, so I need explicit assist, as I read the F1 help to no avail.

      Thanks for assist,
      Jon

      Comment


        #4
        Hi Jon,

        A double value is used if don't need a value synced to every bar. A data series is used when you want a value synced to every bar. A tutorial on custom data series is available here:
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan,

          Respectfully, sending me a link for an indicator tutorial, when I am in a strategy thread, is not helpful. Using the Strategy Wizard has NEVER helped me significantly, and I even paid for and took additional online course (that NT had about 1.5years ago). Those wizards just drive me, lets say, beyond my limits.

          These steps lead me to, I hope, the correct resolution .. testing will verify later

          trying to resolve this line in the code
          sGoShortETOPtest.Set(iGoShortETOPbars * (ETOP(iGoShortETOPperiod)[0]));
          because I see this error on compiling
          The name 'sGoShortETOPtest' does not exist in the current context,CS0103
          I setup a dataseries
          private DataSeries sGoShortETOPtest;
          and have a different error on compile
          Operator '>=' cannot be applied to operands of type 'NinjaTrader.Data.DataSeries' and 'double',NT0019
          due to this filter
          if (
          sGoShortETOPtest >= iGoShortETOPtotal
          )

          when I try to fix that error by following the F1 help NT0019, with this code
          if (
          sGoShortETOPtest[0] >= iGoShortETOPtotal[0]
          )
          compiler responds with
          Cannot apply indexing with [] to an expression of type 'double',CS0021
          so this now compiles
          if (
          sGoShortETOPtest[0] >= iGoShortETOPtotal
          )

          IF you spot something that is an error in my 'fix' please let me know
          Jon

          Comment


            #6
            Hey Jon,

            That looks good. You're comparing two double values by applying indexing to the data series. You can use the indicator data series tutorial in a strategy as well. They're both structured the same way.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            575 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X