Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 09:17:11 +0000



[Programming Help] - differences between SIM and live ארשגןמע with same code in GC only

View Count: 404

[2021-06-15 11:09:26]
User61576 - Posts: 418
pls check the attached screenshots
The same code is running on both instances though not sending my target limit orders

I think but not sure that in the live instance I don't get a confirmation/ price for the position

this is how I am getting the info about the position:

mktBuyDetails.OrderStatusCode == SCT_OSC_FILLED

and here is the full part of sending target orders based on validation of having a position (based on market order)
I add this so you will match the logs on the msg log with the code


  s_SCTradeOrder mktBuyDetails;
  if (sc.GetOrderByOrderID(mktBuyEntryOrderID, mktBuyDetails) && TradeEntry)
  {
    if (mktBuyDetails.OrderStatusCode == SCT_OSC_FILLED && !mktTargetEntries) //if our market entry order was filled than do the following:
    {
      log.Format("AutoTrader Long Market Entry Filled at price: %f", mktBuyDetails.AvgFillPrice);
      sc.AddMessageToLog(log, 1);
      outputFile << log << endl;

      int totalExitsSubmitted = 0;

      totalEntries += mktBuyDetails.FilledQuantity;
      mktPrice = mktBuyDetails.AvgFillPrice;
      target1Price = mktPrice + (tPriceInput.GetInt() * sc.TickSize); //setup the long exit targets based on mkt actual filled price and the ticks setup by the user
      target2Price = mktPrice + (tgt2Ticks.GetInt() * sc.TickSize); //setup the long exit targets based on mkt actual filled price and the ticks setup by the user
      mktBuyEntryFilled = 1;
      mktTargetEntries = 1;

      //target -1 - send order to exchange
      s_SCNewOrder tgt1OrderExit;
      int tgt1SellQty = ceil(totalEntries * (double)tgt1Qty.GetInt() / 100);  // calculate the amount to trade using the % set by the use
      if (tgt1SellQty > totalEntries - totalExitsSubmitted)          // validate we don't send more orders than we have
      {
        tgt1SellQty = totalEntries - totalExitsSubmitted;
      }
      //parameters for the specific order
      tgt1OrderExit.OrderQuantity = tgt1SellQty;
      tgt1OrderExit.OrderType = SCT_ORDERTYPE_LIMIT;
      tgt1OrderExit.Price1 = target1Price;  //long trade - target 1 price
      tgt1OrderExit.TextTag = UserTextTag.GetString();
      if (tgt1OrderExit.OrderQuantity <= 0)
      {
        
        return;
      }

      if(ShowLog.GetYesNo())
      sc.AddMessageToLog("Just before placing tgt1",1);

      int Res = sc.SellEntry(tgt1OrderExit);

      if(ShowLog.GetYesNo())
      sc.AddMessageToLog("Just After placing tgt1",1);

      if (Res > 0)//if we sent a sell limit order which is bigger than 0 than update the log/flags/order id etc.
      {
        log.Format("AutoTrader Long Target-1 Order Submitted at Price: %f Qty: %f Order ID: %d Version: %d",
target1Price,tgt1OrderExit.OrderQuantity,tgt1OrderExit.InternalOrderID,Ver);
        sc.AddMessageToLog(log, 1);
        outputFile << log << endl;

        buyTarget1OrderID = tgt1OrderExit.InternalOrderID;
        totalExitsSubmitted += Res;
      }
      else if(ShowLog.GetYesNo())
      {
        sc.AddMessageToLog("some error occured in placing tgt1",1);
        sc.AddMessageToLog(sc.GetTradingErrorTextMessage(Result),1);
      }


This is on GC/MGC but I have to say that this doesn't happen to me when trading NQ/MNQ (again, same code)

pls advice
thanks
Private File
Private File

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account