Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Eixt on MultiTimeFrame

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

    Eixt on MultiTimeFrame

    Hi,
    I try to exit an automated strategy after a certain percentage of profit on a smaller time frame than the strategy trading logic. It works in backtesting, but not in market replay.
    Could you give me an idea what's wrong with the code?
    Thanks
    Attached Files

    #2
    Hello moon_121,

    Thank you for your post.

    I have tested your strategy in Market Replay and it appears to be running correctly. Can you provide additional details on what is occurring on your end?

    Are there errors on the Log tab of the Control Center? If so, what do these errors report?

    I look forward to your response.

    Comment


      #3
      Hi Patrick,
      the strategy disables itself in market replay just after i enabled it. The output window shows, that the strategy confuses the historical trades with the real ones and assumes, that the strategy was already profitable.
      I already changed "Performance.AllTrades". to "Performance.RealtimeTrades." but the result is the same.

      Comment


        #4
        Hello moon_121,

        Thank you for your response.

        Please add a Historical check in your code at the beginning of the OnBarUpdate() method and advise if this resolves the matter.
        Code:
        protected override void OnBarUpdate()
        {
        if(Historical)
        return;

        Comment


          #5
          All clear

          OK, that seems to work fine. Thanks for the help!
          If you find the time: Could you tell me please why one needs the historical data exclusion in this strategy and not on every strategy? Is there something odd with the code?

          Comment


            #6
            Hello moon_121,

            Thank you for your response.

            The reason in this case we do not want to calculate on historical data is so that historical trades are not placed.

            if (Historical) return; can be used to ensure your calculations do not place historical trades.

            Please let me know if you have any questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            65 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            149 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            99 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            286 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X