• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by EddieBeanPit, 06-21-2019, 07:17 PM
    1 response
    18 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by futures2018!, Yesterday, 05:01 PM
    3 responses
    12 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Splex, Today, 12:04 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by n8dogg59, Today, 06:55 AM
    0 responses
    3 views
    0 likes
    Last Post n8dogg59  
    Started by Tradarr, Yesterday, 07:13 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Working...
    X