ACSIL: working with time and sales data - Sierra Chart Programming | futures io social day trading
futures io futures trading


ACSIL: working with time and sales data
Updated: Views / Replies:8,250 / 44
Created: by yonatan Attachments:17

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 90,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

Reply
 17  
 
Thread Tools Search this Thread
 

ACSIL: working with time and sales data

  #31 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Conclusion

1. To obtain T&S information in real-time from ACSIL: GetTimeAndSales()

2. To access to the T&S information within a bar historically from ACSIL:

- GetTimeAndSales() is not adapted

- There are some solutions to precisely identify to the tick all the individual ticks belonging to a given bar. For instance, I have proposed above a code which "synchronizes" the main chart and a secondary 1-tick chart based on the progress of volume. But these solutions are rather heavy and complicated.

- "sc.GetNearestMatchForDateTimeIndex" allows identifying the ticks of a secondary 1-tick chart belonging to a given bar, but there are some discrepancies due to the "timestamp effect". However, the 2 examples above show that the correspondence is not too bad.

- Overlays could also be used. This solution has not been tested, since similar to the previous (with respect to timestamp effect) and a little more complicated.

3. I am absolutely impressed by the possibilities of Sierra Chart.

Nicolas

Reply With Quote
The following user says Thank You to Nicolas11 for this post:
 
  #32 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

The next 4 messages will be related to @yonatan's original question: use in real-time of SC's Time & Sales information obtained by sc.GetTimeAndSales()


Last edited by Nicolas11; August 13th, 2012 at 03:52 PM.
Reply With Quote
 
  #33 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received


Tip: how to know the DateTime of a trade belonging to the T&S?

This is not straight-forward.
An example is given in studies.cpp

Let's suppose that TSArray contains the T&S:
 
Code
SCTimeAndSalesArray TSArray;
sc.GetTimeAndSales(TSArray);
Let's suppose that TSIndex is the index of the trade we are interested in.

The DateTime TradeDateTime of this trade could be obtained by:
 
Code
SCDateTime TradeDateTime = COMBINE_DATE_TIME(TSArray[TSIndex].Date, HMS_TIME(TSArray[TSIndex].Hour, TSArray[TSIndex].Minute, TSArray[TSIndex].Second));
TradeDateTime += sc.TimeScaleAdjustment;
Nicolas

Reply With Quote
 
  #34 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

In the next 2 messages, we will give 2 examples of use in real-time of SC's Time & Sales obtained by sc.GetTimeAndSales():
  • emulation of the volume of the bar ...from the trades provided by the T&S
  • emulation of the pullback column ...from the trades provided by the T&S

Nicolas

Reply With Quote
 
  #35 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Example A: emulation of the volume of the bar by using the real-time information in SC's Time & Sales (obtained by sc.GetTimeAndSales())

The tricky part is to identify the first trade of the bar within the T&S.
I have simply checked the date/time of the T&S trades versus the date/time of the beginning of the bar.
It entails that the emulation is exact for time charts (for instance: 2-min chart), but there could be a discrepancy for other kinds of charts (timestamp effect). This discrepancy could not be greater than 1s.

The code only works in real-time.

Nicolas

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


 
Code
// Nicolas11 @ futures.io (formerly BMT)
// v1
// August 13th, 2012
SCSFExport scsf_Emulated_Volume_WithGetTimeAndSales(SCStudyGraphRef sc)
{

	// Reference to output:
	SCSubgraphRef EmulatedVolume = sc.Subgraph[0];

	if (sc.SetDefaults) {
		
		sc.GraphName = "Emulated Volume with GetTimeAndSales";
		sc.StudyDescription = "Emulated Volume with GetTimeAndSales";

		// Output:
		EmulatedVolume.Name = "Emulated Volume with GetTimeAndSales";
		EmulatedVolume.DrawStyle = DRAWSTYLE_BAR;
		EmulatedVolume.PrimaryColor = RGB(0, 0, 255); // blue
		EmulatedVolume.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_VALUES_SCALE | LL_VALUE_ALIGN_CENTER;

		sc.FreeDLL = 1;
		sc.AutoLoop = 1;
		return;
	}

	SCTimeAndSalesArray TSArray;
	sc.GetTimeAndSales(TSArray);
	if (TSArray.GetArraySize() == 0) return;

	EmulatedVolume[sc.Index] = 0.0f;

	// For each recent trade...
	for ( int TSIndex = TSArray.GetArraySize() - 1 ; TSIndex >= 0 ; TSIndex-- ) { 

		// What is the date-time of the trade? (inspiration: studies.cpp)
		SCDateTime TradeDateTime = COMBINE_DATE_TIME(TSArray[TSIndex].Date, HMS_TIME(TSArray[TSIndex].Hour, TSArray[TSIndex].Minute, TSArray[TSIndex].Second));
		TradeDateTime += sc.TimeScaleAdjustment; 

		// If the trade is prior the start of the current bar, stop the iteration:
		if ( TradeDateTime < sc.BaseDateTimeIn[sc.Index] ) break;

		// Take into account the volume of the trade:
		if ( TSArray[TSIndex].Level == SC_TS_BID || TSArray[TSIndex].Level == SC_TS_ASK ) { // real trade, not an update of bid-ask
			EmulatedVolume[sc.Index] += TSArray[TSIndex].Volume;
		}
	}
}

