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

How to use simulated results to turn on/off strategies?

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

    How to use simulated results to turn on/off strategies?

    Folks, I hope you can recommend an approach of using past simulated results, to activate current strategies.

    I run about 50 different strategies against a simulation account, against live market data. Over days and weeks, some strategies go hot and others go cold. I'd like to keep track of the last five days of simulated results for each strategy. If a certain strategy has 4/5 positive days, then I want that strategy to be activiated and trade to my brokerage account. If, over the last five days of simulated trading against the live market day, at least two of those days are bad, then I do not want to activate that strategy against my brokerage account. So, a the week, strategies are activated and deactivated.

    Might you be able to provide a general outline or guidance of how to approach? Thanks,




    #2
    Hi timmbbo,
    I can imagine two possible approaches for this.
    No. 1: Shadow trading within strats
    Create your strats and activate them against your live account. However, don't let them fire off immediately. Instead, simulate the trades within the strat as if you traded live (set a bunch of variables) and log the outcome w/in the strat (or/and in a textfile). As soon as the simulated statistics allow live trading, switch the bool "can do live trade" to yes and trade live. Add the results of your live trading to the same log. As soon as rolling statistics forbid live trading, switch the bool "can do live trade" back to no and trade simulated again.
    No. 2: Mirror strats
    Step 1: Create your paper strats, activate them on paper account and let them write their trades/results/counters to text files (easiest: one per strat).
    Step 2: Create your live strats, activate them on live account, read statistics from specific paper trading text file and use this as signal, if you can do the live trade or not.
    Do not switch off (continued) paper strat logging while trading live to ensure you (continue) to have all statistics for the respective strat in one (paper trading) text file.
    Pro/Con:
    No. 1 requires only half of strats, but uses the statistics of simulated trading to switch on/off the trigger.
    No. 2 requires a pair for each strat, but gives you the result of "real" trades placed at your broker (paper account). Thus, you can better verify if trades were really executed as expected (latency, slippage, etc.).
    NT-Roland

    Comment


      #3
      Hello timmbbo,

      Thank you for your post.

      NT-Roland's suggestions are correct for how you could approach your goal. A StreamWriter would be used to store information related to certain market conditions or trades outside of NinjaTrader. Then, a StreamReader would be used to bring in data stored outside of NinjaTrader to use for calculations.

      For NT-Roland's second suggestion, you could consider using a Sim101 account. You could enable your strategies on the Sim101 account and use a StreamWriter to write trades/results/counters to a text file. Then, you would use a StreamReader to bring in the data from that text file to use for the calculations of your Live strategies.

      Something else you could consider is to use a static method in an AddOn that queues things in a list and writes that list to the file line by line (instead of many instances that all try and write simultaneously). See the forum post below for an example of using static methods in an AddOn.

      Using static methods in an AddOn - https://ninjatrader.com/support/foru...est#post733956

      See the help guide documentation for an example of using a StreamReader/StreamWriter.

      StreamReader - https://ninjatrader.com/support/help...o_read_fro.htm
      StreamWriter - https://ninjatrader.com/support/help...o_write_to.htm

      Let us know if we may assist further.
      Last edited by NinjaTrader_BrandonH; 04-14-2021, 09:21 AM.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        NT-Roland's suggestions are correct for how you could approach your goal. A StreamWriter would be used to store information related to certain market conditions or trades outside of NinjaTrader. Then, a StreamWriter would be used to bring in data stored outside of NinjaTrader to use for calculations.
        Should be StreamReader.

        Comment


          #5
          Hello bltdavid,

          Thank you for your note.

          That is correct. I meant to write StreamReader and have edited my previous post to reflect this.

          Let us know if we may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          6 responses
          32 views
          0 likes
          Last Post ScottWalsh  
          Started by frankthearm, Today, 09:08 AM
          10 responses
          36 views
          0 likes
          Last Post frankthearm  
          Started by mmenigma, Today, 02:22 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by NRITV, Today, 01:15 PM
          2 responses
          10 views
          0 likes
          Last Post NRITV
          by NRITV
           
          Working...
          X