Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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?
    Chris L.NinjaTrader Customer Service

    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
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          thank you very much

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DerkWehler, Today, 11:35 AM
          14 responses
          24 views
          0 likes
          Last Post DerkWehler  
          Started by tkaboris, Today, 01:42 PM
          3 responses
          5 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by -=Edge=-, 01-31-2018, 09:10 AM
          23 responses
          1,762 views
          0 likes
          Last Post neo302
          by neo302
           
          Started by dbennett3, Today, 01:59 PM
          2 responses
          5 views
          0 likes
          Last Post dbennett3  
          Started by webus, Today, 06:22 AM
          4 responses
          21 views
          0 likes
          Last Post webus
          by webus
           
          Working...
          X