Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange issue with strategy with a daily profit limit

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

    Strange issue with strategy with a daily profit limit

    I have built a strategy that should stop trading once it hits a certain profit for the day. What is odd is that the strategy works like it should when I run it through the strategy analyzer, but when I set it up to run in a live trading situation, it doesn't work. I have 2 versions of the strategy, the one without the profit limit works as it should.

    The strategy is a crossover strategy. I have 3 sets in the conditions and actions section. The first is the buy order, the second is the sell order, and the third is my way to implement the limit.

    The current way I am implementing the limit is that I have a bool variable that defaults to "True". In both of the trading sets, I have it check to see if that variable is still true and if it is, to go ahead and trade. The third set is set up to change that variable to False using the following command - SystemPerformance.AllTrades.TradesPerformance.Tick s.CumProfit>23 Do the following: Oktotrade=False.

    I'm not sure what the issue is. I've double-checked any user error, like using the wrong account, or not using the right expiration time on the instrument. I have also checked for any errors on the log. I am not really sure what else to do. I would appreciate any help I could get.
    Last edited by zachdasher; 06-14-2020, 05:26 PM.

    #2
    Hello zachdasher,

    Thanks for the post.

    If the script is working historically but not in realtime that generally indicates it is working different somehow in relation to the conditions. You may be able to use a set with no conditions as a utility to print values you use in the other sets. That can help to diagnose why a condition is not true.

    Are you currently running the script OnBarClose or have you changed its calculation mode? That is a common item that is different from realtime and historical that can cause differences in how the script runs.

    I look forward to being of further assistance.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello zachdasher,

      Thanks for the post.

      If the script is working historically but not in realtime that generally indicates it is working different somehow in relation to the conditions. You may be able to use a set with no conditions as a utility to print values you use in the other sets. That can help to diagnose why a condition is not true.

      Are you currently running the script OnBarClose or have you changed its calculation mode? That is a common item that is different from realtime and historical that can cause differences in how the script runs.

      I look forward to being of further assistance.
      Thanks for your help! I didn't change the calculation mode. It is still on OnBarClose. I've also tried it with only 2 sets instead of the 3. I would run that same command that I mentioned previously (SystemPerformance.AllTrades.TradesPerformance.Tic k s.CumProfit>23) with the conditions to buy and sell. It did the exact same thing. I've tried to change the parameters to points and currency and still got the same results.

      Comment


        #4
        Hello zachdasher,

        The system performance will be for all trades when using the builder which includes historical. Did you reach the limit in historical data?

        This would be a good situation to add a 4th set that just has the action to Misc -> Print the CumProfit value. You could then observe the output window when you run it to see what the value is reporting as. That would be helpful to know to see if that is affecting the realtime condition. If it is the options could include to reduce the chart data to prevent historical trades or to add a state check for realtime so it only trades in realtime.

        I look forward to being of further assistance.


        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello zachdasher,

          The system performance will be for all trades when using the builder which includes historical. Did you reach the limit in historical data?

          This would be a good situation to add a 4th set that just has the action to Misc -> Print the CumProfit value. You could then observe the output window when you run it to see what the value is reporting as. That would be helpful to know to see if that is affecting the realtime condition. If it is the options could include to reduce the chart data to prevent historical trades or to add a state check for realtime so it only trades in realtime.

          I look forward to being of further assistance.



          I will try this today and let you know how it goes. I appreciate the help!

          -Zach

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X