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:	153
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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    36 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    14 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X