Announcement

Collapse
No announcement yet.

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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      52 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X