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

Automated order when EMA touched

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

    Automated order when EMA touched

    Hello,

    please tell me how I can configure when the EMA is touched from the price, that an automatic order will be placed.

    Thank you very much

    #2
    Hello Uregon,

    Welcome to the NinjaTrader forums.

    You could check that the price is equal to or greater than the EMA.

    if (Close[0] >= SMA(14)[0])

    Or, since the EMA will not often plot at an exact tick size, you could check that the price is equal to or greater than the EMA minus one tick.

    if (Close[0] >= SMA(14)[0] - 1 * TickSize)

    Or you can check that the price is crossing the EMA

    if (CrossAbove(Close, SMA, 1))

    To place a buy market order you can call EnterLong().


    Below I am providing a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...121#post791121
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Uregon,

      Welcome to the NinjaTrader forums.

      You could check that the price is equal to or greater than the EMA.

      if (Close[0] >= SMA(14)[0])

      Or, since the EMA will not often plot at an exact tick size, you could check that the price is equal to or greater than the EMA minus one tick.

      if (Close[0] >= SMA(14)[0] - 1 * TickSize)

      Or you can check that the price is crossing the EMA

      if (CrossAbove(Close, SMA, 1))

      To place a buy market order you can call EnterLong().


      Below I am providing a link to a forum post with helpful information about getting started with NinjaScript.
      https://ninjatrader.com/support/foru...121#post791121
      I want to be able to place a one-time order on the next ema touch. When I see something on the chart I want to be able to put a limit order to trigger based on an ema touch. I am not trying to make a whole strategy solely based on an ema touch. I just want to put one conditional order in. How do I do this?.

      Comment


        #4
        Hello sashol3,

        I"m not certain what you are asking.

        Are you wanting to place a manual order with the mouse and not with a strategy?

        Are you saying the condition I have suggested in post # 2 is not adequate for your needs after testing?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello sashol3,

          I"m not certain what you are asking.

          Are you wanting to place a manual order with the mouse and not with a strategy?

          Are you saying the condition I have suggested in post # 2 is not adequate for your needs after testing?
          Sorry for the lack of clarity. I have not utilized the strategy feature yet. I may not be following you earlier post. I guess what I am trying to say is that I want it to only trigger once after I initiate the strategy. I am not certain if strategies can be used this way. I am seeing a lot of tutorials on backtesting where the strategy seems to run continuously.

          Comment


            #6
            Hello sashol3,

            Sure you can submit an order once from a NinjaScript Strategy.

            You could use a bool in the logic that is set to true once an order is submitted in real-time.

            Code:
            private bool orderSubmittedOnce;
            
            In OnBarUpdate():
            
            if (State == State.Realtime && orderSubmittedOnce == false)
            {
            EnterLong();
            orderSubmittedOnce = true;
            }
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Belfortbucks, Today, 09:29 PM
            0 responses
            6 views
            0 likes
            Last Post Belfortbucks  
            Started by zstheorist, Today, 07:52 PM
            0 responses
            7 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            151 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            6 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            33 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Working...
            X