Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price of pending orders

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

    Price of pending orders

    ​Hi, i am coding an indicator to place a buy stop order above the current price, but i get error.
    The price is calculated correctly.

    What am I missing?


    Code:
    if ( Close[1] > Open[1] )
                              longprice  = Close[1] + ((Close[1]-Open[1])/2) + (offset * TickSize);
                        else if ( Close[1] < Open[1] )
                              longprice  = Open[1] + ((Open[1]-Close[1])/2) + (offset * TickSize);
                        Print("Current ask  price : "+ GetCurrentAsk(0)+" , buy stop market should be placed at : "+longprice);
            TriggerCustomEvent(o =>
                    {
                        //Order stopOrder = null;
                
        
                        longOrder = myAccount.CreateOrder(Instrument,
                        OrderAction.Buy,
                        OrderType.StopMarket,
                        TimeInForce.Day,
                        nContractQuantity,
                        longprice,
                        0,
                        string.Empty,
                        "Entry",
                        null);
    
                        
                        NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(AtmStrategyName1, longOrder);
                        myAccount.Submit(new[] { longOrder });
                        }, null);
                    }​
    Click image for larger version

Name:	image.png
Views:	129
Size:	59.8 KB
ID:	1341220

    #2
    Hello gyilaoliver,

    You are supplying a price of 0 for the stop price.
    Also, you are supplying the longprice variable as the limit price, though this is a StopMarket order and not a limit order.

    myAccount.CreateOrder(Instrument, OrderAction.Buy, OrderType.StopMarket, TimeInForce.Day, nContractQuantity, longprice, 0, string.Empty, "Entry", null);​

    CreateOrder(Instrument instrument, OrderAction action, OrderType orderType, OrderEntry orderEntry, TimeInForce timeInForce, int quantity, double limitPrice, double stopPrice, string oco, string name, DateTime gtd, CustomOrder customOrder)
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, Yesterday, 01:02 PM
    0 responses
    23 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    16 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    94 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    147 views
    2 likes
    Last Post CaptainJack  
    Working...
    X