Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How do I use the changing of color as a trading condition?

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

    How do I use the changing of color as a trading condition?

    Emaslopecolor
    This is a conversion of the NT7 indicator EMASlopeColor. Please contact the original author for any questions or comments. Colors the EMA plot when rising or falling.


    How do I use the changing of color as a trading condition?

    This isn't working:
    Code:
    if(
      (EMASlopeColor0.PlotBrushes[0][1] == Brushes.LimeGreen)
    && (EMASlopeColor0.PlotBrushes[0][0] == Brushes.Red)
    )
    EnterShort();

    #2
    Hello johnnybegoode,

    Thanks for your post.

    The indicator is simply creating an EMA with some user specified period and using the conditions IsRising() or IsFalling() to then assign the colors. You can use the same thing in your strategy (Specify the same period EMA and then use the IsRising() or IsFalling() conditions on the EMA.
    References:



    If you are using the strategy builder, here is a link to an example where those conditions (IsRising(), IsFalling(), are demonstrated: https://ninjatrader.com/support/help...sfalling_c.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I tried that first but the condition is always true or always false
      and it would keep buying and selling
      when it is Falling/Raising.
      I need the POINT when it Change from
      IsFalling to IsRaising and vice versa.

      How do I get that point
      when it Change from
      IsFalling to IsRaising and vice versa.

      Code:
      if
      (IsFalling(EMASlopeColor0))
      EnterShort();

      Comment


        #4
        Hello johnnybegoode,

        Thanks for your reply.

        You are correct regarding that it would assert true or false on each bar and be either rising or falling on each bar and thus placing entry orders.

        What you can do is use the IsRising and IsFalling conditions to set a bool you create to be either true or false. By checking the opposite state of the bool in the rising or falling condition you can then enter an order when the condition has changed.

        For example, assume we create a bool called goingUp. and using a simple EMA

        if (IsRising(EMA(15))
        {
        if (!goingUp) // check to see if we were previously falling and if so, place an order (Note the ! operator means if the bool is not true).
        {
        EnterLong();
        goingUp = true; // now we set it true because we are now rising and this will prevent further orders.
        }
        }

        if (IsFalling(EMA(15))
        {
        if (goingUp) // check to see if we were going up and if so place a short order
        {
        EnterShort();
        goingUp = false; // set false because now we are going down and this prevent further short orders
        }
        }




        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello sir can you help me with the code please i want to make the same strategy for the EMA

          Comment


            #6
            Hello Marwan,

            Thanks for your post and welcome to the NinjaTrader forums!

            I have received your e-mail to PlatformSupport and will work with you through that means.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by inanazsocial, Today, 01:15 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by rocketman7, Today, 02:12 AM
            0 responses
            10 views
            0 likes
            Last Post rocketman7  
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            1 view
            0 likes
            Last Post dustydbayer  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            23 views
            0 likes
            Last Post trilliantrader  
            Started by Davidtowleii, Today, 12:15 AM
            0 responses
            3 views
            0 likes
            Last Post Davidtowleii  
            Working...
            X