Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 knighty6508, 05-10-2024, 01:20 AM
            4 responses
            25 views
            0 likes
            Last Post knighty6508  
            Started by OllieFeraher, 05-09-2024, 11:14 AM
            6 responses
            19 views
            0 likes
            Last Post OllieFeraher  
            Started by PaulMohn, 05-02-2024, 06:59 PM
            2 responses
            44 views
            0 likes
            Last Post PaulMohn  
            Started by ETFVoyageur, Today, 02:10 AM
            0 responses
            14 views
            0 likes
            Last Post ETFVoyageur  
            Started by rayyyu12, Today, 12:47 AM
            0 responses
            9 views
            0 likes
            Last Post rayyyu12  
            Working...
            X