• 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 authenticx, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post authenticx  
    Started by PN720, Today, 12:54 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by linuxguru, Yesterday, 05:59 PM
    1 response
    26 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by xasser, Today, 02:17 PM
    3 responses
    34 views
    0 likes
    Last Post xasser
    by xasser
     
    Started by ttodua, Today, 01:54 PM
    5 responses
    17 views
    0 likes
    Last Post ttodua
    by ttodua
     
    Working...
    X