Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecution and backtesting

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

    OnExecution and backtesting

    I'm trying to develop a strategy where I place a buy stop order (ie once a certain price is reached, I want to place a market buy order... not sure if my terminology is correct because I'm still a newbie), and once that executes, I want to set a stop loss and a target for that order.

    From my readings, I believe OnExecution is the method that I want to override for my strategy.

    My question is, will this work when backtesting? I see that my buy stop orders are being set while backtesting, but I don't see my stop loss orders or my sell limit orders being activated.

    I know that some methods like OnMarketData don't work for backtesting, but in reading the docs for OnExecution, I didn't see anything that said it wouldn't work for backtesting but I may have missed it.

    If they don't work for backtesting, what function is appropriate for backtesting purposes?

    Thanks in advance,

    Ken

    #2
    Ken, while you could work into OnExecution() for maximum control, the SetStopLoss and SetProfitTarget would also do what you need, attach a stop and target order as OCO type to your entry.





    Besides this OnExecution() would work for backtesting as well, if you want to give it a go, here's a sample with code on this topic -

    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()

    Comment


      #3
      Thanks once again for your great help, Bertrand!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      668 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      377 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      110 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X