Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to plot a line

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

    #16
    Hello Paul,

    Thanks for the reply.

    Do you mean we can't use a custom variable as 1st parameter of the CrossAbove() method?

    If so why not? Is there a sensible reason?
    If not can you update NT8 to make it accept custom variables for the CrossAbove() method and not just default data series?


    In the mean time is it possible to get the same result as when using the CrossAbove() method but with the greater than operator with custom variables?

    For example when CurrClose transitions from below PrevHigh to above PrevHigh?
    I can't see how to render this transition in the logic.
    Something like that
    Code:
    if (CurrClose < PrevHigh  && [B]'then' [/B]CurrClose > PrevHigh) 
    {
    PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert1.wav");
    }
    Please suggest the simple way (switch, not array etc.), not the hard way to do it if possible.

    Thanks a lot!



    Comment


      #17
      Hello Cormick,

      Thanks for your reply.

      In the help guide is the syntax that shows two ways you can use the method. If you want to use the method, please use one of the two overloads provided:

      CrossAbove(ISeries<double> series1, ISeries<double> series2, int lookBackPeriod)
      CrossAbove(ISeries<double> series1, double value, int lookBackPeriod)

      Reference: https://ninjatrader.com/support/help...crossabove.htm
      (The same is true for the CrossBelow() as well.

      In the Cross methods static values would not cross, this is why one must be a series.

      Yes, you can get the same using C# logical operators.

      For example, using simple moving average and the close price:

      if (Close[0] > SMA(20)[0] && Close[1] < SMA(20)[1]) // is the current close above the sma and (&&) was the previous bar was the close below the sma, this would be a cross condition.

      Comment


        #18
        Hello Paul,

        Thanks for the reply.

        Regarding the references:
        It's not clear from reading the Reference: https://ninjatrader.com/support/help...crossabove.htm what an ISeries refers to.
        I first sort of got what it meant from your other sharing "Here is a reference to all price series you can choose: https://ninjatrader.com/support/help...riceseries.htm"
        Even then I'm still not sure if all the ISeries are encompassed by this second reference.

        It would be of great help to update the documentation to make it explicit at first glance.
        Better to be verbose than laconic in the documentation, with all references exemplified with code, so we don't have to guess/trial and errors/rethink what is only partially stated. In the long run it pays dividends. Same as code commenting. If possible.


        Regarding the Cross methods not accepting static values:
        Suppose I have a non static double I need to make use of via a custom variable.
        For example High[0]-Low[0].
        Expressed as custom variable:
        double HiMinusLow = High[0]-Low[0];

        Why isn't it supported?


        Regarding your C# logical operator statement:
        That's great logic!
        I just got the insight!
        It works backward!
        First the latest bar inequation must be expressed/checked for truth, then the previous bars, backward-wise!
        The engine works backward?

        Or is it also functioning forward (because on a strictly logic basis the AND doesn't differentiate order when checking for true condition)
        if (Close[1] < SMA(20)[1] && Close[0] > SMA(20)[0])

        Thanks a lot!
        Last edited by Cormick; 05-10-2021, 03:27 PM.

        Comment


          #19
          Hello Cormick,

          Thanks for your reply.

          Here is the iseries definition: ISeries<T> is an interface that is implemented by all NinjaScript classes that manage historical data as an ISeries<double> (Open, High, Low, Close, etc), used for indicator input, and other object data. Please see the help guide article on Working with Price Series for a basic overview on how to access this information.
          References:



          You can use the High and Low series in the Cross methods, just not the specific bar []. Using the barsAgo index [] changes it from a series to that specific bar value as a double type. (Note that you could use a specific double type value in the 2nd parameter spot of the Cross methods).

          You can write your logic in whichever way that makes sense to you and follows the C# logic syntax. [0] is the current bar and [1] is the previous bar. If the first 1/2 of the && is not true the second part would not even be evaluated.

          Comment


            #20
            Hello Paul,

            Thank you for the reply and references.
            I didn't find them before. I'll study them and be back later.

            Be well!

            Comment

            Latest Posts

            Collapse

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