Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to enter a trade when price cross an indicator

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

    #16
    is this what you are talking about?

    Comment


      #17
      and this one for the other side?

      Comment


        #18
        Hello babouin77,

        Thanks for your post.

        The exitshortstoplimit has an incorrect signal name.

        One issue you will run into is that in real time an order will not fill as fast your code will execute when using Calculate.OnPriceChange or Calculate.OnEachTick so Position.AveragePrice will not be correct until the order fills at the exchange and the exchange sends back an update to the position object with the order status and the entry price (internet transmission time delay).

        What I suggest is that in another set you check for Position.MarketPosition == MarketPosition.Long and then set the exit orders. (create another set for the short orders). You will likely need to a bool variable (one for long and short) so that you only do this once for the order. The bool would need to be true in the conditions and then set false in the actions. In the entry order set you would need to set the bool to be true so that on each new order the sets will respond but again only once per entry order.

        Comment


          #19
          it sounds more complicated than it is lol i wish we can do in strategy builder like we do the ATM strategy where it is easy and automatic

          Comment


            #20
            Good evening,

            Is it possible to set a condition based on the price where 2 emas cross using strategy builder? For example, exit the trade if the cross price is below the 50 EMA.

            Thanks

            Comment


              #21
              Hello conniejforextrader,

              As an example:

              if (CrossBelow(EMA(7), EMA(50), 1))
              {
              ExitLong();
              }

              In the Strategy Builder > Condition Builder select Indicators > EMA, set Period to 7, in the center select CrossBelow, on the right select Indicators > EMA, set Period to 50.

              Below is a link to a support article with helpful resources on getting started with NinjaScript and C#. Be sure to watch the 'Automate Your Trading with NinjaTrader's Strategy Builder' training video.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              43 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              21 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              30 views
              1 like
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              50 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              40 views
              0 likes
              Last Post CarlTrading  
              Working...
              X