Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

account.CreateOrder in indicator for Stop loss and take profit

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

    account.CreateOrder in indicator for Stop loss and take profit

    Hi I am selecting Limit enum from custom chart trader and want to create buy limit order when price retraces back a half way and also need to create stoploss and take profit order, so not to use ATM for limit orders.
    Do I use same account.CreateOrder for stop loss and take profit?
    OrderType.StopLimit for stop loss?

    entryOrder = account.CreateOrder(instr, OrderAction.Buy, OrderType.Limit, TimeInForce.Gtc, numericStepperValue, Low[0] +barRangez , 0 , string.Empty, "Entry",

    Code:
    else if (wtrOrderEntryCommandsState == WTROrderEntryCommandsState.BuyClose)
                    {
                                        
    //                    if (IsFirstTickOfBar)
    //                    {        
                            double highWick = Math.Abs(High[1] - Close[1])/ TickSize;
                            
                            if (cbxSelectedValue == "Market")
                            {
    //                            if previous candle is bearish and current candle is closing bullish -> buy Close true, otherwise false
                                
                                if (Open[2] > Close[2] &&
                                    Open[1] < Close[1] && highWick <= wickTick
                                    )
                                {
                                    wtrOrderEntryCommandsState = WTROrderEntryCommandsState.BuyCloseAwaiting;
                                
                                    entryOrder = account.CreateOrder(instr, OrderAction.Buy, OrderType.Market, TimeInForce.Gtc, numericStepperValue, 0, 0, string.Empty, "Entry", null);
                                    atmStrategy = NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(atm, entryOrder);
    //                                Print("highWick Buy Close"+highWick);
                                    atm = null;
                                    Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
                                    ResetButtons();
                                }
                                else
                                {
                                    wtrOrderEntryCommandsState = WTROrderEntryCommandsState.Awaiting;
                                    Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
                                    ResetButtons();                                
                                }                            
                            }
                            else if (cbxSelectedValue == "Limit")
                            {    
                                if (High[0] > High[1])
                                {
    //                                wtrOrderEntryCommandsState = WTROrderEntryCommandsState.BuyCloseAwaiting;
                                    double barRangez = Math.Abs(High[1] - Low[0]) / 2;
                                    
                                    entryOrder = account.CreateOrder(instr, OrderAction.Buy, OrderType.Limit, TimeInForce.Gtc, numericStepperValue, Low[0] +barRangez , Low[0] , string.Empty, "Entry", null);
    //                                 atmStrategy = NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(atm, entryOrder);
                                    Print("Limit Time");
    //                                atm = null;
    //                                Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
                                    ResetButtons();
                                }
                                else
                                {
                                    wtrOrderEntryCommandsState = WTROrderEntryCommandsState.Awaiting;
                                    Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
                                    ResetButtons();                                
                                }
                            }
                            else if (cbxSelectedValue == "OCO")
                            {    
                                if (Open[1] < Close[1])
                                {
                                    wtrOrderEntryCommandsState = WTROrderEntryCommandsState.BuyCloseAwaiting;
                                
                                    entryOrder = account.CreateOrder(instr, OrderAction.Buy, OrderType.Market, TimeInForce.Gtc, numericStepperValue, 0, 0, string.Empty, "Entry", null);
                                    atmStrategy = NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(atm, entryOrder);
                                    
                                    atm = null;
                                    Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
                                    ResetButtons();
                                }
                                else// if (Open[2] < Close[2] && Open[1] > Close[1])
                                {
                                    wtrOrderEntryCommandsState = WTROrderEntryCommandsState.BuyCloseAwaiting;
                                
                                    entryOrder = account.CreateOrder(instr, OrderAction.SellShort, OrderType.Market, TimeInForce.Gtc, numericStepperValue, 0, 0, string.Empty, "Entry", null);
                                    atmStrategy = NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(atm, entryOrder);
                                    
    //                                atm = null;
                                    Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
                                    ResetButtons();                            
                                }
    //                            else
    //                            {
    //                                wtrOrderEntryCommandsState = WTROrderEntryCommandsState.Awaiting;
    //                                Draw.TextFixed(this, "atmNotSelected", "", TextPosition.BottomRight);
    //                                ResetButtons();                                
    //                            }
                            }                        
    //                    }
                    }​

    #2
    Hello tkaboris,

    Yes, account.CreateOrder() would also be used for the stop and limit exit orders.

    See the ProfitCaseStopTrailIndicatorExample example here:
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    597 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    555 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X