Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order rejected inmediatly after submision

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

    order rejected inmediatly after submision

    Dear Sir.

    The following strategy example shows me an errorrder rejected inmediatly after submision. the strategy run in FDAX.

    the problen isposition.averageprice, but i cannot find the issue.

    best regards

    namespace NinjaTrader.NinjaScript.Strategies.DAX
    {
    public class probarcorto : Strategy
    {

    private SMA SMA1;


    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"probarcorto";
    Name = "probarcorto";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = false;
    ExitOnSessionCloseSeconds = 1800;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.High;
    OrderFillResolutionType = BarsPeriodType.Second;
    OrderFillResolutionValue = 1;
    Slippage = 2;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 1;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = false;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    SMA1 = SMA(Close, Convert.ToInt32(60));
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 2)
    return;

    // Set 1
    if (CrossBelow(Close, SMA1, 1)
    {
    EnterShort("colto");
    }
    if (CrossAbove(Close, SMA1, 1)|| (Close[0]-Position.AveragePrice>40)|| (Position.AveragePrice-Close[0]>240))
    {
    ExitShort("colto");
    }
    if (Close[0] <= Position.AveragePrice - 45 * TickSize)
    ExitShortStopMarket(Position.Quantity, Position.AveragePrice);
    }
    }

    #2
    Hello memonic,

    Thanks for your inquiry.

    When you add prints for Position.AveragePrice, do you see any hints for why the strategy has taken the action it did?

    When you enable TraceOrders, do you get any further information about the order submission that resulted in a rejection?

    If the strategy is not in a position, Position.AveragePrice will be 0. I may suggest to add logic to check Position.MarketPosition before using Position.AveragePrice.

    Resources for troubleshooting this occurrence can be found below.

    Debugging Tips - https://ninjatrader.com/support/foru...ead.php?t=3418

    TraceOrders - https://ninjatrader.com/support/foru...ead.php?t=3627

    Position.MarketPosition - https://ninjatrader.com/support/help...etposition.htm

    Please let me know if I can be of further help.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X