Reply With Quote
The following 2 users say Thank You to Nicolas11 for this post:
 
  #36 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Example B: emulation of the pullback column by using the real-time information in SC's Time & Sales (obtained by sc.GetTimeAndSales())

We are not going to emulate the whole pullback column, but only the total delta of the pullback. The same logic could be used to emulate any part of the pullback column.

As for the previous example, we have to identify the first trade of the bar within the T&S.
I have simply checked the date/time of the T&S trades versus the date/time of the beginning of the bar.
It entails that the emulation is exact for time charts (for instance: 2-min chart), but there could be a discrepancy for other kinds of charts (timestamp effect). This discrepancy could not be greater than 1s.

The code only works in real-time.

Nicolas

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


 
Code
// Nicolas11 @ futures.io (formerly BMT)
// v1
// August 13th, 2012
SCSFExport scsf_Emulated_Pullback_Delta(SCStudyGraphRef sc)
{

	// Reference to output:
	SCSubgraphRef EmulatedDeltaFromHigh = sc.Subgraph[0];
	SCSubgraphRef EmulatedDeltaFromLow = sc.Subgraph[1];

	if (sc.SetDefaults) {
		
		sc.GraphName = "Pullback Delta (emulated)";
		sc.StudyDescription = "Pullback Delta (emulated)";

		// Output:
		EmulatedDeltaFromHigh.Name = "Delta from High (emulated)";
		EmulatedDeltaFromHigh.DrawStyle = DRAWSTYLE_DASH;
		EmulatedDeltaFromHigh.PrimaryColor = RGB(255, 0, 0); // red
		EmulatedDeltaFromHigh.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_VALUES_SCALE | LL_VALUE_ALIGN_CENTER;
		EmulatedDeltaFromLow.Name = "Delta from Low (emulated)";
		EmulatedDeltaFromLow.DrawStyle = DRAWSTYLE_DASH;
		EmulatedDeltaFromLow.PrimaryColor = RGB(0, 0, 255); // blue
		EmulatedDeltaFromLow.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_VALUES_SCALE | LL_VALUE_ALIGN_CENTER;

		sc.FreeDLL = 1;
		sc.AutoLoop = 1;
		return;
	}

	SCTimeAndSalesArray TSArray;
	sc.GetTimeAndSales(TSArray);
	if (TSArray.GetArraySize() == 0) {
		return; 
	}

	// Let's identify the first trade of the bar:
	int TSIndex = TSArray.GetArraySize()-1;
	while ( TSIndex >= 0 ) {
		// What is the date-time of the trade? (inspiration: studies.cpp)
		SCDateTime TradeDateTime = COMBINE_DATE_TIME(TSArray[TSIndex].Date, HMS_TIME(TSArray[TSIndex].Hour, TSArray[TSIndex].Minute, TSArray[TSIndex].Second));
		TradeDateTime += sc.TimeScaleAdjustment; 
		// If the trade is prior the start of the current bar, stop the iteration:
		if ( TradeDateTime < sc.BaseDateTimeIn[sc.Index] ) {
			TSIndex++;
			break;
		}
		TSIndex--;
	}
	int IndexOfFirstTradeOfTheBar = TSIndex;

	// Let's walk through the T&S from the first trade of the bar to the most recent trade
	// Each time we find a trade after the H/L of the bar (inclusive), let's take it into account for pullback calculations
	bool HighOfBarAlreadyReached = false;
	bool LowOfBarAlreadyReached = false;
	EmulatedDeltaFromHigh[sc.Index] = 0.0f;
	EmulatedDeltaFromLow[sc.Index] = 0.0f;
	for ( int TSIndex = IndexOfFirstTradeOfTheBar; TSIndex < TSArray.GetArraySize(); TSIndex++ ) {
		
		// if the trade is real (not an update of bid/ask) and is at the H or L of the bar...
		// let's change the flags
		if ( TSArray[TSIndex].Level == SC_TS_BID || TSArray[TSIndex].Level == SC_TS_ASK ) {
			if ( (!HighOfBarAlreadyReached) && sc.FormattedEvaluate(TSArray[TSIndex].Price, sc.BaseGraphValueFormat, EQUAL_OPERATOR, sc.High[sc.Index], sc.BaseGraphValueFormat) ) {
				HighOfBarAlreadyReached = true;
			}
			if ( (!LowOfBarAlreadyReached) && sc.FormattedEvaluate(TSArray[TSIndex].Price, sc.BaseGraphValueFormat, EQUAL_OPERATOR, sc.Low[sc.Index], sc.BaseGraphValueFormat) ) {
				LowOfBarAlreadyReached = true;
			}
		}

		// if the trade is real (not an update of bid/ask) AND if we are after the High of the bar (inclusive)...
		// let's take into account its delta for the pullback:
		if ( ( TSArray[TSIndex].Level == SC_TS_BID || TSArray[TSIndex].Level == SC_TS_ASK ) && HighOfBarAlreadyReached ) {
			if ( TSArray[TSIndex].Level == SC_TS_ASK ) {
				EmulatedDeltaFromHigh[sc.Index] += TSArray[TSIndex].Volume;
			} else {
				EmulatedDeltaFromHigh[sc.Index] -= TSArray[TSIndex].Volume;
			}
		}

		// if the trade is real (not an update of bid/ask) AND if we are after the Low of the bar (inclusive)...
		// let's take into account its delta for the pullback:
		if ( ( TSArray[TSIndex].Level == SC_TS_BID || TSArray[TSIndex].Level == SC_TS_ASK ) && LowOfBarAlreadyReached ) {
			if ( TSArray[TSIndex].Level == SC_TS_ASK ) {
				EmulatedDeltaFromLow[sc.Index] += TSArray[TSIndex].Volume;
			} else {
				EmulatedDeltaFromLow[sc.Index] -= TSArray[TSIndex].Volume;
			}
		}
	}
}

