• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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}
    PaulNinjaTrader Customer Service

    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.
        }
        PaulNinjaTrader Customer Service

        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
            PaulNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by E-Viper87, Today, 02:50 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by diddyp1990, Today, 01:28 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Paul  
            Started by dariuszszyc, Today, 09:08 AM
            8 responses
            32 views
            0 likes
            Last Post Nicolas
            by Nicolas
             
            Started by pman777, Today, 12:08 PM
            2 responses
            6 views
            0 likes
            Last Post pman777
            by pman777
             
            Started by Sadat, Today, 09:09 AM
            5 responses
            22 views
            0 likes
            Last Post NinjaTrader_JoshG  
            Working...
            X