Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using an indicator in a strategy normally found in a panel

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

    Using an indicator in a strategy normally found in a panel

    I want to create a strategy that uses an indicator normally not on the chart itself but found below in a panel. For example, if the MACD line (usually found in a panel) crosses above and EMA line, I want to go long. The reverse for a short signal.

    Pasted below is the abbreviated code. Your assistance is greatly appreciated!



    // Condition set 1
    if (CrossAbove(MACD(12, 26, 9), EMA(8), 1))
    {
    EnterLong(DefaultQuantity, "LONG");
    }
    // Condition set 2
    if (CrossBelow(MACD(12, 26, 9), EMA(8), 1))
    {
    EnterShort(DefaultQuantity, "SHORT");
    }
    }

    #2
    Hi Dewurster,

    Thank you for posting.

    While you can do this type of function, I would recommend that you use a different indicator to test with. The EMA will get you a value closer to the instrument price, while the MACD will return with a value typically less than 1. Thus meaning that the conditions you have provided will never be true.

    Could you elaborate what it is you would like to accomplish?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Indicators are just for illustration of the concept

      The two indicators I used are not important. I'm actually using two different indicators in my strategy. They are used to get my point across.

      Comment


        #4
        Dewurster,

        If that is the case then the method you outlined in your first post will accomplish what you are looking to do.
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 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
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X