Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 04:34:42 +0000



[Programming Help] - Backtesting

View Count: 456

[2021-07-22 02:50:46]
User626838 - Posts: 2
Hi Sierra Chart Support team
I'm new to SC and Programming and I'm trying to learn how to back test a study using Bars Replay
As I read through the documentation on website, I learnt that for each bar, a study is calculated 4 times for OHLC prices but when I tried to back test a very simple study (place a Buy entry if year > 2021) I noticed that except for the first day which actually has 4 buy entries, the other days have 5 buy entries for each day with the open price has been placed twice buy entry. I'm not sure if i'm doing it wrong or something else:
here is my code:

sc.MaximumPositionAllowed = 100;
sc.AllowOnlyOneTradePerBar = FALSE;
sc.AllowMultipleEntriesInSameDirection = TRUE;


if (sc.BaseDateTimeIn[sc.Index].GetYear() >= 2021)
  {
    s_SCNewOrder neworder;
    neworder.OrderQuantity = 1;
    neworder.OrderType = SCT_ORDERTYPE_MARKET;
    //neworder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
    sc.BuyEntry(neworder);
}

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

Login

Login Page - Create Account