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 NullPointStrategies, Today, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X