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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        90 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        137 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        120 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        71 views
        0 likes
        Last Post PaulMohn  
        Working...
        X