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

granular resolution error

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

    granular resolution error

    Hallo,

    in strategy builder I am trying to do very simple thing. When price cross above the indicator SWING, enter long position. (but enter not on bar close but enter on intrabar basis = as soon as the price crosses the swing)
    I have been reading the forum about the granular resolution data series issue, adjusted the code as written (I am not programmer), but the problem is still there.
    If i do the historical data backtest, this error still occures: high order fill resolution is only available for single series strategies. For multi-series......

    Could you please review my simple code, I believe for you it is matter of few seconds. Thank you very much. Regards Radomir







    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class swing3 : Strategy
    {
    private Swing Swing1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "swing3";
    Calculate = Calculate.OnEachTick;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.High;
    OrderFillResolutionType = BarsPeriodType.Minute;
    OrderFillResolutionValue = 1;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    AddDataSeries("NQ 09-19", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Bid);
    }
    else if (State == State.DataLoaded)
    {
    Swing1 = Swing(Close, 3);
    SetProfitTarget("", CalculationMode.Ticks, 20);
    SetStopLoss("", CalculationMode.Ticks, 20, false);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (CrossAbove(GetCurrentBid(0), Swing1.SwingHigh, 1))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    }
    }
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by zstheorist, Today, 07:52 PM
0 responses
5 views
0 likes
Last Post zstheorist  
Started by pmachiraju, 11-01-2023, 04:46 AM
8 responses
150 views
0 likes
Last Post rehmans
by rehmans
 
Started by mattbsea, Today, 05:44 PM
0 responses
6 views
0 likes
Last Post mattbsea  
Started by RideMe, 04-07-2024, 04:54 PM
6 responses
33 views
0 likes
Last Post RideMe
by RideMe
 
Started by tkaboris, Today, 05:13 PM
0 responses
6 views
0 likes
Last Post tkaboris  
Working...
X