Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Exit

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

    Strategy Exit

    Hi,

    I am having some exit issue with my live account , i understand that is the volume is too thin the price cannot be match , it would missed the execution point.
    How do i code it so the strategy will exit no matter what the price is ?

    #2
    Hi TYS1986, thanks for posting. The strategy needs to use ExitLong() or ExitShort() to exit a position as a market order. Your strategy needs some code in it that can check a certain criteria for exiting a market position such as a time limit or X amount of bars since the entry. See here for an example:



    Kind regards,
    -ChrisL

    Comment


      #3
      Thanks for the reply,

      my current code is

      int ProfitQuantity = 0;
      if (TradeProfit)
      ProfitQuantity = (int)Math.Floor(SystemPerformance.RealTimeTrades.T radesPerformance.NetProfit / Close[0]);
      EnterShort((int)Math.Floor(AmountToBuy/Close[0]) + ProfitQuantity);
      }
      if (Position.MarketPosition == MarketPosition.Short && Close[3] < Bot[1])
      ExitShort();


      but sometimes it missed the exit and creating a loss in the trade.

      possible to make an exit if it missed the initial exit?​​

      Comment


        #4
        Hi TYS1986, thanks for your reply. It will take C# logic to complete that is specific to your strategy and its actions. The NinjaScript library is a C# based library, so you can use any C# code to control the flow of your strategy. E.g. Monitoring the order and the time an order stays alive can be monitored through the OnOrderUpdate method. We have an example of advanced order management using OnOrderUpdate/OnExecutionUpdate here:



        Kind regards,
        -ChrisL

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        51 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        129 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X