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

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 burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        14 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        13 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,983 views
        3 likes
        Last Post jhudas88  
        Working...
        X