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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      63 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      54 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      61 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Working...
      X