Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Naming different setup differetnly and finding an order for it

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

    Naming different setup differetnly and finding an order for it

    HI I have different setups in my strategy but currently it only tracks BT order. I want to name each setup with its name for tracking. In my logic I have two setups trade 600B and DW89

    else if (Trade600B

    && Close[1] > Open[1]
    && High[0] > High[1]
    //
    && High[0] > EMA600[0] && Close[0] < EMA600[0]

    && !(Open[1] > Low[1] && Close[0] > Low[1])
    && EMA600[0] > slowEMA[0] + DFor600B * TickSize)
    {
    entryOrder = SubmitOrderUnmanaged(0, OrderAction.SellShort, OrderType.Market, TradeSize, 0, 0, "", "BT");

    return;
    }

    else if (DW89

    && (Close[1] < Open[1] && High[1] > Open[1])// previous bar bearish
    && (Close[0] < Open[0] && High[0] > Open[0]) // current bar bearish
    && High[1] > High[0] // and low of signal bar is lower then previous bar
    && High[0] > cEMA89[0] && Close[0] < cEMA89[0]
    && High[1] > cEMA89[1] && Close[1] < cEMA89[0]
    && slowEMA[0] < cEMA89[0] - DForDW89 * TickSize) // piercing through 34EMA

    {
    entryOrder = SubmitOrderUnmanaged(0, OrderAction.SellShort, OrderType.Market, TradeSize, 0, 0, "", "BT");

    return;
    }

    ---------- and in my order update I only have BT. How to properly add ​and tradck another name for lets say 600B to be 600B not BT.

    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
    if (orderState == OrderState.Filled && order.Name == "BT" )
    {
    double ask = GetCurrentAsk();
    double bid = GetCurrentBid();

    string oco = Guid.NewGuid().ToString();

    if (order.IsLong)
    {
    double tp = Instrument.MasterInstrument.RoundToTickSize(averag eFillPrice + ProfitTarget * TickSize);

    if (ProfitTarget > 0 && tp.ApproxCompare(ask) > 0)
    {
    targetOrder = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, filled, tp, 0, oco, "PT");
    }

    double sl = Instrument.MasterInstrument.RoundToTickSize(averag eFillPrice - StopLoss * TickSize);

    if (StopLoss > 0 && sl.ApproxCompare(bid) < 0)
    {
    stopOrder = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, filled, 0, sl, oco, "SL");
    }
    }

    if (order.IsShort)
    {
    double tp = Instrument.MasterInstrument.RoundToTickSize(averag eFillPrice - ProfitTarget * TickSize);

    if (ProfitTarget > 0 && tp.ApproxCompare(bid) < 0)
    {
    targetOrder = SubmitOrderUnmanaged(0, OrderAction.BuyToCover, OrderType.Limit, filled, tp, 0, oco, "PT");
    }

    double sl = Instrument.MasterInstrument.RoundToTickSize(averag eFillPrice + StopLoss * TickSize);

    if (StopLoss > 0 && sl.ApproxCompare(ask) > 0)
    {
    stopOrder = SubmitOrderUnmanaged(0, OrderAction.BuyToCover, OrderType.StopMarket, filled, 0, sl, oco, "SL");
    }
    }
    }
    }

    Thank you

    #2
    Hello, thanks for writing in. Do you have a specific question that I can help with or anything you have tried already that does not work?

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello, thanks for writing in. Do you have a specific question that I can help with or anything you have tried already that does not work?
      HI, i tried to add OR statement to add another order name, but it opens an order and it doesnt set SL. I am sure i am missing something
      if (orderState == OrderState.Filled && order.Name == "BT" || order.Name == "C34B")
      entryOrder = SubmitOrderUnmanaged(0, OrderAction.SellShort, OrderType.Market, TradeSize, 0, 0, "", "C34B");

      Comment


        #4
        Hello, thanks for the follow up. The Signal name is how you track each individual order. You would need duplicate logic that will handle the stop and target for the other order not named "BT".

        if (orderState == OrderState.Filled && order.Name == "BT" )
        //submit stop and target for BT entry order

        if (orderState == OrderState.Filled && order.Name == "C34B" )
        //submit stop and target for BT entry order

        Comment


          #5
          thank you very much

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          87 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          151 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          80 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          53 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          62 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X