Login Page - Create Account

Support Board


Date/Time: Wed, 15 Jan 2025 21:55:49 +0000



[User Discussion] - Backtest doesn't work as expeted

View Count: 835

[2017-09-16 18:41:04]
ubarolo - Posts: 1
I'm testing this simple trading system that buy the highest high of 5 days back.


float h = 0;
  SCFloatArrayRef Highs = sc.BaseData[SC_HIGH];

  if (sc.Index > 5)
  {

    for (int i = sc.Index - 5; i < sc.Index; i++)
    {
      if (h < Highs[i])
        h = Highs[i];
    }

  }



  
  //LONG
  if (h>0 )
  {
    // Create an s_SCNewOrder object.
    s_SCNewOrder NewOrder;
    NewOrder.OrderQuantity = 1;
    NewOrder.TextTag = "Trading example tag";
    NewOrder.OrderType = SCT_ORDERTYPE_STOP;
    NewOrder.Price1 = h;
    NewOrder.Target1Price = h + TargetValue.GetFloat();
    NewOrder.Stop1Price = h - StopValue.GetFloat();
    Result = sc.BuyEntry(NewOrder);
    //Result = sc.BuyOrder(NewOrder);
    //If there has been a successful order entry, then draw an arrow at the low of the bar.
    if (Result > 0)
    {
      r_EntryInternalOrderID = NewOrder.InternalOrderID;
      SCString InternalOrderIDNumberString;
      InternalOrderIDNumberString.Format("BuyEntry Internal Order ID: %d", r_EntryInternalOrderID);
      sc.AddMessageToLog(InternalOrderIDNumberString, 0);

      BuyEntrySubgraph[sc.Index] = sc.Low[sc.Index];
    }
  }


I don't understand why in the case attached it doesn't work.

Can you help me?
Date Time Of Last Edit: 2017-09-17 10:36:20
image2017-09-16_20h38_14.png / V - Attached On 2017-09-16 18:40:04 UTC - Size: 13.9 KB - 300 views

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

Login

Login Page - Create Account