Backtesting with Sierra Chart (SC) - Sierra Chart | futures io social day trading
futures io futures trading


Backtesting with Sierra Chart (SC)
Updated: Views / Replies:1,052 / 10
Created: by chris123 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

 
 
Thread Tools
 

Backtesting with Sierra Chart (SC)

 
Frankfurt + Germany
 
 
Posts: 4 since Apr 2018
Thanks: 0 given, 0 received

Backtesting with Sierra Chart (SC)

Hello,

at the moment I backtest my system and try to find an appropriate exit strategy.

I use ACSIL Programming Concepts and have Tick Data available.
After a backtest I check the results using Trade Activity Log, especially columns Profit/Loss, Runup, Drawdown.

I can see that there are sometimes huge price gaps between the price that fulfills my exit condition and the price shown in the trade log. This makes it impossible to test and optimize exit strategies like trailing stops for me.

Example:
I use a trailing stop of 100$ based on the Runup in the code, e.g. stop = runup - $100.
Even if the position is in profit with runups way beyond $100, I see losses in the P&L row after the backtest
that are beyond any tolerance bands acceptable or slippage.

It seems that the price in the log is always the close price of the bar after the exit condition was fulfilled.
Of course if this is a huge bar the price can be way away from my exit condition.


I use Auto Trade System Bar Based Backtest for this because it is relatively fast.

If I use Auto Trade System Replay Backtest it is extremly slow and also the values recorded in Trade Activity Log seem to be wrong, e.g. in Runup column I see huge runups that do not correspond with the charts and are not identical with the runups when I used Bar Based Backtest, e.g. Bar Based Runup = $ 300, Replay Runup = $ 3995
for the same trade.


Another issue I had with Sierra Chart while backtesting was regarding to the position sizing.

I use an algo to determine position size depending on my risk per trade and the following code:

NewOrder.OrderQuantity = Quantity;

Quantity is a variable filled by the algo mentioned above, e.g. 3 contracts.

When I have quantities > 1 I can see partial order fills while backtests in the trade log when my exit conditions are met, e.g. 3 fills at the same time.

Since my code does not use any scaling out methods and since I always exit on the full position size this is very strange (no help from support).

Maybe someone of the forum users can give me an advice if it makes sense to proceed with Sierra Chart
in general for serious trading systems development.


Default section:

sc.StudyDescription = "This study function is a Testenvironment";
sc.AutoLoop = 1;
sc.GraphRegion = 0;
sc.FreeDLL = 1;
sc.AllowMultipleEntriesInSameDirection = false;
sc.MaximumPositionAllowed = 100000;
sc.SupportReversals = false;
sc.SendOrdersToTradeService = false;
sc.AllowOppositeEntryWithOpposingPositionOrOrders = false;
sc.SupportAttachedOrdersForTrading = false;
sc.CancelAllOrdersOnEntriesAndReversals = true;
sc.AllowEntryWithWorkingOrders = false;
sc.CancelAllWorkingOrdersOnExit = false;
sc.AllowOnlyOneTradePerBar = true;
sc.MaintainTradeStatisticsAndTradesData = true;


Statement

if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED) return;

is disabled !


Looking forward to any comments or suggestions.

Regards,

Chris

 
 
Boston, MA USA
 
Trading Experience: Intermediate
Platform: SierraChart
Favorite Futures: ES
 
Posts: 5 since Jun 2018
Thanks: 4 given, 2 received

> if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED) return;
> is disabled !

Yikes! If I disable this, then I get fills from the previous bar instead of the bar after my indicator fires.

 
 
Denver Colorado/USA
 
Trading Experience: Intermediate
Platform: SierraChart, ThinkorSwim
Favorite Futures: ES,ZN,6E,CL,GC
 
LittleFinger's Avatar
 
Posts: 78 since May 2017
Thanks: 68 given, 71 received



