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

Same strategy running on multiple charts?

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

    Same strategy running on multiple charts?

    Is there a conflict if I run the same strategy on the same instrument but on different charts, different time frames?

    I have a custom trailing stop that kicks in X ticks above the entry and the Atr trailing stop becomes the trailing stop.

    It has always worked fine... occasionally I would have to reset the strategy because the trailing stop would kick in as soon as a trade was entered.

    Recently it seems far more "buggy".

    I cannot figure out the problem and the only thing different is have the same strategy on multiple charts.
    Last edited by sdauteuil; 11-09-2020, 10:40 PM.

    #2
    Hello sdauteuil,

    Thanks for your post.

    "Is there a conflict if I run the same strategy on the same instrument but on different charts, different time frames?" Yes, if they are all using the same account, each strategy will be performing live trades but with one account you can only have one account position of Long, short, or Flat, this means that (for example) while one strategy may be long when another strategy goes short the actual account would then become flat yet the strategies both continue as if long and short respectively. The strategies will continue to place live trades regardless of the account position and regardless of the other strategies. This means that a strategy that was long still thinks it is long and when it reaches a profit target or stop (as determined by the strategy code) the strategy would issue a live sell order which if the account was flat would leave the account now short. Or if the account was already short 1 it would now be short 2.

    To avoid any conflicts, you would need to use separate accounts for each strategy instance on the same instrument or run only one strategy per instrument.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I have separate accounts for the long and shorts.

      When I have the strategy running on 2 charts and 2 time frames on the same account when one enters a trade I turn the other one off.

      So there is only one position at a time in any account.

      I have a variable that keeps track of the "trigger state"


      When the position is flat TriggerState = 0

      When a trade executes the TriggerState =1 and the TriggerPrice is set to averagepostion + plus the TriggerAmount... (1000 + 10 = the trailing stop will engage at 1010)

      When the Close[0] > TriggerPrice then TriggerState = 2 the Atr Trailing Stop indicator is now the trailing stop.

      When TriggerState == 2 and close[0] < AtrTrailing stop position is closed... Or the profit target is hit whichever comes first.



      I am wondering if the trigger state from one chart can have a conflict with another?

      Chart1 enters a trade and the TriggerState = 1
      at the same time Chart2 is still in TriggerState = 0

      so there is a lag where the 2 charts are in different states until I can disable the strategy on Chart2.

      I would say everything works fine 70% of the time. The other times either the trailing stop engages immediately or doesn't engage at all.
      I have been watching the output and I can see when there is a problem the relationship between the TriggerState and the TriggerPrice is off.

      I am running sim with the same strategy on different sim accounts to see if that changes anything.

      It is unrealistic for me to have an account for every time frame... currently I am using the same strategy on 2 or 3 different time frames and I have 3 separate strategies...
      Basically I would need about 9 accounts or have a separate named strategy for each instance of use.


      Sorry for being long winded but appreciate the help.

      Comment


        #4
        Hello sdauteuil,

        Thanks for your reply.

        I would suggest that you add print statements to your strategies and have them print the variables on each bar so that you know what the state of these entry/exit conditions are in each strategy. Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm

        In the long run, you might find it easier to combine the strategies into one strategy.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by MarianApalaghiei, Today, 10:49 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        8 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        37 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        46 views
        0 likes
        Last Post bill2023  
        Working...
        X