Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

converting the price of a trigger to an double

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

    converting the price of a trigger to an double

    How do I convert a trigger into a double that I can use to make an additional if statement with for a 2 method trigger. Please provide the syntax for this. Thanks you.

    For example:

    if(MACD(Closes[2], 12, 26, 9).Avg[0] > 0) && Close[0] > Close[1])
    {
    triggerone = thecurrent price level
    }

    if(close[0] > trigger1)
    { bull alert goes out}

    #2
    Hello gordongekko,

    Thanks for your post.

    You would need to have declared the variable as a double. private double triggerone;

    Then you can:
    if(MACD(Closes[2], 12, 26, 9).Avg[0] > 0) && Close[0] > Close[1])
    {
    triggerone = Close[0]; // assign the close price of the current bar to triggerone.
    }

    if(close[0] > trigger1)
    { bull alert goes out}

    Comment


      #3
      If I do this will the value of the price attached to this double remain static as in stay the same price it was on the current close at that point in time? So for example, 5 bars later when the the current 0 bar has a different closing price this double will still be assigned the value of the price at the time that method was executed until it executes again and changes this value. Is this correct?

      Also how do I reset the value to null/0 using an additional boolean condition once the 2nd trigger has finished and the alert goes out? Or do i even need to do that since I'm assuming if first method is run again it will just overwrite that old value.

      Comment


        #4
        Hello gordongekko,

        Thanks for your reply.

        Correct, the variable would remain the same until it is changed. If your conditions never permit it will never change. If they permit on the next bar it will change on the next bar.

        You could reset like (assuming this is your second trigger):

        if(close[0] > trigger1)
        {
        //bull alert goes out
        triggerone = 0.0; // reset to zero.
        }

        Comment


          #5
          when you declare a double do you need to use a decimal?

          private double triggerone = 0.0; ?

          Comment


            #6
            Hello gordongekko,

            Thanks for your reply.

            Please see the educational resources here: https://ninjatrader.com/support/help...sic_syntax.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X