chris123 View Post
I can see that there are sometimes huge price gaps between the price that fulfills my exit condition and the price shown in the trade log. This makes it impossible to test and optimize exit strategies like trailing stops for me.
....
It seems that the price in the log is always the close price of the bar after the exit condition was fulfilled.
Of course if this is a huge bar the price can be way away from my exit condition.
....
I use Auto Trade System Bar Based Backtest for this because it is relatively fast.
Chris

It sounds like you shouldn't use the bar-based backtest if you need trades to execute mid-bar. Not sure about the other issues. I hope you find a solution. I am getting used to backtesting in SC also.

 
 
Denver Colorado/USA
 
Trading Experience: Intermediate
Platform: SierraChart, ThinkorSwim
Favorite Futures: ES,ZN,6E,CL,GC
 
LittleFinger's Avatar
 
Posts: 78 since May 2017
Thanks: 68 given, 71 received

This thread has a lot of views.

I think a lot of people must be looking for general SC backtesting info or something.

If there are any SC vets here that use the platform for automation or have extensive backtesting experience with it I would be interested in talking to you.

 
 
Boston, MA USA
 
Trading Experience: Intermediate
Platform: SierraChart
Favorite Futures: ES
 
Posts: 5 since Jun 2018
Thanks: 4 given, 2 received

I have worked with the bar based backtest in Sierra for a couple of weeks and Iíve convinced myself that it can be wildly inaccurate. The tick by tick replay is supposed to be much more accurate, but Iím still trying to figure out how to make it run consistently.

Happy to collaborate on this, LittleFinger.

Anyone with a similar interest is free to message me.


Sent using the futures.io mobile app

 
 
Denver Colorado/USA
 
Trading Experience: Intermediate
Platform: SierraChart, ThinkorSwim
Favorite Futures: ES,ZN,6E,CL,GC
 
LittleFinger's Avatar
 
Posts: 78 since May 2017
Thanks: 68 given, 71 received


bbking View Post
I have worked with the bar based backtest in Sierra for a couple of weeks and Iíve convinced myself that it can be wildly inaccurate. The tick by tick replay is supposed to be much more accurate, but Iím still trying to figure out how to make it run consistently.

Happy to collaborate on this, LittleFinger.

Anyone with a similar interest is free to message me.


Sent using the futures.io mobile app

I'm glad you brought that up. It is unfortunate the way that the bar-based backtest calculates to distort your results to make them look much better.

From what I've seen, if your exit rules can calculate mid bar, then absolutely do not use the bar-based backtest. It will determine the absolute best price to get you out of the trade, even if it was impossible for you to be filled at that price. It will dramatically inflate the results of any backtest that does mid-bar calculations for entry or exit.

However, if you add sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED to your exit logic then you can get close results on the bar based backtest to what you get on a replay test, but there will be some imperfections.

 
 
Boston, MA USA
 
Trading Experience: Intermediate
Platform: SierraChart
Favorite Futures: ES
 
Posts: 5 since Jun 2018
Thanks: 4 given, 2 received


LittleFinger View Post
if you add sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED to your exit logic then you can get close results

This is an important point to reiterate for anyone else. Setting sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED was absolutely critical to prevent the awarding of prices from the before the open point of the bar.

Even so, I found that the "logic" (which is documented) is not really what I want, from the bar based testing. I asked Sierra to give users the ability to control how fills are made, but they have so far studiously avoided even responding to the request.

If you or anyone else would like to be able to control exactly how fills are awarded in your bar backtest, please add a comment in support here:

https://www.sierrachart.com/SupportBoard.php?ThreadID=41741

 
 
Denver Colorado/USA
 
Trading Experience: Intermediate
Platform: SierraChart, ThinkorSwim
Favorite Futures: ES,ZN,6E,CL,GC
 
LittleFinger's Avatar
 
Posts: 78 since May 2017
Thanks: 68 given, 71 received

I agree that some options on the bar based logic would be nice.


