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 Shansen, 08-30-2019, 10:18 PM
24 responses
938 views
0 likes
Last Post spwizard  
Started by Max238, Today, 01:28 AM
0 responses
3 views
0 likes
Last Post Max238
by Max238
 
Started by rocketman7, Today, 01:00 AM
0 responses
2 views
0 likes
Last Post rocketman7  
Started by wzgy0920, 04-20-2024, 06:09 PM
2 responses
27 views
0 likes
Last Post wzgy0920  
Started by wzgy0920, 02-22-2024, 01:11 AM
5 responses
32 views
0 likes
Last Post wzgy0920  
Working...
X