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

Moving Stops created by user from a Strategy

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

    Moving Stops created by user from a Strategy

    I'm trying to make move Stops using a supervisor strategy.

    The goal is to update Stops of any active order every time OnBarUpdate() is called.

    I was trying this example on a MarketReplay connection with a entry create by hand using a ATM in the SuperDOM.

    Code:
    protected override void OnBarUpdate() {
        foreach (Order order in Account.Orders) {
            if(Order.IsTerminalState(order.OrderState)){
                // Print(order.ToString());
                }
            else {
                // Try to change the stop
                if (order.OrderType == OrderType.StopMarket){
                    int sign = 1 ; // Let assume entry is Long
                    double new_price = order.StopPrice + sign * TickSize;
                    new_price = order.Instrument.MasterInstrument.RoundToTickSize(new_price);
                    Print(strinf.Format(" -- sign: {2}: changing stop {0} --> {1}", order.StopPrice, new_price, sign));
                    ChangeOrder(order, order.Quantity, order.LimitPrice, new_price);
                }
            }
        }
    }
    Obviously I can change stops by hand on the Chart but ChangeOrder() makes nothing running from the Strategy despite the message "...changing stop..." appears on the console.

    Can anyone show me what I am missing?

    Thanks in advance
    --
    Asterio

    #2
    Hello,

    Thank you for the post.

    In this situation, I could not suggest using a Strategy and it's methods for this specifically. A Strategies methods will not handle manual orders in the way you are wanting. You could instead use the addon Account methods for this task. The Strategy methods such as ChangeOrder would only apply to managed and unmanaged orders but have no use for manual orders.

    A strategy by nature will utilize the Managed, Unmanaged or Atm approach orders but does not observe any manually placed orders. This is to keep the strategy in a virtual state for its isolated reporting. If you wish to interact with manual trading to further execute your ideas, you could use an indicator that observes an account or addon that observes the account for that purpose. As the manual orders will not show up in the strategies account performance, it would really be unnecessary to execute this type of logic in a strategy specifically unless you have a reason to.

    As for the account methods, we have a complete add-on sample that demonstrates all that is possible surrounding creating a whole tool in the platform and managing manual trades. While this may be overkill for the task, the Addon Account page has a simple example of subscribing to the Account where you can then use the normal order overrides like OnExecutionUpdate to track orders.

    Here is a full Addon Account example that could be used in an Indicator Strategy or Addon:


    To create an order: https://ninjatrader.com/support/help...reateorder.htm
    To submit a created order: https://ninjatrader.com/support/help...-us/submit.htm
    To change an order in which you have an Order for: https://ninjatrader.com/support/help...-us/change.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Straegies DO NOT MANAGE manuel orders by DESIGN.

      Originally posted by NinjaTrader_Jesse View Post
      The Strategy methods such as ChangeOrder would only apply to managed and unmanaged orders but have no use for manual orders.
      Ok, I do really understand now. Strategies need to be isolated from user interaction in order not to alter the reporting.

      Originally posted by NinjaTrader_Jesse View Post
      you could use an indicator that observes an account or addon that observes the account for that purpose.
      Thanks for the quick and great response Jesse. I'm going to take the approach I've found in
      the example code that you've provided in the links.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by WeyldFalcon, 12-10-2020, 06:48 PM
      14 responses
      1,428 views
      0 likes
      Last Post Handclap0241  
      Started by DJ888, 04-16-2024, 06:09 PM
      2 responses
      9 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      41 views
      0 likes
      Last Post jeronymite  
      Started by bill2023, Yesterday, 08:51 AM
      2 responses
      16 views
      0 likes
      Last Post bill2023  
      Working...
      X