Reply With Quote
The following 2 users say Thank You to Nicolas11 for this post:
 
  #37 (permalink)
Elite Member
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received

@Nicolas11, this is more than perfect.

Reply With Quote
The following user says Thank You to yonatan for this post:
 
  #38 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

One remark...

sc.GetTimeAndSales() gives access to the T&S, but also to the ever-changing first bid and ask levels of the DOM between actual trades.

I mean...

Of course, sc.GetTimeAndSales() gives access to the content of the T&S window, with all successive actual trades, their size, and their status (bid or ask).

But sc.GetTimeAndSales() also gives access to the changing values of best ask/best bid (1st bid and ask levels of the DOM) between the actual trades.

To have confirmation of it, you can plot built-in study "Times and Sales BidSize" (based on sc.GetTimeAndSales) and a 1-tick chart.
You will see that the value of this study changes even if no trade takes places (no new tick).
You can compare the value of this study with the DOM of your broker (no link with SC).
They are the same.

(So, when you use sc.GetTimeAndSales, it is important to distinguish between (i) actual trades and (ii) actualization of the DOM without trade. I have shown a way to do it in my above codes.)

Nicolas

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Last edited by Nicolas11; August 16th, 2012 at 11:43 AM.
Reply With Quote
The following 3 users say Thank You to Nicolas11 for this post:
 
  #39 (permalink)
Trading Apprentice
Wrocław/POLSka
 
Futures Experience: Beginner
Platform: sierra chart
Favorite Futures: EUR/usd
 
Posts: 3 since Jan 2013
Thanks: 0 given, 0 received

Hi Nicolas11
I wanted to Time and Sales Time studies. Add Ask Bid/Size Filter input settings. Available is only Volume Filter. Very need this to study spreadsheet.

Reply With Quote
 
  #40 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received


Hi @mkruss ,

If no mistake, I have released the source code of all my works. Feel free to adapt it to your own needs.

Nicolas

Reply With Quote

Reply



futures io > > > > > ACSIL: working with time and sales data

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Time and Sales - Level I - Level II - tick data trendisyourfriend Traders Hideout 4 August 28th, 2014 01:14 AM
ACSIL: How do I get the time value of a Vertical line that I have drawn on the chart yonatan Sierra Chart Programming 7 June 25th, 2012 08:20 AM
Austerity Isn't Working; It's Time for a Plan B Quick Summary News and Current Events 0 June 6th, 2011 07:40 AM
Time and Sales help traderTX The Elite Circle 3 May 3rd, 2011 11:14 AM
Is it possible to get "historical" Time and Sales data? adaseb Reviews of Brokers and Data Feeds 2 September 8th, 2010 12:18 PM


All times are GMT -4. The time now is 02:32 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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
Page generated 2017-12-17 in 0.13 seconds with 20 queries on phoenix via your IP 54.82.56.95