Thank you very much, Andrew, for your work! I will test it, but only in a month or so...
Meanwhile: - does the plug-in support true limit orders? - how does one retrieve historical data for a futures/options contract? how/why would one use GET_DTCSECURITYDEF BrokerCommand?
Thank you!
Re: Sierra Chart Plugin
[Re: Zheka]
#474097 09/20/1812:1509/20/1812:15
1) The plugin is NFA mode (orders) only, so this depends on how Zorro handles pool trades.
2) Sierra's. If you can pull up a chart for that explicit symbol, it should be available. This is why I needed to put in the workaround (more on that later).
re getting historical prices: as I understand, BrokerHistory2 fills in a t6 struct. So, one has then to manually "repackage" them to t8, correct? Does SC plug-in fill in the fVal field in a t6 struct for Spread?
It would be great to get the plug-in to recognize that the instrument is a "contract" and switch to filling in a t8 struct.
Re: Sierra Chart Plugin
[Re: Zheka]
#474209 09/29/1819:2809/29/1819:28
re getting historical prices: as I understand, BrokerHistory2 fills in a t6 struct.
Yes.
Originally Posted By: Zheka
So, one has then to manually "repackage" them to t8, correct?
I suppose filling t8 can be one way to do it. There may be other ways. Anyways, the plugin cannot do this for now, so it must be manual.
Originally Posted By: Zheka
Does SC plug-in fill in the fVal field in a t6 struct for Spread?
For market, yes. Historical data does not have spreads, so that is set to zero.
Originally Posted By: Zheka
It would be great to get the plug-in to recognize that the instrument is a "contract" and switch to filling in a t8 struct.
Sierra Chart is not eager to support options much further than market and trading. Last time I checked, the symbol definitions did not clarify whether they were puts or calls, not even the strike price. (That is, the fields are available in the security definition response messages, but they were left blank.) There might have been a multiplier, not sure. Maybe they added some features ever since?
Depending on what's available, I might be able to put in another custom BrokerCommand to fill a CONTRACT struct for a given explicit SC symbol.
For market, yes. Historical data does not have spreads, so that is set to zero.
What do you mean by "do not have spreads"? Normally both bid and ask data ARE available in SC..
Quote:
Last time I checked, the symbol definitions did not clarify whether they were puts or calls, not even the strike price. (That is, the fields are available in the security definition response messages, but they were left blank.) There might have been a multiplier, not sure
I read your messages on the DTC forum. Do I understand correctly that this is a problem for forming a contract list, but for a directly specified symbol - it is not?
Re: Sierra Chart Plugin
[Re: Zheka]
#474212 09/30/1801:4209/30/1801:42
the plugin is able to buy and sell options symbols directly
I understand that. The question is about simplifying delivery of historical data.
If SC only has 1-min "trade" data - that would be of almost no use (for backtesting): trades do not happen often in a particular strike, and so the last trade tick might be too old to be meaningful.
Re: Sierra Chart Plugin
[Re: Zheka]
#474260 10/02/1812:4110/02/1812:41
The question is about simplifying delivery of historical data.
Did you have a question?
Originally Posted By: Zheka
If SC only has 1-min "trade" data - that would be of almost no use (for backtesting): trades do not happen often in a particular strike, and so the last trade tick might be too old to be meaningful.
The type of historical data available (ticks and/or M1 for any security type) depends on: 1) If applicable, your Sierra Chart Service Package type 2) If applicable, your Sierra Chart Data or Historical Data service 3) If applicable, your broker that Sierra Chart is connected to, and the type of historical service it provides.
As you can see, there are many confounding variables here.
In any case, the plugin does both ticks and M1 for any security type, if available on DTC.
I'm answering your call for beta testers for the Sierra Chart plugin.
I'm currently using SC 1841 and Service package 5.
I've copied the SC Zorro Plugin v 0.9.2.0 to the Zorro plugin folder and created a history file to include the current futures SC symbols: ESZ18 and NQZ18.
When I run a strategy an ES_2018.t6 file is created in the History folder, some data appear to be placed in the file and then I receive a couple of errors. Any guidance you can provide would be greatly appreciated.
Here is a snip-it of the messages I'm receiving: ... Subscribing to Symbol ESZ18... Market depth subscribed. Data is being downloaded from a remote source. Download will start when this is done. Load ES 2018.. 85678 min - ES history unavailable! Error 056: Can't download ES 2017 history Error 046: TRND EMA LookBack exceeded by 37 bars (128) Logout.. ok
I'm using the SC Sim1 account to test the plugin. I'm not subscribed to SC's real-time data, I use Interactive Brokers for RT data. For this test, I was just trying to pull historical data and run the script.
Also, in the user field, I tried leaving it blank (to which I receive an ES history unavailable message). So I run the script with only zlib in the user field and it appears to pull ES data from 2018-04-02 (based on the Warning message: Warning 047: ES first bar at 2018-04-02).
Based on the above warning, I thought a first step would be to use the plugin to successfully pull historical data. So I created the following Asset file: Assets-SC-ES.csv (spacing appears messed up below, but it lines up properly in Excel):
Code:
Name Price Spread RollLong RollShort PIP PIPCost MarginCost Leverage LotAmount Commission Symbol
ES 2700 0.25 0 0 0.25 12.5 6000 0 1 5 ESZ18
I then took the Gap study and modified it slightly:
Code:
// Display gaps in historical data.
// Red lines = gap length in days.
#define ASSET_LIST "History\Assets-SC-ES.csv"
function run()
{
StartDate = 2017;
//StartDate = 2018;
LookBack = 0;
set(PLOTNOW);
assetList(ASSET_LIST);
//asset("EUR/USD");
var m = minutesAgo(1);
plot("Gap",m/(60*24),NEW,RED);
}
Findings: 1. With a StartDate = 2018 the script runs without any errors, but the chart starts on April 2, 2018 rather than January.
2. With a StartDate = 2017 I receive the following message: GapFinder_2018 compliling.......... Error 055: ES History missing (2017 8192 HistoryES.t6) Test: GapFinder_2018 ES 2017..2018 Asset HistoryAssets-SC-ES.csv
The historical data from SC goes back years. So I thought the plugin would connect to SC and download the required data. The data for the ES was downloaded by the plugin when I first ran it, but it only downloaded it from April 2, 2018.
My assumption was that when I tell it to start in 2018 it would download data for all of 2018, when I change the start date to 2017 it would download missing data starting January 1, 2017.
Alas, Sierra Chart's DTC server does not support the export of Continuous Contracts, or any indicator for that matter.
I believe you do have two options:
1) Using Zorro, download all of the individual contracts' historical data and construct a continuous contract indicator from that data.
2) Maybe you can export Continuous bars directly from Sierra Chart to text/csv, and then convert it to t6 using a zorro script. I have not tried this yet.
It is really unfortunate and surprising that their server does not support continuous contracts since SC uses them.
I appreciate your suggestions, but I think option 1 is not realistic due to the amount of work that would be involved in constructing a continuous contract.
When I get some time, I'll try to research option 2 to see how one might convert the downloaded data to t6 files. If you are taking feature requests, this would be a great option to add to the plugin
Take a peek at the CSVtoHistory script, it should point you in the right direction.
Given the DTC implementation, it is not realistic to try to output continuous contracts from the plugin. The SC staff told me finding futures symbols by underlying is on their to-do list, but they never got around to it.
Thank you so much for the Sierra Chart plugin. Sierra Chart is link to IB. I am thinking of what is the advantage of using Sierra Chart plugin instead of just directly using IB plugin.
Re: BETA 0.9.2.0: Sierra Chart Plugin
[Re: firecrest]
#475877 01/11/1913:5601/11/1913:56
If you need lower latency and every last tick, use the Sierra Chart plugin.
If you want access to Sierra Chart's historical data and/or live streaming data service, use the Sierra Chart plugin.
If you need options, use the IB plugin.
If you need all of the above at the same time, use both plugins simultaneously.
Here's why: * The engineers at Sierra Chart have gone so far as to reverse engineer the IB interface so that they are working directly with IB's proprietary protocol rather than a library. They prefer to work directly with sockets. * Likewise, my plugin also works directly with sockets (using Boost Asio as a frontend for the socket API). * Finally, the Sierra Chart plugin supports SET_HWND while the IB plugin currently does not. This means you can get every last tick while running your strategy live. * But Sierra Chart is not eager to support listing options symbols by underlying using their integrated DTC protocol. (Their protocol supports it, but that's irrelevant if the server does not.) * Anyways, the IB plugin works well with options.
Is it possible to have a more information about GET_HWND? What does means?
thanks AndrewAMD
It means Zorro will be notified when a new tick has arrived.
but for this we can use function tick() within Zorro. I don't understand what is the difference... Using function tick() the script is performed for each tick. For me it is very important to understand well the diffrence and why Sierra plugin is more fast respect to MT4. Also with MT4 plugin is it possible to obtain the notification for each tick
Is it possible to have a more details about it to use the plugin in the best way?
Re: BETA 0.9.2.0: Sierra Chart Plugin
[Re: tradingest]
#475984 01/16/1915:0601/16/1915:06
Using function tick() the script is performed for each tick.
Not necessarily.
There is a chain...
BROKER <--> PLUGIN <--> ZORRO <--> tick()
Without SET_WHND:
* Broker says there is a tick. * Plugin retains tick info or does nothing. * (pause indefinitely) * Broker says there is a tick. * Plugin retains tick info or does nothing. * (pause indefinitely) * Zorro's timer says that it is time to check for a new tick on all Assets. * Zorro gets the tick. * Zorro invokes tick().
With SET_WHND:
* Broker says there is a tick. * Plugin tells Zorro there is a tick. * Zorro gets the tick. * Zorro invokes tick().
Using function tick() the script is performed for each tick.
Not necessarily.
There is a chain...
BROKER <--> PLUGIN <--> ZORRO <--> tick()
Without SET_WHND:
* Broker says there is a tick. * Plugin retains tick info or does nothing. * (pause indefinitely) * Broker says there is a tick. * Plugin retains tick info or does nothing. * (pause indefinitely) * Zorro's timer says that it is time to check for a new tick on all Assets. * Zorro gets the tick. * Zorro invokes tick().
With SET_WHND:
* Broker says there is a tick. * Plugin tells Zorro there is a tick. * Zorro gets the tick. * Zorro invokes tick().
very good...wonderful...now is more clear...thanks so much
less steps means more speed
Re: BETA 0.9.2.0: Sierra Chart Plugin
[Re: tradingest]
#476105 01/27/1910:4501/27/1910:45
So from my uderstanding next step is download price data? So it tells me "!1: NumberOfDays or StartDateTime fields must be non-zero.", although I have 2019-2019, maybe it's just information.
It runs forever, when I cancel I receive the information below.
Download... Login 0 SierraChart.. !1: Connected to SC DTC Protocol server. Service=scdataallservices|SymbolSettings=scdataallservices !1: WARNING: Trading not supported !1: TradeAccounts detected: Sim1 !1: Using: Sim1 !1: Balance synchronized.. !1: NumberOfDays or StartDateTime fields must be non-zero. !1: Failed to confirm historical orders !1: Sync hist orders failure. Can't connect! Done
I just see the latest post, ame here, all newest... only sim account to receive data.
Solved: Sierra Chart changed the behavior of their DTC server. It now requires the NumberOfDays field to be filled, even though the documentation says it is not required.
As stated before, Sierra Chart’s DTC server does not support continuous contracts. For the plugin to output continuous contracts, I would have to code the reconstructions myself, which I do not have the time for right now.
Currently, you have two options:
1) The user can manually reconstruct the continuous contract as a Zorro script.
2) The user can export CC CSV directly from Sierra Chart, and import it as T6 for Zorro. I talk about this on my blog:
Does sierra chart bitmex connection use rest or websocket?
Neither. Bitmex set up a DTC service just for Sierra Chart users. It comes complete with live streaming of market data and market depth, historical intraday, live trading, simulated trading, etc.
Originally Posted By: 7th_zorro
I heard that bitmex have order rejection problem. Do you have any experience about that?
I don't use Bitmex, but Sierra Chart has declared the Bitmex interface to be stable. You can read about setting up the Bitmex/SC connection here.
As of Zorro 2.10, it looks like Virtual Hedging will only be a Zorro S feature from that point.
For this plugin in particular, you need NFA flag enabled, and the best Hedge setting is Hedge = 5. This will require Zorro S.
If you are using the free Zorro, you can only use NFA flag enabled and Hedge = 0. This can especially be an issue for portfolio systems using my plugin - in which case, consider Zorro S.
Same issue on other brokers? This means Sierra Chart changed the DTC server again.
I tweaked it again, but this time the historical order requests syncs up the particular trade account. (Apparently they decided they require this field now.)
I was having this issue regardless of whether I was connected to IB or just using SC data service.
The first plugin you provided above fixed that.
I have an issue now, the plugin starts downloading all history for that instrument (3 gb for USDNOK) in sierrachart, while being stuck on "Data is being downloaded for a remote source. Download will start when this is done"
What's a good way of restricting 1) how much data SC will download off the web, and 2) more importantly, how much data gets transferred to Zorro, as this seems to be rather slow.
Thanks again!
Last edited by h4h4rd; 05/16/1914:24.
Re: Sierra Chart Plugin
[Re: h4h4rd]
#477107 05/16/1914:2605/16/1914:26
The second plugin is not able to connect, neither with the download script, nor with the script I posted.
The first plugin seems works, when I change to "trades" and remove the slash from the name, i.e. EURUSD instead of EUR/USD. At least SierraChart starts downloading data.
Hey is there any news regarding this? Again, the first plugin you sent works for me right now, the second one doesn't. For downloading that is, I haven't tried live trading. I can't imagine I'm the only one with this issue. Or do you believe there is something wrong with my setup?
Thanks,
h4h4rd
Last edited by h4h4rd; 05/24/1906:37.
Re: Sierra Chart Plugin
[Re: h4h4rd]
#477145 05/24/1910:5405/24/1910:54
Hey Andrew, just wanted to say thanks for taking the time to write this dll, very much appreciated!
Secondly, I'm having the same problem as h4h4rd, but I'm trying to download historical prices from Bitmex - similar/same error messages showing up on Zorro (using Zorro S) and on Sierra. Was there any update to this?
Thanks for the update! I just tried it out and no issues on my end with historical data now.
For anyone wondering, I'm using a demo of Sierra as provided by Sierra, but I had the Login fields set to Real when I downloaded price history, gonna try out what happens if I set it to Demo later tonight and re-download the data. I personally use CQG and IQFeed, so I'll run it using both data sets to see if I get any issues and report back here.
Also, can't thank Andrew enough, thanks for keeping up with this man, big ups!
I think I read earlier in this thread that to download data, we should be using the symbols listed by Sierra. Using the new plugin, I just tried it with a couple of equity symbols and I'm getting no foreseeable problems. Gonna try it with some futures and cryptocurrency exchanges in a bit as well.
Couple of things;
If I wanted to test using a symbol from another data feed that isn't Sierra, say IQFeed, how would I/would I be able to do that with the plugin? (E.g.
File > Data/Trade Settings > Select IQFeed // File > Find Symbol > [Input/Type out IQFeed Symbol] // Run Zorro download.c script > [Type IQFeed Symbol, not Sierra's Symbol] into the download widget]? )
I tried the above steps with LYFT and I was able to download the asset prices and display a price graph doing the above steps. I attached a picture as well.
My questions is, how do I know that I pulled from IQFeed and not Sierra's data feed? I'm assuming the message log from Sierra would let me know that (?) Here are some select messages that might help with the clarification; -----------------------
// After selecting IQFeed and inputting LYFT as the symbol, I tried to chart the price in Sierra's software. In the message log I received notification that the data was from IQFeed
IQFeed | Starting real-time market data updates for: LYFT. ID: 3 | 2019-06-27 16:51:41.485 IQFeed | Requesting security definition data for: LYFT. ID: 3 | 2019-06-27 16:51:41.485 IQFeed | Using primary service for historical data for LYFT | 2019-06-27 16:51:41.485 Intraday data recording state for symbol LYFT is set to download 'Pending'. | 2019-06-27 16:51:41.485 Delaying start of download for LYFT | 2019-06-27 16:51:41.486 HD Request # 7 | Downloading Intraday chart data for LYFT to the file LYFT.scid. Service: dtn | 2019-06-27 16:51:46.214
// When I tried to download/chart the data using the plugin, I received this notification (I'm assuming this means that the data is being downloaded from IQFeed > since dtn = IQFeed, but just wanted to make sure : D)
Sent successful Logon response message to client. Username: _. Result text: Connected to SC DTC Protocol server. Service=dtn|SymbolSettings=dtn | 2019-06-27 16:52:52.195
-----------------------
And lastly, I think I read in the Zorro manual that imported data converts into UTC (correct me if I'm wrong), so the timestamps we see on the time scale are in UTC as well, even if I set my Sierra settings to my local time?
As I was playing around with loading different asset data, I noticed that for Bitmex, it's skipping regular time periods, specifically the same weekend day every single week [See picture below]. I highlighted the areas of interest.
I'm using the download widget that runs from Zorro's included download.c script and after checking that the asset was stored in the Zorro History folder, I plot the price to check the data according to this script;
//Run to check price curve data
function run() { //Defining a 1 minute period BarPeriod = 1;
//Defining the two assets used in spread calculation asset("nameofasset"); var assetprice = priceClose() ;
//Plots plot("assetprice",assetprice,NEW,BLUE); }
Not sure if this is due to the plugin, or Sierra's side? Or do I need to do something to the download.c script from Zorro?
There's definitely weekend data, I loaded historical charts off Sierra using the same symbol and was able to display the entire history (plus, almost all cryptocurrency exchanges are 24/7 barring downtimes.
**** Also, I checked BTC data off of Poloniex and received a similar result (regularly occurring, missing data that seems to be a weekend day), see second attached picture. I checked my Sierra settings and it's set to load weekend data.
I loaded the data up in Z History Editor and was able to see continuous data (including the weekends), I checked this on ES futures as well as some cryptocurrencies. Thanks again for the assist [I read up on the weekend bit after you posted about it, and for anyone who didn't know, I think the Zorro Manual > Time and Calendar Functions > BarMode should be helpful]. I'm gonna play with the code and try to get Zorro to chart all data (including weekends).
For anyone who's curious, I've been loading 1 minute data (so t6), but I'll mess around with downloading/checking tick data and report how that goes.
Also, gonna code a couple simple strategies/phantom trade them to see how the plug-in works for trading execution and will also post results - Thanks again to Andrew, the update is going swimmingly!
Just a quick update - I have plans to spin off the sockets backend into its own DLL library with a C API, since it depends on Boost. Maybe even make the library directly accessible from Zorro.
This way, the plugin itself would not have a direct dependency on boost. This will make code management much easier.
Also, I dislike my current multi-threaded design - there's no need for it. I can call windows handles using sockets, so networking can still be asynchronous while still single-threaded.
I can afford to be a perfectionist since there's no deadline, and this is not a funded project. But at the end of the day, I'm trying to make this repository as easy to maintain as possible.
Hey man, just wanted to say thanks for continually updating us on this, your work is very much appreciated! I have yet to deploy live capital using your plugin (been working through a bunch of coding examples), but I'm excited to try it out
I'm thinking about giving the Sierra Chart a try for historical data. I'm happy with my own broker plugin for live trading and live pricing feed, but not quite happy with my current historical EOD and M1 data feed setup. Can I use the Sierra Chart plugin for historical data ONLY -- basically what assetHistory() would provides. Thanks.
I got SC working with a simple script and it's downloading D1 and M1 historical data perfectly. I had to point the account to SierraChart.dll in Accounts.csv, but then I cannot specify my own plugin for my live trading.
Ideally, I would like my use of SC to be something like assetHistory(FROM_SC,xxx), while all trading and real-time data in Live mode goes through my broker plugin.
Thanks again for your work on the Sierra Chart plugin!
It’s in beta, and I planned on rewriting the backend in the near future.
In other words, don't do it.
For your own purposes, you can instead dynamically load the DLL and invoke BrokerOpen, BrokerLogin, and BrokerHistory2, all entirely from a Zorro script.
My need isn't urgent. My multiple data provider approach via Zorro script, while not elegant, is working so far. Sierra Chart has all the data I'm looking for a very reasonable price, an would be an elegant solution.
Why did you hand over null pointers to fpError and fpProgress? I bet my plugin crashes on calling BrokerError and BrokerProgress. (Obviously, there's no reason to check if the pointers are valid )
Also, char* Accounts is an output, so why are you supplying a string literal?
Mind you, my plugin was designed to be used by Zorro.
Make up your own function and pass a function pointer. You know what to do, right? Just do what the manual says the functions do.
Also, your BrokerHistory2 call is wrong. You don't even know how much memory you need - you need to call GET_MAXTICKS, and then call malloc.
~~~~ IN GENERAL~~~~ Any time that the plugin outputs memory (such as T6 ticks or strings), the caller is responsible for supplying the memory. You have supplied memory zero times. Fix this.
If you're not sure whether or not it's an output, read the manual.
Hi Andrew, my programming skills are not close to your level by any measure. This DLL loading thing is completely new to me.
I've read the manual and continued to hack at it and still doesn't work. I even copied SierraChart.dll to SierraChart2.dll, put in the root Zorro directory, and tried a different way of loading the DLL.
I'm getting a compile error about wrong type CONV:POINTER::DOUBLE at the BrokerOpen line. I don't think I'm passing the function pointers in correctly. I tried my best with my rusty skills. Here's my stripped down code. I'll worry about BrokerHistory once I get pass BrokerOpen :-)
Any thoughts?
Thanks.
Code
#include <stdio.h>
#include <default.c>
#include <contract.c>
int __cdecl BrokerOpen (char*, FARPROC, FARPROC);
BrokerOpen = DefineApi("SierraChart2:BrokerOpen");
int __cdecl BrokerLogin (char*, char*, char*, char*);
BrokerLogin = DefineApi("SierraChart2:BrokerLogin");
int __cdecl BrokerHistory2 (char* , DATE , DATE , int , int , T6* );
BrokerLogin = DefineApi("SierraChart2:BrokerHistory2");
int BrokerError(char* message) {
printf(message);
}
int BrokerProgress(DWORD progress) {
printf("stuff");
}
void run()
{
StartDate = 20190101;
EndDate = 20191031;
Verbose = 7|DIAG;
string temp = "AAPL";
History = "_SC.t6";
string temp1[100];
BrokerOpen(temp1, &BrokerError, &BrokerProgress);
char retAcct[1024];
BrokerLogin ("XXXXX", "XXXXXX", "Demo", retAcct);
}
Andrew, looks like it's working pretty well in TEST or TRADE mode with multi-asset strategies too. I will post the script here when I am comfortable there are no bugs.
However, I noticed that the volume data looks suspicious. It ramps up, zero, ramps up, zero. See the attached chart for AAPL.
It’s by design. Now you can calculate volume per bar by calculating the difference between them. Plus it matches the volume you get in [Trade] mode.
Did you know that if you have M1 data, and you use a larger BarPeriod than 1, then Zorro discards all of the volume data in between each bar? For example, if you set BarPeriod to 5, Zorro discards four fifths of your volume data.
See the attached image comparing the EOD SPX data from Sierra Charts vs. Yahoo.
I think you mean to timestamp the bar just before midnight, but because it's stamped as midnight, the bar data is actually assigned to the next day. I noticed this on 1-minute bars as well yesterday, but the problem at 1-minute resolution was annoying but not a big enough deal. But on daily bars, that's a pretty big deal.
The EOD bars appear to be correct, the M1 bars do not. You SC data is 1 minute ahead. It'd be nice if you fix that too so the bar charts look the same as conventional trading platforms.
BTW, since you are putting UTC timestamps in the T6 files, your DLL should also adjust for daylight savings time. Or is the sierra chart data already in UTC time? As you know the UTC offset is different when in DST.
Zorro’s T6 specification is that intraday historical time stamps should align with the end of the period. Whereas for daily, the stamp should be at midnight UTC at the very beginning of the day. I am operating in accordance with this specification.
I read the manual on timestamps again and it's a bit confusing. So I asked support this question and they gave this answer:
Question: When creating an M1 t6 file, what is the timestamp of an M1 bar that covers the period from 11:16:00 - 11:16:59. Is it 11:16:00 or 11:16:59 or 11:17:00 ?
Answer: it should be 11:16:59.
Unless History.c is displaying it wrong, it looks like your timestamp for this example is 11:17:00.
You mean to tell me that when you download historical data from the official oP Group plugins that they actually have the seconds offset by one before the end of the period?
This is a problem that I encountered early on with the way SierraChart's stores its bars.
For backtesting, one typically wants the [A,B) interval or (A,B] interval covered by the bar to be designated by time B. That way it is less likely that you will peek into the future during your backtest. At the time B, you are allowed to observe bars labelled with B or before.
However, because SierraChart is repeatedly re-drawing the bar on the chart as it it is forming, they want to publish the bar to the internal ACSIL DLL code with a more constant time stamp. At least this is how I rationalize the observation that they use the "A" timestamp (beginning of bar) everywhere instead of the "B" end-of-bar timestamp.
Last edited by wzschultz; 12/05/1901:32. Reason: grammar
Thanks to Andrew's help, I'm pretty happy with my version assetHistorySC() that gets historical data from Sierra Charts like the standard assetHistory() function in Zorro. It works in Test, Live PRELOAD. It initially loads at least 6 years of EOD data, and as much M1 data as you have in your Sierra Charts setting. Then it adds new data to the T6 file as needed (usually in Live mode) on subsequent runs.
The only problem is Zorro crashes when you close the Zorro instance. I think it has to do with dangling DTC sockets to the Sierra Charts program when the Zorro instance is closed. Aside from having to click and clear the crash message, I haven't seen any problems.
I like using SC because it's a single source for high quality historical EOD and M1 data, with dividend adjusted prices, for all kinds of symbols starting at $26/month. Before SC, I had to piecemeal my data sources depending on what my strategy requires.
Here is the code. Use and modify at your own risk :-)
Code
int __cdecl BrokerOpen (char* Name, void* fpError, void* fpProgress);
API(BrokerOpen,Plugin\\SierraChart)
int __cdecl BrokerLogin (char* User, char* Pwd, char* Type, char* Accounts);
API(BrokerLogin,Plugin\\SierraChart)
int __cdecl BrokerHistory2 (char* theasset, DATE tStart, DATE tEnd, int nTickMinutes, int nTicks, T6* ticks);
API(BrokerHistory2,Plugin\\SierraChart)
int fError(char* message) {
//printf("\n%s",message); // uncomment to display brokerError messages from SC
return 0;
}
int fProgress(DWORD prog) {
return wait(0);
}
function connectToSierraChart()
{
//-----------------------------------
// connect at INITRUN
//-----------------------------------
if (!Init) return 0;
char outName[64],outAccount[1024]; memset(outName,0,64); memset(outAccount,0,1024);
int o = BrokerOpen(outName,(void*)fError,(void*)fProgress);
if (o!=2) {
printf("%s BrokerOpen FAILED!\n", outName);
quit("#quit...");
}
o=BrokerLogin ("","","Demo",outAccount); // don't need login credentials here for localhost SC
if (!o) {
printf("%s BrokerLogin FAILED!\n", outName);
quit("#quit...");
}
}
int assetHistorySC(string theAsset)
{
if (!Init) return 0;
int barperiod = BarPeriod;
//----------------------------------
// setup start and end dates
//----------------------------------
int M1back = (LookBack*BarPeriod)/(7*60); // days of lback
int DailyLBack = (LookBack+2*UnstablePeriod);
int start = min(ymd(wdate(NOW)-6*365), ymd(dmy(StartDate)-2*ifelse(barperiod<1440,M1back, DailyLBack))); //6 years or more
int end;
string t6Out[100];
if (barperiod<1440) {
sprintf(t6Out,strf("History\\%s%s",theAsset,History));
barperiod = 1;
end = ymd(wdate(NOW)+1); // +1 to get most current M1 bar
}
else {
sprintf(t6Out,"History\\%s.t6",theAsset);
end = ymd(wdate(NOW)-1); // -1 to get up to yesterday
}
//-------------------------------------
// check to see if exiting t6 is in range
//-------------------------------------
if (file_length(t6Out)) {
int records = dataLoad(33,t6Out,7);
int fileStart = ymd(dataVar(33,-1,0));
int fileEnd = ymd(dataVar(33,0,0));
//printf("fileStart=%d fileEnd=%d\n",fileStart, fileEnd);
// if Test or Train, don't download if data in range
if ( (!Live && EndDate<=fileEnd && barperiod==1440)
|| (Live && end<=fileEnd && barperiod==1440)
)
{
printf("\n[%s] historical data up to date... no download\n");
dataNew(33,0,0);
return 0; // range already inside
}
// if not enough data, its probably a newly listed stock/asset with limited history
if (start<fileStart)
printf("\nWARNING: historical data for [%s] may not be early enough\n",theAsset);
// set start to last date in file, to upate to current date
start = fileEnd;
}
printf("Downloading data [%s]... Start=%d End=%d\n", theAsset, start, end);
//----------------------------------
// index symbol conversions
//----------------------------------
if (theAsset == "SPX") theAsset = "$SPX";
if (theAsset == "DJI") theAsset = "$DOWI";
if (theAsset == "INX") theAsset = "$INX";
//----------------------------------
// get data
//----------------------------------
if(once(Init)) connectToSierraChart();
int reqbars = (int) (dmy(end) - dmy(start))*ifelse(barperiod==1440,1,1440); // D1 or M1 data only
//printf("SC: items allocated = %d\n",reqbars+10);
T6* myT6=malloc((reqbars+10)*sizeof(T6));
int items = BrokerHistory2 (theAsset, dmy(start), dmy(end), barperiod, -1, myT6);
printf("SC: items received = %d\n",items);
if (!items) {
printf("ERROR: No historical data returned from SierraChart... maybe out of data cache range.\n");
free(myT6);
quit("#quit");
}
FILE *fp;
string tempT6 = strf("History\\temp-%s.t6",theAsset);
fp = fopen(tempT6, "wb");
fwrite(myT6 , sizeof(T6), items, fp );
fclose(fp);
free(myT6);
dataLoad(33,tempT6,7); // load it into 33
dataSort(33); // make sure it's sorted
//---------------------------------
// pre-pend to existing t6
//---------------------------------
if (file_length(t6Out)>0) {
dataLoad(22,t6Out,7);
dataMerge(22,33);
dataSave(22,t6Out);
dataNew(22,0,0);
}
else {
dataSave(33,t6Out);
dataNew(33,0,0);
}
file_delete(tempT6);
return 0;
}
I am here to answer any questions and fix any bugs you may have found. Please let me know.
Thanks, Andrew
Hello Andrew,
I am very interested in using your plugin!
However, I want to make sure it will be suitable for what I am trying to do before spending time on it.
I want to use it for market making on the BitMEX exchange. So it would be placing passive limit orders using POST_ONLY orders (I believe the POST_ONLY flag can be set in the SC plugin).
This also needs to be low-latency. Can Zorro react with your plugin (place orders upon receiving new market data), say within 1ms?
Support at SC told me that their DTC server is suitable for low-latency trading.
My setup is low-latency, since it implements SET_HWND for immediate reactions to incoming data. However, I have not done any latency tests, so I cannot comment on whether or not it is sub-ms.
(Note: This project will remain in beta until I rewrite the backend.)
My setup is low-latency, since it implements SET_HWND for immediate reactions to incoming data. However, I have not done any latency tests, so I cannot comment on whether or not it is sub-ms.
(Note: This project will remain in beta until I rewrite the backend.)
That still sounds very good. Do you know if Zorro runs at that low latency in general (aside from your plugin)?
Also, there is no problem with sending limit orders to the BitMEX exchange? I read something about limit orders earlier in this thread but I could not understand the discussion.
Re: Sierra Chart Plugin
[Re: JamesHH]
#479040 02/07/2019:4102/07/2019:41
Also, there is no problem with sending limit orders to the BitMEX exchange? I read something about limit orders earlier in this thread but I could not understand the discussion.
Not sure what you mean. Limit orders are supported.
If BitMEX has problems, that has nothing to do with my plugin. Remember, this plugin works with Sierra Chart.
When in doubt, test on a paper account and in Sierra Chart's simulation mode.
Also, there is no problem with sending limit orders to the BitMEX exchange? I read something about limit orders earlier in this thread but I could not understand the discussion.
Not sure what you mean. Limit orders are supported.
At the start of the thread, Zheka asked "- does the plug-in support true limit orders?" and then: "1) You mean, by specifying a TakeProfit var in the enterLong, the plug-in will send a real limit order to the book, right?" and you replied "1) The plugin is NFA mode (orders) only, so this depends on how Zorro handles pool trades." I don't understand what NFA mode does, but as long as I can send limit orders all is good.
Quote
When in doubt, test on a paper account and in Sierra Chart's simulation mode.
Yes, I plan to test it. BitMEX also has a testnet that SC can connect to, where you can paper trade with the BitMEX API.
In Zorro, you place "trades". But "trades" are a high-level interface for order placement. When a plugin is "NFA mode", it means the broker only understands orders.
This does not change the fact that limit orders are supported. Just verify that it behaves as you expect.
I attempting to use the plugin in Trade mode to get live prices, but after Zorro connects to the server I am receiving a flood of unknown message type errors:
!1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 !1: Received unknown msg type: 140 [Stop] at 00:16 Logout.. ok
It looks like they added some new market depth messages. I'll need to add some more message handling.
If you don't need market depth, you can probably ignore it until I have a fix.
OK. I think it works.
This is not specific to the plugin, but I have never used Zorro in Trade mode before. It looks like I will only get price updates at the end of each 1 minute bar, with BarPeriod = 1? So I need Zorro-S to get a stream of tick data?
Also, about market depth, eventually I would need it. Are the bid/ask prices real? I mean that Spread is always 0.5, so does that mean it is really 0.5 on the exchange?
The spread you get in Trade mode is real. Whereas the spread you set in your asset list is strictly used for Test and Train mode to emulate a spread.
Quote
It looks like I will only get price updates at the end of each 1 minute bar, with BarPeriod = 1? So I need Zorro-S to get a stream of tick data?
I believe tick() works for both Zorro and Zorro S. But you can only use BarPeriod 1 or greater in free Zorro. So if you're only using run() and BarPeriod is 1, then you only get price updates once per run(), which is once per minute.
I believe tick() works for both Zorro and Zorro S. But you can only use BarPeriod 1 or greater in free Zorro. So if you're only using run() and BarPeriod is 1, then you only get price updates once per run(), which is once per minute.
I didn't know about tick(). It does seem to be working with free Zorro.
My understanding of the manual is that in tick(), priceClose() gives the ask quote. So how does one get the trade price when a trade occurs?
Btw, I assume obtaining market depth with be specific to the Sierra Chart Plugin (since I didn't see any documentation on this in the manual), but I guess you will explain this once the plugin adds that functionality.
Re: Sierra Chart Plugin
[Re: JamesHH]
#479328 03/18/2011:2003/18/2011:20
I assume obtaining market depth with be specific to the Sierra Chart Plugin (since I didn't see any documentation on this in the manual), but I guess you will explain this once the plugin adds that functionality.
Sorry, but so far I am not finding this plugin to be usable. Here are some issues:
1) After starting Zorro in Trade mode, the status remains red for about 2:45 minutes before the script starts doing anything. This makes it very time consuming to debug scripts.
2) The flood of megabytes of error messages makes it that much more difficult to try and see what is going on.
3) At one point I was receiving quote updates in the tick() function. Now there are no updates showing in the log (even though I know the quotes have updated on SC). Also when I try to stop my script zorro keeps running after I select Yes to stop running the script.
I made some changes to my script and then tried to revert them to what seemed to be working before. Is there some error in my script that could be causing the problems?
There appears to be an error/failure under unknown circumstances. I will not be fixing this because 1) Sierra Chart changed the protocol on me, and 2) I planned on overhauling the plugin in the first place. The overhaul is low on my priority list because I'm working on a much bigger project right now.
There appears to be an error/failure under unknown circumstances. I will not be fixing this because 1) Sierra Chart changed the protocol on me, and 2) I planned on overhauling the plugin in the first place. The overhaul is low on my priority list because I'm working on a much bigger project right now.
Fine, but I guess that means Sierra Cart is unusable with Zorro in the meantime.
I do not know of any other plugin implementations of Sierra Chart for Zorro. If you know C++ and sockets, you can always implement your own.
The other issue is that my debugger said that the crash was internally in Zorro.exe (not in the scope of my code), so that makes it a wee bit harder to debug in the first place. Even if the crash is elsewhere, my plugin can still be the culprit. And then if Zorro is the culprit, I might need to file a convoluted bug report. This kind of stuff is very time-consuming.
I do not know of any other plugin implementations of Sierra Chart for Zorro. If you know C++ and sockets, you can always implement your own.
The other issue is that my debugger said that the crash was internally in Zorro.exe (not in the scope of my code), so that makes it a wee bit harder to debug in the first place. Even if the crash is elsewhere, my plugin can still be the culprit. And then if Zorro is the culprit, I might need to file a convoluted bug report. This kind of stuff is very time-consuming.
I see what you mean by time consuming. I'm not sure if you have access to the Zorro source code, but they should give it to you if you don't.
My plan for now is to write a basic bot that connects directly to the Sierra Chart DTC server. I have done socket programming in C++, but I will not attempt to write a Zorro plugin, at least for now.
I am new to both Zorro and your plugin, and just started trying the plugin for simulation trading. My Sierra subscribes to their exchange data and order routing service. Two questions here.
1. Can I use Sierra's special orders with Zorro in trading mode, like Limit Chase or OCO orders?
2. In Zorro's trading mode, it looks Zorro subscribes to the tick data from Sierra, and builds the 1M bar by itself. Because of a little bit latency, the bar's OHLC prices are not exactly aligned with Sierra's historical data on the chart. I compared them by setting PRICETYPE to 2. It's more significant in night session. Is it possible to directly subscribe to Sierra's bar data in trading mode? I understand assetHistory is only for initialization.
1. Can I use Sierra's special orders with Zorro in trading mode, like Limit Chase or OCO orders?
Although these order interfaces are available via the DTC server, they do not jive very well with Zorro's high level trading interface, so it does not make much sense for me to program this into the plugin.
Quote
2. In Zorro's trading mode, it looks Zorro subscribes to the tick data from Sierra, and builds the 1M bar by itself. Because of a little bit latency, the bar's OHLC prices are not exactly aligned with Sierra's historical data on the chart. I compared them by setting PRICETYPE to 2. It's more significant in night session.
It's not latency. The historical timestamps have different meanings in Zorro than in Sierra Chart. Zorro defines a bar by end-of-period, whereas Sierra Chart supplies the timestamp of the very first tick received per bar. The plugin does the translation for you.
Quote
Is it possible to directly subscribe to Sierra's bar data in trading mode? I understand assetHistory is only for initialization.
What Sierra Chart supplies via the DTC server is what you get.
I started to using daily volume in my strategy and your continuous summing of the bar volume is causing a bit of a challenge. I'm wondering if I can convince you to not do that for the follow reasons:
1. It is not consistent with the way Zorro create historical .t6 files from other sources such as YAHOO etc. EOD .t6 files have only daily volume in the volume field.
2. The raw data in the SierraChart Data folder contains only daily volume for EOD data, not continuously summed up.
Whenever I exit out of Zorro, windows gives a Zorro crash modal message. I think you mentioned this was expected. Is this something that the Zorro developers can easily fix, or is this something in your DLL?
It think it may have something to do with the dangling network connection to the SC application?
Is there a function to gracefully disconnect from SC or unload the DLL after I've received the historical data? I only use SC in the beginning of a trade/test session.
Re: Sierra Chart Plugin
[Re: SBGuy]
#480902 07/22/2015:3407/22/2015:34
This is because the plugin was designed to operate as a Broker Plugin and not for users to dynamically reload DLL's for direct API access, so this creates side effects.
I have no plans on fixing this, because my work will go out the window once I revamp the plugin.
I see. So it is something that only you can fix inside the DLL and not something that Zorro developers can do to "clean up" some dangling this or that?
I am proud to announce that the Sierra Chart plugin has been completely overhauled and has been released!
Basically, the plugin no longer depends on Boost. The plugin is both single-threaded and asynchronous (SET_HWND is supported). GET_FUTURES is now supported for certain Sierra Chart services. All dependencies have been included in the Github repo.
Thanks for the overhaul! I look forward to testing it.
As you may recall, I use it strictly for historical data download/preload. How have you change things with regards to using your DLL as a replacement assetHistory() function while trading and real-time data is through another broker plugin?
Re: Sierra Chart Plugin
[Re: SBGuy]
#482854 04/07/2113:3704/07/2113:37
How have you change things with regards to using your DLL as a replacement assetHistory() function while trading and real-time data is through another broker plugin?
Status has changed from "it works" to "it works (and probably faster too)".
I might otherwise add a standalone brokercommand so that you don't have to manually load the DLL.
I am attempting to get some historical data from SierraCharts using the plugin. I have been successful for daily bars just using the zorro assetHistory(). However I am attempting to use SBGuy's assetHistorySC function posted earlier to get intraday historical data for some equities. I have set BarPeriod=1. Function below and some example output. The data bars received is is only going back about 6 months or so. It always seems to get around 50k items from Sierra. I have set Global Settings...Day/Trade Service Settings...Common Settings...Maximum Historical Intraday Days to Download to 1825 (5 years). I have noticed that I actually see data in SierraCharts go back much further, so I believe the data is there in the scid file from Sierra, but I cannot get it all to zorro.
Any thoughts? I believe the right parameters are called in the BrokerHistory2. Could this be another SierraCharts setting required? Any help would be appreciated.
StartDate=0 EndDate=2021 NumYears=3 BarPeriod=1
Cmd=C:\Users\User\Zorro\Zorro.exe -h -stay -run Sierra_GetAsset_BC.c
asset=BRX
Downloading data [BRX]... Start=19991231 End=20210422
#1: Launching thread...
#1: Trying endpoint 127.0.0.1:11099 (TLS 1.2)
1: Connected to SC DTC Protocol server. Service=scdataallservices|SymbolSettings=scdataallservices
1: WARNING: Trading not supported
1: TradeAccounts detected: Sim1
1: Using: Sim1
1: Warning: no balance confirmed for this account!
1: 0 historical orders detected.
1: 0 open orders detected.
1: 0 open positions detected.SC: items allocated = 11207530
BrokerHistory2 (BRX, 19991231, 20210422, 1, -1, myT6)
#2: Launching thread...
#2: Trying endpoint 127.0.0.1:11097 (TLS 1.2)
#2: Logon successful.
2: Data is being downloaded from a remote source. Download will start when this is done.
#2: Joining thread...SC: items received = 50821
t6 = History\temp-BRX.t6
LOADED TEMP
Saving to, C:\Users\User\Zorro\History\Sierra\BRX.t6
Code
int assetHistorySC(string theAsset)
{
if (!Init) return 0;
int barperiod = BarPeriod;
//----------------------------------
// setup start and end dates
//----------------------------------
int M1back = (LookBack*BarPeriod)/(7*60); // days of lback
int DailyLBack = (LookBack+2*UnstablePeriod);
int start = min(ymd(wdate(NOW)-6*365), ymd(dmy(StartDate)-2*ifelse(barperiod<1440,M1back, DailyLBack))); //6 years or more
int end;
string t6Out[100];
if (barperiod<1440) {
sprintf(t6Out,strf("%s%s.t6",History,theAsset));
barperiod = 1;
end = ymd(wdate(NOW)+1); // +1 to get most current M1 bar
}
else {
sprintf(t6Out,"History\\%s.t6",theAsset);
end = ymd(wdate(NOW)-1); // -1 to get up to yesterday
}
//-------------------------------------
// check to see if exiting t6 is in range
//-------------------------------------
if (file_length(t6Out)) {
int records = dataLoad(33,t6Out,7);
int fileStart = ymd(dataVar(33,-1,0));
int fileEnd = ymd(dataVar(33,0,0));
//printf("fileStart=%d fileEnd=%d\n",fileStart, fileEnd);
// if Test or Train, don't download if data in range
if ( (!Live && EndDate<=fileEnd && barperiod==1440)
|| (Live && end<=fileEnd && barperiod==1440)
)
{
printf("\n[%s] historical data up to date... no download\n");
dataNew(33,0,0);
return 0; // range already inside
}
// if not enough data, its probably a newly listed stock/asset with limited history
if (start<fileStart)
printf("\nWARNING: historical data for [%s] may not be early enough\n",theAsset);
// set start to last date in file, to upate to current date
start = fileEnd;
}
printf("Downloading data [%s]... Start=%d End=%d\n", theAsset, start, end);
//----------------------------------
// index symbol conversions
//----------------------------------
if (theAsset == "SPX") theAsset = "$SPX";
if (theAsset == "DJI") theAsset = "$DOWI";
if (theAsset == "INX") theAsset = "$INX";
//----------------------------------
// get data
//----------------------------------
if(once(Init)) connectToSierraChart();
int reqbars = (int) (dmy(end) - dmy(start))*ifelse(barperiod==1440,1,1440); // D1 or M1 data only
printf("SC: items allocated = %d\n",reqbars+10);
T6* myT6=malloc((reqbars+10)*sizeof(T6));
printf("BrokerHistory2 (%s, %d, %d, %i, -1, myT6)\n", theAsset, start, end, barperiod);
int items = BrokerHistory2 (theAsset, dmy(start), dmy(end), barperiod, -1, myT6);
printf("SC: items received = %d\n",items);
if (!items) {
printf("ERROR: No historical data returned from SierraChart... maybe out of data cache range.\n");
free(myT6);
quit("#quit");
}
FILE *fp;
string tempT6 = strf("History\\temp-%s.t6",theAsset);
printf("t6 = %s\n", tempT6);
fp = fopen(tempT6, "wb");
fwrite(myT6 , sizeof(T6), items, fp );
fclose(fp);
free(myT6);
dataLoad(33,tempT6,7); // load it into 33
dataSort(33); // make sure it's sorted
printf("LOADED TEMP\n");
//---------------------------------
// pre-pend to existing t6
//---------------------------------
if (file_length(t6Out)>0) {
printf("Appending to, %s\n", t6Out);
dataLoad(22,t6Out,7);
dataMerge(22,33);
dataSave(22,t6Out);
dataNew(22,0,0);
}
else {
printf("Saving to, %s\n", t6Out);
dataSave(33,t6Out);
dataNew(33,0,0);
}
file_delete(tempT6);
return 0;
}
I had this same 180 day problem back in 2019 and you lifted the limit. Here's what you said. Perhaps forgot to include the IGNORE_MAX_DAYS thing in the new plugin? Would appreciate you putting it back in. It apparently didn't cause any problems since 2019.
========================================================================= I hacked off max_days with a macro IGNORE_MAX_DAYS.
Ah, very good Andrew. Yeah, the old link was just for your reference.
Sorry, jbhunter, don't know what's wrong with your setup. I have 1,000 days max on SC setting and was able to get 1,000 days of M1 data for your BRX example into a .t6 file. I am using the version 1.0.xx of the plugin
My code may have changed since I posted it. For what it's worth, here's the latest code. It's not the best code, but it works for me. Just put BarPeriod as the second argument.
You'll have to debug your problem further on your own.
Code
int assetHistorySC(string theAsset, int theBP)
{
if (!Init) return 0;
int barperiod = theBP;
//----------------------------------
// setup start and end dates
//----------------------------------
int M1back = (LookBack*BarPeriod)/(7*60); // days of lback
int DailyLBack = (LookBack+2*UnstablePeriod);
int start = min(ymd(wdate(NOW)-6*365), ymd(dmy(StartDate)-2*ifelse(barperiod<1440,M1back, DailyLBack))); //6 years or more
int end;
if (!EndDate)
if (hour(NOW)>=21) EndDate = ymd(wdate(NOW));
else EndDate = ymd(wdate(NOW)-1);
string t6Out[100];
if (barperiod<1440) {
sprintf(t6Out,strf("History\\%s%s",theAsset,History));
barperiod = 1;
end = ymd(wdate(NOW)+1); // +1 to get most current M1 bar
}
else {
sprintf(t6Out,"History\\%s.t6",theAsset);
if (hour(NOW)>=21) end = ymd(wdate(NOW));
else end = ymd(wdate(NOW)-1); // -1 to get up to yesterday
}
//-------------------------------------
// check to see if exiting t6 is in range
//-------------------------------------
if (file_length(t6Out)) {
int records = dataLoad(33,t6Out,7);
int fileStart = ymd(dataVar(33,-1,0));
int fileEnd = ymd(dataVar(33,0,0));
//printf("fileStart=%d fileEnd=%d\n",fileStart, fileEnd);
// if Test or Train, don't download if data in range
if ( (!Live && EndDate<=fileEnd && barperiod==1440)
|| (Live && end<=fileEnd && barperiod==1440)
)
{
if (Live || DEBUG) printf("\n[%s] historical data up to date... no download\n");
dataNew(33,0,0);
return 0; // range already inside
}
// if not enough data, its probably a newly listed stock/asset with limited history
if (start<fileStart)
if (Live || DEBUG) printf("\nWARNING: historical data for [%s] may not be early enough\n",theAsset);
// set start to last date in file, to upate to current date
start = fileEnd;
}
if (start==end) return 0;
if (Live || DEBUG) printf("Downloading data [%s]... Start=%d End=%d\n", theAsset, start, end);
//----------------------------------
// index symbol conversions
//----------------------------------
if (theAsset == "SPX") theAsset = "$SPX";
if (theAsset == "DJI") theAsset = "$DOWI";
if (theAsset == "INX") theAsset = "$INX";
//----------------------------------
// get data
//----------------------------------
if(once(Init)) connectToSierraChart();
int reqbars = (int) (dmy(end) - dmy(start))*ifelse(barperiod==1440,1,1440); // D1 or M1 data only
//printf("SC: items allocated = %d\n",reqbars+10);
T6* myT6=malloc((reqbars+10)*sizeof(T6));
int items = 0;
int i;
for (i=0;i<=2;i++)
{
items = BrokerHistory2 (theAsset, dmy(start), dmy(end), barperiod, -1, myT6);
if (Live || DEBUG) printf("SC: items received = %d\n",items);
if (!items) {
if (Live || DEBUG) printf("ERROR: No historical data returned from SierraChart... maybe out of data cache range.\n");
connectToSierraChart();
wait(1000);
}
else {
break;
}
}
FILE *fp;
string tempT6 = strf("History\\temp-%s.t6",theAsset);
fp = fopen(tempT6, "wb");
fwrite(myT6 , sizeof(T6), items, fp );
fclose(fp);
free(myT6);
dataLoad(33,tempT6,7); // load it into 33
dataSort(33); // make sure it's sorted
//---------------------------------
// pre-pend to existing t6
//---------------------------------
if (file_length(t6Out)>0) {
dataLoad(22,t6Out,7);
dataMerge(22,33);
dataSave(22,t6Out);
dataNew(22,0,0);
}
else {
dataSave(33,t6Out);
dataNew(33,0,0);
}
file_delete(tempT6);
return 0;
}
When trying the latest plugin version 1.0.0.3, I had to change the ports to get it to login. After fixing this I am getting these errors shown on the Sierra side...
HD Server | Thread:7228 (152) | Encryption stream error encountered when processing received data. Failed to read incoming decrypted data from the incoming binary I/O stream. error:1408F10B:SSL routines:ssl3_get_record:wrong version number | 2021-04-21 13:41:15.703
Oh geez, I had the "Historical Data Port" and "TLS Historical Data Ports" swapped. I thought I had tried that already. It is working. I am also now getting multiple years with assetHistory(ticker, 1)