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

using multiple timeframes and keltner channel

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

    using multiple timeframes and keltner channel

    Hi

    Im runnning a simple test strategy - going long whenever Close cross above a Keltner lower line.
    But i wish to use multipple timeframes to check other stuff before i enter - so i added one 60 minute DataSeries like this:
    Code:
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Minute, 60);
    }
    Im running this strategy on a 2000 tick chart or testing it on a 2000 tick Strategy Analyzer.
    But i have dificulties understanding the "main" Data series.
    If i only have the above line in my script - does that mean that i have 1 or 2 different data series?

    I run some EnterLong code - inside the
    if (BarsInProgress == 0) sentence. And as far as i can understand this is reffering to the chart or the analyzer "main" data series time frame? in my case the 2000 tick?

    The big issue that i have is that i get less trades if i just add the above mentioned time series with 60 minutes also if i do nothing inside any if (BarsInProgress == 1) sentence...


    So wihtout the 60 minutes added - i get 1265 trades. With the 60 minutes added i get 1237 trades.
    But all my enter/exit rules happens inside the BarsInProgress == 0 - so how can adding another time frame - change the number of trades - unless i actually do anything inside the BarsInProgress == 1 ?


    I also use the below lines of code.

    Code:
    f (BarsInProgress > 1)
    return;
    
    if (CurrentBars[0] <= BarsRequiredToTrade || CurrentBars[1] <= BarsRequiredToTrade)
    return;

    #2
    Hello KarstenKafl,

    Thank you for your post.

    By adding a data series using AddDataSeries, your strategy will contain 2 different series; the 2000-tick primary series, BarsInProgress[0], and the added 60-minute series, BarsInProgress[1].

    There are a number of factors that can contribute to seeing different trade results when adding the secondary data series.

    If you are referencing indicators based on the secondary data series, that may cause differences. Also, checking CurrentBars[1] <= BarsRequiredToTrade is a specific requirement for the added series and may also cause differences to be seen.

    Debugging:

    Ultimately, debugging steps should be taken to monitor the strategy as it is executing to determine why an action has been taken or has not been taken.

    In order to better understand how the code is working, I recommend adding some debugging prints to your strategy. By adding debugging prints for the values used to evaluate your conditions, outside of those conditions you can observe if the strategy's logic is allowing your order submission methods to fire.

    If you are seeing your order submission being reached, but it is not executing, there may be an issue where the strategy is hitting an internal rule that is not allowing you to re-enter. TraceOrders can be used in the strategy (set in State.SetDefaults or in the Strategy Builder under Default Properties) so it prints its order feedback, and you may also observe the log tab of the Control Center for additional information.

    Some items to check when you are taking debugging steps:
    1. Are your strategy's conditions allowing your order submission methods to be reached?
    2. Is the strategy currently in a position that is preventing it from submitting another entry order?
    3. Do you see any errors in the log tab of the Control Center or do Trace Orders give you any feedback?
    Please note if the strategy was developed by somebody other than yourself, the strategy developer should be consulted to confirm if that behavior is expected for their strategy.
    I've included some tips for debugging below. The Playback Connection can be used to replay data as if it were realtime.

    Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

    TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm

    Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk

    Debugging Demo - https://drive.google.com/file/d/1rOz...w?usp=drivesdk

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    941 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    4 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    28 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    33 views
    0 likes
    Last Post wzgy0920  
    Working...
    X