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;
}