Python / Sierra Chart modules - Sierra Chart | futures io social day trading
futures io futures trading

Python / Sierra Chart modules
Updated: Views / Replies:213 / 0
Created: by kiwi 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 Search this Thread

Python / Sierra Chart modules

  #1 (permalink)
Gold Coast
Trading Experience: Advanced
Platform: Sierra Chart
Favorite Futures: Futures and Forex
Posts: 20 since Aug 2010
Thanks: 11 given, 34 received

Python / Sierra Chart modules

Here's a little module that will convert all text files in a directory to scid files in the same or another directory. If the constant KEEP_UPDATING is True it will then check the text files every REFRESH seconds and if they've changed it will update the scid files.

Set FILES_IN and FILES_OUT. In windows the format is "C:\\mydir\\mysubdir\\"

Also set Timezone if you wish to change the times in Sierra's scid files (Sierra saves them in the UTC time zone).

Save the code in a file named something like and run it using python
Tested with Python 3.7 on Linux & Windows. Have fun:

Convert's Text files to SCID files for SierraChart
It will create a new scid file for every text file it finds
  format is assumed to be D T O H L C V T with comma separated variables
It will continue to update the scid file every REFRESH seconds
  generally refresh would be set to 1/2 the time period for the text file updates

import os
import struct
from time import sleep
from datetime import datetime as dt, timedelta as tdelta
import subprocess

# these are linux format, windows might need to use double backslashes \\
FILES_IN = "/home/john/Python/Trading/textfiles/"
FILES_OUT = "/home/john/zRamdisk/SierraData/"
TIMEZONE = 0  # scid saved as UTC, use this if the text file is another time zone
KEEP_UPDATING = True  # set to False to convert and stop; True for live updating
REFRESH = 0.25  # refresh every 1/4 second for 1/2 second updating text files
TEXT_FILE_SUFFIX = ".txt"  # usually .txt or .csv

sizeHeader = 0x38
sizeRecord = 0x28
file_header = (b'SCID8\x00\x00\x00\x28\x00\x00\x00\x01\x00\x00\x00\x00\x00' +
               b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +
               b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +

def excel_date(datetime, offset=TIMEZONE):
    """convert date&time with offset in hours to excel format for scid"""
    delta = datetime - dt(1899, 12, 30) + tdelta(hours=offset)
    return delta.days + delta.seconds / 86400

def python_date(exceldt, offset=TIMEZONE):
    """convert date&time with offset in hours to python format"""
    excel_as_delta = tdelta(days=exceldt//1) + tdelta(seconds=exceldt%1*86400)
    return dt(1899, 12, 30) + excel_as_delta + tdelta(hours=offset)

def write_struct(record, f):
    if len(record) == 8 and record[0][0].isnumeric():
        out = [excel_date(dt.strptime(f'{record[0]} {record[1]}', '%Y-%m-%d %H:%M:%S.%f'))]
        out.extend([float(s) for s in record[2:]])
        # note that SC packs dt, O, H, L, C, T, V not V, T so swap them
        wt = struct.pack('d4f4I', out[0], out[1], out[2], out[3], out[4], int(out[6]), int(out[5]), 0, 0)

def create_base(f):
    record = None
    with open(FILES_OUT + f[: -3] +'scid', "wb") as scidfile:
        with open(FILES_IN + f, "r") as txtfile:
            for line in txtfile:
                record = line.split(',')
                write_struct(record, scidfile)
    return f'{record[0]} {record[1]}'  # will update when date+time changes

def update_if_changed(files):
    for f in files:
        with open(FILES_IN + f, "r") as txtfile:
            record = txtfile.readlines()[-1].split(',')
            last_dt = f'{record[0]} {record[1]}'
            if files[f] == last_dt:
            files[f] = last_dt
            with open(FILES_OUT + f[: -3] +'scid', "ab") as scidfile:
                write_struct(record, scidfile)

if __name__ == '__main__':
    files = sorted(k for k in os.listdir(path=FILES_IN) if k[-4:] == TEXT_FILE_SUFFIX)
    files = {k: '' for k in files}
    for f in files:
        files[f] = create_base(f)
    print('finished base')
        # now test each input file each REFRESH interval & update if datetime changed
        while True:

Last edited by kiwi; May 11th, 2019 at 08:44 AM. Reason: update for VT transposition
Reply With Quote
The following 4 users say Thank You to kiwi for this post:


futures io > > > > Python / Sierra Chart modules

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


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
Sierra Chart TPO chart + composite volume profile Big Mike Sierra Chart 10 August 2nd, 2016 08:15 AM
Sierra Chart - Footprint Chart Babool Sierra Chart 5 September 15th, 2014 04:14 PM
Switching from intraday to historical chart type in Sierra Chart Big Mike Sierra Chart 4 April 25th, 2013 04:10 AM
How to disable top most status line of chart in Sierra Chart Big Mike Sierra Chart 9 April 16th, 2013 06:07 PM
Sierra Chart : Tick Chart request. torroray Sierra Chart 19 December 14th, 2012 01:31 PM

All times are GMT -4. The time now is 07:15 AM. (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,
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