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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X