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

Order opening

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

    Order opening

    Hi,

    sorry, i have a new question:
    If a strategy has already opened an order, how I can avoid it open a second order?

    Example:

    1 step) The close of a bar exceeds an moving average "X" and my strategy start a long order…OK!
    2 step) The next bar close again falls a little below the moving average "X”, but don’t take the stop.
    3 step) The third bar close again above the moving average "X", but I don’t want that the strategy again start a second long order… HOW DO?

    Thank you for your answer
    germano

    #2
    Hello,

    Take a look at the code below and add the proper criteria for you. This is very basic. There are more accurate but much more complicated ways to do it here:
    The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()



    if(time_to_trade && EMA(5)[0] > EMA(18)[0] )
    {
    EnterLong();
    time_to_trade =
    false;
    }


    if (EMA(5)[0] < EMA(18)[0] && time_to_trade == false)
    {
    ExitLong();
    time_to_trade =
    true;
    }
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks yet Ben

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cre8able, Yesterday, 09:15 PM
      2 responses
      15 views
      0 likes
      Last Post cre8able  
      Started by Trader146, Today, 09:17 PM
      0 responses
      6 views
      0 likes
      Last Post Trader146  
      Started by ttrader23, 05-08-2024, 09:04 AM
      9 responses
      43 views
      0 likes
      Last Post ttrader23  
      Started by ZeroKuhl, Yesterday, 04:31 PM
      8 responses
      46 views
      0 likes
      Last Post ZeroKuhl  
      Started by reynoldsn, Today, 07:04 PM
      0 responses
      11 views
      0 likes
      Last Post reynoldsn  
      Working...
      X