Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A few problems

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

    A few problems

    Hi,

    I've written a simple strategy, but picked up a few problems (please see attached screen grab):
    • My Limits (take profits) are not being hit
    • Positions are closed at the end of the day even though Exit on Close is set to false (I'm using the default 24/5 session template)
    • I open my position at 08:30 (NT bar time), but the execution only happens at 08:45 (on a M15 chart)


    The code is at http://freetexthost.com/od24hu0oig

    Many thanks
    Attached Files

    #2
    OK disregard the Exit on Close issue, I see now that it closes the position when the strategy tester reaches it's To Date. The take profit and stop losses are not being hit though.

    Comment


      #3
      Ravish, I would confirm the actual prices your limit exits are submitted at, best would be running via TraceOrders enabled and printing your logic to see if sound. For the default historical fill processing algorithm your limits need to be traded through and not just touched (to make it conservative).

      For the entry fills, yes the order are submitted on the next bar after your signal generated. That's the first potential trade location (in backtesting per default) after the signal trigger bar closed.

      Comment


        #4
        Betrand,

        Please see attached screen grab, with TraceOrders enabled. I drew the blue line on the chart where the limit price is at, and it is not hit. As you can see the price far exceeded the limit.

        With regards to the position opening time, is there no way to open a position at the same time as the OnBarUpdate event is called?
        Attached Files

        Comment


          #5
          You submit the order always for the next bar in your OnBarUpdate(), once the signal is known your bar has closed and you are already on the next bar. What you can look into for backtesting is sending the order to a finer series to simulate intrabar fills.

          You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


          From the trace order, I'm not sure why you would submit a market order type with a limit and stop price?

          A typical exit order would be off type limit and only have a limit price value set - it would also need to Sell as order action to offset your long.

          Comment


            #6
            That's a very roundabout way of doing things.

            If market orders ignore limits and stops, why are there parameters in the SubmitOrder method for limitPrice and stopPrice?

            Can you give me an example please?

            Comment


              #7
              That's just the general SubmitOrder call, you would need to tailor to your needs i.e for a target limit order try

              SubmitOrder(0, OrderAction.Sell, OrderType.Limit, 1, yourLimitPrice, 0, "", "");

              Here's the full docs on it, they highlight to just leave the unneeded parameter set at 0.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by sjsj2732, Yesterday, 04:31 AM
              0 responses
              31 views
              0 likes
              Last Post sjsj2732  
              Started by NullPointStrategies, 03-13-2026, 05:17 AM
              0 responses
              286 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              283 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              133 views
              1 like
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              91 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Working...
              X