Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Time and sales coding in ACSIL
Updated February 21, 2021
Top Posters
looks_one
Trembling Hand
with 34 posts (15 thanks)
looks_two
liboro
with 28 posts (2 thanks)
looks_3
bobwest
with 2 posts (1 thanks)
looks_4
Big Mike
with 1 posts (1 thanks)
Best Posters
looks_one
Big Mike
with 1 thanks per post
looks_two
bobwest
with 0.5 thanks per post
looks_3
Trembling Hand
with 0.4 thanks per post
looks_4
liboro
with 0.1 thanks per post
trending_up
11,203 views
thumb_up
19 thanks given
group
5 followers
forum
64 posts
attach_file
11 attachments
Time and sales coding in ACSIL
February 12th, 2021, 07:37 AM
Prague
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2
Ok, thank you. I will be happy if you will let me know.
Trembling Hand
Yes I think it's very possible but I'm away from my computer til tomorrow I'll have another look then.
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
February 12th, 2021, 07:11 PM
Melbourne, Land of Oz
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360
So here is a Study that will save the time and sales data to a txt file to C:\SierraChart \Data (modified from something on SC forum).
You can see some of the available data types commented out in the main loop.
Code
SCSFExport scsf_Save_TimeNSales(SCStudyGraphRef sc) {
SCInputRef OutputFile = sc.Input[0];
if (sc.SetDefaults) {
// https://www.sierrachart.com/SupportBoard.php?ThreadID=36979
sc.GraphName = "Save_TimeNSales";
sc.StudyDescription = "Save Time and sales to file";
sc.GraphRegion = 0;
//sc.AutoLoop=true;
sc.FreeDLL = 1;
OutputFile.Name = "The storage link";
SCString OutputFileDefaultName;
OutputFileDefaultName.Format("C:\\SierraChart\\Data\\1_%s.txt", sc.Symbol.GetSubString(2, 0).GetChars());
OutputFile.SetString(OutputFileDefaultName);
}
std::ofstream file(OutputFile.GetString(), std::ios_base::app);
if (!file) {
SCString Buffer;
Buffer.Format("Unable to open file %s", OutputFile.GetString());
sc.AddMessageToLog(Buffer, 1);
//return;
}
if (sc.Index == sc.ArraySize - 1)
{
__int64& LastProcessedSequence = sc.GetPersistentInt64(1);
c_SCTimeAndSalesArray TimeSales;
sc.GetTimeAndSales(TimeSales);
if (TimeSales.Size() == 0)
return;
if (LastProcessedSequence != 0)
{
for (int TSIndex = 0; TSIndex < TimeSales.Size(); ++TSIndex)
{
if (TimeSales[TSIndex].Sequence < LastProcessedSequence)
continue;
if (TimeSales[TSIndex].Type == SC_TS_BID || TimeSales[TSIndex].Type == SC_TS_ASK)
{
//int AskVol = TimeSales[TSIndex].AskSize;
//int TotalAsks = TimeSales[TSIndex].TotalAskDepth;
//int BidVol = TimeSales[TSIndex].BidSize;
//int TotalBids = TimeSales[TSIndex].TotalBidDepth;
float Price = TimeSales[TSIndex].Price;
int Vol = TimeSales[TSIndex].Volume;
int TradeType = TimeSales[TSIndex].Type; // at bid or ask
int ValueFormat = sc.BaseGraphValueFormat;
SCString formatString = " %i/%02i/%02i %02i:%02i:%02i: %03i , Index: %i, Price: %0.4f, Vol: %i BidAsk: %i";
SCDateTime TradeDateTime = TimeSales[TSIndex].DateTime;
TradeDateTime += sc.TimeScaleAdjustment;
int Year, Month, Day, Hour, Minute, Second, MilliSecond;
TradeDateTime.GetDateTimeYMDHMS_MS(Year, Month, Day, Hour, Minute, Second, MilliSecond);
SCString BarDataString;
BarDataString.Format(formatString, Year, Month, Day, Hour, Minute, Second, MilliSecond, TSIndex, Price, Vol, TradeType);
file << BarDataString << std::endl;
}
}
}
LastProcessedSequence = TimeSales[TimeSales.Size() - 1].Sequence;
}
}
Of course this only works with a live market connection.
February 12th, 2021, 07:16 PM
Melbourne, Land of Oz
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360
I probably should of asked before I took the step but do you want this to work on historical data then that is a totally different method!
From SC Docs about sc.GetTimeAndSales()
See Docs
Quoting
Alternative Way For Obtaining
Time and Sales Data
Open a chart that is set to 1
Number of Trades Per Bar for the symbol you want Time and Sales for.
Select Global Settings >> Data/Trade Service Settings and make sure the Intraday Data Storage Time Unit is set to 1 Tick.
Use the sc.GetChartArray and the sc.GetChartDateTimeArray functions to access the price, volume and DateTime arrays. Every element in these arrays is 1 trade. This may actually be a preferred way of accessing trade by trade data since there will be an abundant amount of history available.
February 13th, 2021, 04:16 AM
Prague
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2
Thank you for the codes and other help.
I understand the basics of the TS, but the crucial thing is how to work with the TS data within price leves in the bars - how these arrays would be allocated or how these arrays should look like (subgraphs arrays?)?
I know that SC has Large Volume Trade Indicator, but there is no source code available and I want to use it in my own way. That is the reason why I am trying to solve this.
Trembling Hand
February 13th, 2021, 06:08 AM
Melbourne, Land of Oz
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360
What? I'm not sure what else you would need. If you are not able to use the above code samples then I guess you actually need to explain exactly what you are trying to do and maybe someone can do it for you. But every thing you have said so far is actually very short of what it seems like you really want.
February 13th, 2021, 06:17 AM
Prague
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2
PRICE 69.60 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.61 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.62 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.63 AV (from TS) = XY, BV (from TS) = XY
Is it more clear now?
Put AV and BV to the relevant prices in the current bar.
Trembling Hand
What? I'm not sure what else you would need. If you are not able to use the above code samples then I guess you actually need to explain exactly what you are trying to do and maybe someone can do it for you. But every thing you have said so far is actually very short of what it seems like you really want.
February 13th, 2021, 06:27 AM
Melbourne, Land of Oz
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360
liboro
PRICE 69.60 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.61 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.62 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.63 AV (from TS) = XY, BV (from TS) = XY
Is it more clear now?
Put AV and BV to the relevant prices in the current bar.
That's what the first study I wrote did in post #6!
February 13th, 2021, 06:31 AM
Prague
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2
I do understand the code in post #6, but as I mentioned, these data are from VAP function,
this is not the same as data in Time Sales data structure.
I believe there is no way how to use VAP for TS data.
Maybe I am wrong.
Trembling Hand
That's what the first study I wrote did in post #6!
February 13th, 2021, 06:43 AM
Melbourne, Land of Oz
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360
liboro
I do understand the code in post #6, but as I mentioned, these data are from VAP function,
this is not the same as data in Time Sales data structure.
I believe there is no way how to use VAP for TS data.
Maybe I am wrong.
I think you have a fundamental misunderstanding of what is going on here.
TS data is not a different data set from "other" data.
Could you explain why you think it is? Where does it come from?
Last Updated on February 21, 2021