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

Better crossover-based signal reversals to reduce slippage?

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

    Better crossover-based signal reversals to reduce slippage?

    I'm backtesting a strategy right now that uses an SMA and an EMA crossover condition as an entry/exit action. Everything is default except for the minimum bars needed has been changed from 20 to 4 and start behavior is "wait until flat":

    https://i.gyazo.com/2c94330120e5ee61...c41550a067.png

    Right now, the way I have it coded, I use a simple EnterLong and EnterShort to essentially "reverse" when the crossover happens:


    https://i.gyazo.com/dceb055ff2c91029...b45abd08f8.png


    I get this:
    https://i.gyazo.com/0ebaa9b8d0ed973d...c1db12c952.png

    However it seems like I get a lot of slippage and in general it doesn't seem like it's "Reversing" correctly. Is there a better way to code this in strategy builder? A close position action and then a buy/short action at the same time seems strange and... unelegant? to me.

    Also, 2nd mini question: Is there a way to keep my ATM trades marked on the chart and on the control center indefinitely after the end of the day? I come home after the markets close and all my accounts are sitting at 0.00 PnL and I have no markers on my chart to see how my strategy worked. I also have the Tools > Options > Trading > Auto close positions set on for 15:44:00 EST. Could this be why all the markers of entries and exits are disappearing later?
    Last edited by ckabjp; 01-30-2019, 08:21 PM.

    #2
    Hello ckabjp,

    Thanks for your post.

    Changing the minimum bars only impacts the first trade of the strategy which would occur typically on the historical data of the chart.

    The start behavior specifies that when connected to "live" data, if there is a historical order in progress (from the latest historical crossover so there always will be an historical order in progress) that the strategy status would show yellow in the strategy tab and once the next crossover occurs (in the live data) the historical order would be closed and a new live order would be placed at which time the strategy status in the strategy tab would change to green.

    From the screenshots it does appear that the strategy is reversing as expected, you may need to define what you expect. When an entry order is placed, if there is an existing position in the opposite direction, the entry method will first place a market order to close the position and it is labeled "Close Position" The entry method then will place a second order to leave you in the desired direction. The screenshot shows that the close position and next entry are occurring at the same price.

    The first screenshot shows that the strategy is operating under Calculate.OnBarClose. This means that your strategy code is executed at the close of the bar and will run once per bar. At the end of the bar if the crossover condition has been detected then a market order is placed which is filled on the following bar.

    To clarify ATM Strategies are designed to provide discretionary traders with semi-automated features to manage their positions (typically done with the chart trader or superdom). This is not to be confused with NinjaScript Strategies for automated trading systems.

    Yes, once your strategy is disabled, all strategy information is removed from the chart. To see the strategy trades either re-enable the strategy or remove the strategy from the chart. Alternatively, open a duplicate chart and it will show all the real-time trades.
    Last edited by NinjaTrader_PaulH; 01-31-2019, 08:02 AM. Reason: change is to if
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_PaulH Thanks for the response, very helpful.

      Another question you might know: How accurate are these simulated "reversal" orders compared to a real-time trade with regards to the slippage or price changes that a real money market order would have? Different from what you see in the first picture, I have my Strategy Anlayzer options set to have 1 tick of slippage to account for market orders generally giving a poorer entry and exit. Is this useful, or does the simulated strategy already have a market order's generally poor entry already built-in? Another way to ask this would be to say "does a simulated market order also mimic the poor entry and exits of a real money market order? And if so, how accurately?"

      I am doing this on the ES if that helps to give a more accurate idea of the kind of volume and liquidity I'm working with.
      Last edited by ckabjp; 01-31-2019, 04:39 PM.

      Comment


        #4
        Hello ckabjp,

        Thanks for your post.

        As you know market orders are filled relatively immediately and this would be the case on such a liquid instrument as the ES. There are too many variables to be able to answer the "how accurate" question in the strategy analyzer. I would suggest running tests using the playback connection with market replay data to get a better idea of what you considering as slippage. Market replay data more closely resembles the live market as it is a recording of all of the data employed. You can also test your strategy using live data on the simulation account.

        The help guide also offers a good summary: https://ninjatrader.com/support/help...ime_vs_bac.htm
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by chbruno, Today, 04:10 PM
        0 responses
        1 view
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        6 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        127 views
        1 like
        Last Post caryc123  
        Working...
        X