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

Enter on bars, exit on ticks and min bars requirment

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

    Enter on bars, exit on ticks and min bars requirment

    I have some questions about exiting positions.

    My position trades on x min bars, but I want to exit on Ticks. Right now, it waits until the end of the bar to close out the position IF the bar's close meets the exit criteria.
    I set the CalculateOnBarClose = false; but that did not seem to do it.

    The other question is about MinimumBars. So let's say I have it set to 10. When I run the backtest, it waits 10 bars. However, my startegy closes out at 4PM and starts trading again at 6PM. However when it starts trading again at 6PM, it doesn't wait anymore the 10 bars before going in, it trades immediately b/c it considers the bars before it as part of the required 10 bars. How do I set it so that every time it does "SessionBegins" it resets the amount of bars required that is has seen and will then have to wait for the 10 bars again.

    Thanks for helping out a NT Scripting newbie!!

    #2
    Hello,

    My position trades on x min bars, but I want to exit on Ticks. Right now, it waits until the end of the bar to close out the position IF the bar's close meets the exit criteria.
    I set the CalculateOnBarClose = false; but that did not seem to do it.

    >>Are you backtesting? By default backtesting works on closed bar information only. To backtest using ticks see this link:
    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by



    The other question is about MinimumBars. So let's say I have it set to 10. When I run the backtest, it waits 10 bars. However, my startegy closes out at 4PM and starts trading again at 6PM. However when it starts trading again at 6PM, it doesn't wait anymore the 10 bars before going in, it trades immediately b/c it considers the bars before it as part of the required 10 bars. How do I set it so that every time it does "SessionBegins" it resets the amount of bars required that is has seen and will then have to wait for the 10 bars again.

    >>The MinimumBars only comes into play when your SessionBegins. Your session begins times is set either on the chart (double click the chart>session begins and session ends) or in the strategy attachment properties (right click the Strategy tab>New Strategy>Session begins and ends. When your strategy starts working again at 6pm you will need to build in some logic to have it wait the 10 bars that you want then check for a signal.
    DenNinjaTrader Customer Service

    Comment


      #3
      Sounds good, I will build the granularity like you said with the code you described. From the sample code, I understand how you can TRADE on the 1 min bar rather than waiting for your primary bar to close.

      However, is it possible to trade on the 1 min bar as soon as a condition is met where that condition can be met DURING your current primary bar (instead of waiting for that bar to close to see if the condition has bee met?)

      What I mean is : If I want to say "if the current price is above the price of the last 30 min bar", can I accomplish this with the code you referenced?

      Basically, when I use the function High[0], is that going to be updated constantly at every tick or will it only be calculated on the close of this bar?
      In live trading, I think the answer is yes, however in backtesting, I presume the answer is no. Am I correct? Is there any way around this?

      Thanks!

      Comment


        #4
        Not possible in backtesting. Reason is if you have the OHLC value of a bar that bar is closed. There is nothing more you can do once the bar is closed.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by aa731, Today, 02:54 AM
        0 responses
        4 views
        0 likes
        Last Post aa731
        by aa731
         
        Started by thanajo, 05-04-2021, 02:11 AM
        3 responses
        470 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        10 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,237 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        4 views
        0 likes
        Last Post thread
        by thread
         
        Working...
        X