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

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.
    JesseNinjaTrader Customer Service

    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.


        JesseNinjaTrader Customer Service

        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 RookieTrader, Today, 07:41 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by kujista, Today, 05:44 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by elderan, Yesterday, 08:03 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by samish18, Yesterday, 08:57 AM
          8 responses
          25 views
          0 likes
          Last Post samish18  
          Started by DJ888, 04-16-2024, 06:09 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X