Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I am trying to write a strategy using a 50ema of a 50 ema. Can someone help.

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

    I am trying to write a strategy using a 50ema of a 50 ema. Can someone help.

    hello!
    I am trying to write a strategy that is continuously active. I want a to use an input series of the 50 ema times a 50 ema. Then a 50 sma cross. I am trying to set an OCO order, so every time they cross my long will replace my short, and vice versa. Any help would be greatly appreciated.

    #2
    Hello tbergmann9919,

    Welcome to the NinjaTrader forums!

    Below is a link to a forum post with helpful resources on getting started with NinjaScript and C#. Please start with the 'Automate Your Trading with NinjaTrader's Strategy Builder' and 'NinjaScript Editor 401' training videos before continuing further.
    https://ninjatrader.com/support/foru...pts#post786040

    I want a to use an input series of the 50 ema times a 50 ema
    You are trying make an indicator that plots the ema squared (50 ema times a 50 ema)?
    Code:
    Value[0] = EMA(50) ^ 2;
    And then use this as the input series for another indicator?

    Which indicator do you want to use this as the input series for?

    For example if you named the indicator MyIndicator you could use this for the input series of the SMA.
    Code:
    Print(SMA(MyIndicator(), 14));
    Then a 50 sma cross

    What do you want to detect the EMA(5) crossing?

    For example checking if the EMA(50) is crossing above the SMA(14)
    Code:
    if (CrossAbove(EMA(5), SMA(14), 1))
    {
    }
    I am trying to set an OCO order
    To set an OCO pair of two or more orders, you will need to use the unmanaged approach.

    Below are links to examples.
    https://ninjatrader.com/support/foru...579#post770579
    https://ninjatrader.com/support/foru...269#post802269
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the reply, Chelsea! I am attempting to write a strategy that would place an OCO order when the 50x50 Ema crosses a 50simple ema.

      Comment


        #4
        Hello tbergmann9919,

        I'm not understanding. A value squared is never going to cross the original value..

        Lets say the current value of the EMA(50) is 1000. If you multiply 1000 times 1000 (or 1000 ^ 2) this equals 1,000,000. 1 million is never going to cross below the SMA(50) which is likely producing a value around 1000.

        You could add that logic but the condition would never evaluate as true.

        Are you certain you want to multiply the EMA(50) times the EMA(50)?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        89 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        135 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        119 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        69 views
        0 likes
        Last Post PaulMohn  
        Working...
        X