Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Close below EMA for exit conditions (backtest works,not with live sim test)

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

    Price Close below EMA for exit conditions (backtest works,not with live sim test)

    Hello,

    I am trying to have an exit long condition for when a bar closes below the 10 EMA. the SS below works for the backtest, but when I go to live sim test, the order exits whenever the EMA is touched, instead of a 5 min candle closing beneath the 10 EMA. Any ideas? Thanks for the help as always!
    Click image for larger version

Name:	SS4.PNG
Views:	283
Size:	27.7 KB
ID:	1173809
    Attached Files

    #2
    Hello abtrad1ng,

    Thanks for your post.

    Are you running your strategy with a Calculate mode of OnBarClose, OnEachTick, or OnPriceChange?

    To have the strategy process only at the close of each bar, you would need to run the strategy using a Calculate mode of OnBarClose.

    See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    Also, see the help guide documentation on the differences on real-time vs backtest (historical).
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    It is expected that a strategy running real-time (live brokerage account, live market simulation, Playback connection etc...) will produce different results than the performance results generated during a backtest.

    ​​​​​​​When in historical data, only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

    Additional information may be found in this NinjaTrader Forum post —
    https://ninjatrader.com/support/foru...mance?t=102504

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon thanks for the info!

      I just checked and it was set to on price change. My entry is based on an active price of the current bar instead of the bar close. If I change the setting to on bar close, will my entry likely need to change as well? Right now my entry is an enter long market if touched @ the ema, whenever the price is <= the ema.

      Comment


        #4
        Hello abtrad1ng,

        Thanks for your note.

        I would not be able to say for sure if you would need to modify your entry order condition.

        If you run the strategy with a Calculate mode of OnBarClose, the strategy will process orders at the close of each bar.

        You could run your strategy using Calculate.OnBarClose to see how the strategy is behaving and make modifications depending on your goals.

        Note that it would be able to calculate some logic OnPriceChange and other logic OnBarClose using IsFirstTickOfBar, however, this would require unlocking the script from the Strategy Builder and manually coding this. You can take the following approach to differentiate logic between OnBarClose and OnPriceChange processing.

        Please see this reference sample which demonstrates a technique used for those who need to separate their logic to calculate some values on each tick and others only on the close of a bar. You will set your host script to Calculate.OnPriceChange and use if(IsFirstTickOfBar) and place all code that needs to calculate once every bar within that condition check. Then place all code that you want to calculate OnPriceChange outside of the IsFirstTickOfBar condition check.

        SampleEnterOnceExitEveryTick -https://ninjatrader.com/support/help...either_cal.htm

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by WilliCarls, Today, 02:01 AM
        0 responses
        5 views
        0 likes
        Last Post WilliCarls  
        Started by Pa_Baz, 12-14-2024, 09:40 PM
        47 responses
        793 views
        1 like
        Last Post Gianmarco Giorgi  
        Started by powbordon1126, 02-06-2025, 08:47 PM
        3 responses
        28 views
        0 likes
        Last Post rockmanx00  
        Started by dhanushatrader96, Yesterday, 10:24 PM
        1 response
        13 views
        0 likes
        Last Post bltdavid  
        Started by reynoldsn, Yesterday, 07:52 PM
        0 responses
        9 views
        0 likes
        Last Post reynoldsn  
        Working...
        X