I'm currently trying to figure out the best method to limit a strategy to one trade a day.


I was thinking compare current day with day of last fill, but not sure how to get the current day on the chart for backtesting and not actual current day.

 
 
Boston, MA USA
 
Trading Experience: Intermediate
Platform: SierraChart
Favorite Futures: ES
 
Posts: 5 since Jun 2018
Thanks: 4 given, 2 received


LittleFinger View Post
I'm currently trying to figure out the best method to limit a strategy to one trade a day.

I was thinking compare current day with day of last fill, but not sure how to get the current day on the chart for backtesting and not actual current day.

a) How to get the start time of the most recent bar, in an ASCIL study; so here I log the bar time:
 
Code
    // define a macro to make it easy to do very verbose logging.
   #define vv(args...) \
       do {SCString Msg; Msg.Format(args); sc.AddMessageToLog(Msg, 0);} while(0);
    int BarStartTime = sc.BaseDateTimeIn.TimeAt(sc.Index);
    int minuteOfDay = BarStartTime / 60;
    int sec = BarStartTime % 60;
    double close = sc.Close[sc.Index];
    vv("at simtm %02i:%02i:%02i at sc.Index %i, close=%f",  
              minuteOfDay / 60, minuteOfDay % 60, sec, sc.Index, close)
b) To process each bar once (advice from the Sierra documentation); could be generalized...

 
Code
   
    if(sc.GetBarHasClosedStatus(sc.Index) != BHCS_BAR_HAS_CLOSED) {
      return;
    }

    //This demonstrates a simple method to prevent processing on a bar more than once.
    //All bars in the chart other than the last one are only going to have processing for\
 them in a study function, done only once.
    //However, the last bar in the chart could be multiple times during real-time updatin\
g and during a chart replay.
    //
    // must come *after* the BHCS_BAR_HAS_CLOSED check!
    //
    int &LastBarIndexProcessed = sc.GetPersistentInt(1);
    if (sc.Index == 0) {
      LastBarIndexProcessed = -1;
    }
    if(sc.Index == LastBarIndexProcessed) {
      return;
    }
    LastBarIndexProcessed = sc.Index;

    // Here, I think if you now reference a static (file scope or global) variable that holds the
    // time of the last trade, you should be able to limit the trading to once per day.


Last edited by bbking; April 13th, 2019 at 03:24 AM.
The following user says Thank You to bbking for this post:
 
 
Denver Colorado/USA
 
Trading Experience: Intermediate
Platform: SierraChart, ThinkorSwim
Favorite Futures: ES,ZN,6E,CL,GC
 
LittleFinger's Avatar
 
Posts: 78 since May 2017
Thanks: 68 given, 71 received


I'm getting my feet wet still with programming so I'm going to have to work through your example slowly.

Thanks for that


 



futures io > > > > Backtesting with Sierra Chart (SC)
Thread Tools



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$1,000 in Amazon Gift Cards being given away right now from GFF Brokers

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Show us your trading desks and win over $5,000 in prizes w/Jigsaw Trading

August
 

Webinar: Chart Patterns and Practical Trading Stats w/Suri Duddella

Elite only
 

Webinar: Richard Bailey (TBA)

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
market delta default footprint shading on Sierra SC whats1thingnow Sierra Chart 1 December 24th, 2018 03:21 PM
Webinar: Sierra Chart and CTS Futures, Automated Trading Systems and Backtesting Big Mike Sierra Chart 12 July 29th, 2018 01:44 PM
Sierra connection problems - resolved (SC IP change and no DNS Propagation) LDog Sierra Chart 7 June 19th, 2017 10:53 PM
Sierra Chart Professional Software Solutions backtesting Triplane1 Trading Reviews and Vendors 2 December 29th, 2016 02:52 PM
Sierra Chart - Tick Level Backtesting a2trader Sierra Chart 5 June 29th, 2016 03:50 PM


All times are GMT -4. The time now is 08:23 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts