Gamestudio Links
Zorro Links
Newest Posts
Historical ticks for Lookback backfill
by Zheka. 07/08/20 09:10
Trade Mode without a broker
by jj02520024. 07/08/20 01:20
How to handle algo name in Simulate.c
by happysun. 07/07/20 08:56
Erasing a datapoint in a plot array
by jcl. 07/06/20 09:51
typo
by jcl. 07/06/20 09:44
Video Panel System
by Emre. 07/06/20 09:39
Market Internals Data
by Spirit. 07/05/20 07:50
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
10 registered members (AndrewAMD, Zheka, Mio, kvm, jenGs, 3run, alibaba, Ayumi, 2 invisible), 368 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
TraderKevin, deus777, carolthesecond, Roger399, vrindger
18474 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 12 of 15 1 2 10 11 12 13 14 15
Re: Sierra Chart Plugin [Re: AndrewAMD] #478678
11/26/19 00:12
11/26/19 00:12
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
Here it is. Can you give it a spin?

Attached Files
SierraChart_0_9_3_0.zip (18 downloads)
Re: Sierra Chart Plugin [Re: AndrewAMD] #478679
11/26/19 01:21
11/26/19 01:21
Joined: May 2018
Posts: 94
S
SBGuy Offline
Junior Member
SBGuy  Offline
Junior Member
S

Joined: May 2018
Posts: 94
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.

Re: Sierra Chart Plugin [Re: AndrewAMD] #478680
11/26/19 01:55
11/26/19 01:55
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
DTC is already UTC, so there is no adjustment.

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.

Re: Sierra Chart Plugin [Re: AndrewAMD] #478686
11/26/19 14:01
11/26/19 14:01
Joined: May 2018
Posts: 94
S
SBGuy Offline
Junior Member
SBGuy  Offline
Junior Member
S

Joined: May 2018
Posts: 94
Good to know it's already in UTC time.

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.

Re: Sierra Chart Plugin [Re: AndrewAMD] #478688
11/26/19 14:27
11/26/19 14:27
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
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?

Re: Sierra Chart Plugin [Re: AndrewAMD] #478689
11/26/19 14:32
11/26/19 14:32
Joined: May 2018
Posts: 94
S
SBGuy Offline
Junior Member
SBGuy  Offline
Junior Member
S

Joined: May 2018
Posts: 94
No. I'm using my own data from an ActiveTick source.

It's probably because they are time-stamping theirs at the beginning of the M1 bar.

You're probably right about my question being asked incorrectly.

Re: Sierra Chart Plugin [Re: AndrewAMD] #478726
12/05/19 01:31
12/05/19 01:31
Joined: Dec 2019
Posts: 1
W
wzschultz Offline
Guest
wzschultz  Offline
Guest
W

Joined: Dec 2019
Posts: 1
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/19 01:32. Reason: grammar
Re: Sierra Chart Plugin [Re: AndrewAMD] #478796
12/20/19 19:04
12/20/19 19:04
Joined: May 2018
Posts: 94
S
SBGuy Offline
Junior Member
SBGuy  Offline
Junior Member
S

Joined: May 2018
Posts: 94
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;
}



Re: Sierra Chart Plugin [Re: AndrewAMD] #479034
02/07/20 04:06
02/07/20 04:06
Joined: Oct 2018
Posts: 67
J
JamesHH Offline
Junior Member
JamesHH  Offline
Junior Member
J

Joined: Oct 2018
Posts: 67
Originally Posted by AndrewAMD
I am proud to announce that the Sierra Chart Plugin is now in BETA, and so I am in need of some testers.

Documentation and source code is here:
https://github.com/AndrewAMD/SierraChartZorroPlugin

The latest DLL can be found here:
https://github.com/AndrewAMD/SierraChartZorroPlugin/tree/master/releases

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.

Thanks

Re: Sierra Chart Plugin [Re: AndrewAMD] #479036
02/07/20 15:12
02/07/20 15:12
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
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.)

Page 12 of 15 1 2 10 11 12 13 14 15

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1