Footprint chart with history

Questions about MultiCharts and user contributed studies.
SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Footprint chart with history

Postby SP » 25 May 2012

/*********
Updated code in post #37



*********/


I created a indicator that plots the Footprint for the lastcalcdate based on a 1 Tick chart for for best accuracy and the complete history for the day by simulating a higher timeframe.

It works ok so far, but i need to plot the last "live" footprints till the condition
"If Barcounter = SynthTimeFrame " is true.
If i use the same logic for plotting as after "If Barcounter = SynthTimeFrame " I do not get either all the rows updated or deleted the next higher timeframe bar.

Maybe some coder here or the MC has a solution?

Code: Select all



inputs :
MaxExpectedRangeInTicks ( 300 ),
SynthTimeFrame ( 2000 ),
// 0 - Bid x Ask
// 1 - Delta (Bid-Ask)
// 2 - TotalVolume (Bid+Ask)
PlotDeltaMode ( 0 ),
TxTSize ( 8 ),
Width ( 4 ),
TxTFont ( "Consolas"),
Plot.Border ( true ),
Plot.Candle ( true ),
Show.SubText ( true ),
Show.UpTminusDnT ( true ),
Show.UpT ( true ),
Show.DnT ( true ),
Show.UpTplusDnT ( true );

vars:
BarHigh ( 0 ),
BarLow ( 0 ),
FootPrintPrice ( 0 ),
TodayOpenPrice ( 0 ),
UpDnTick ( 0 ),
BarCounter ( 0 ),
TickSize ( 0 ),
ResetCounter ( 0 ),
OpenValue ( 0 ),
TextString (""),
NumBarsText (0),
FootPrintText ( 0 ),
TotalBid ( 0 ),
TotalAsk ( 0 ),
FirstCandle ( 0 ),
BidAskArraySz ( 2*MaxExpectedRangeInTicks);

//dynamic numerical arrays
Array: Bid.Array[](0),Ask.Array[](0) ;
Once begin
if bartype_ex >1 or barinterval >1 then raiseruntimeerror (" For 1 Tick chart resolution only !! ");
TickSize = (minmove/PriceScale);
Array_SetMaxIndex( Bid.Array, BidAskArraySz );
Array_SetMaxIndex( Ask.Array, BidAskArraySz );
end;

if d = LastCalcDate then
begin

//Reset the values at the begin of the day
if d > d[1] then
begin

BarCounter = 0;
BarHigh = 0;
BarLow = 999999;
TodayOpenPrice = Close;
FootPrintPrice = 0;
TotalBid = 0;
TotalAsk = 0;
FirstCandle = 1;
for ResetCounter=0 to BidAskArraySz
begin
Bid.Array [ResetCounter] = 0;
Ask.Array [ResetCounter] = 0;
end;
end;

BarCounter = BarCounter +1 ;
FootPrintPrice = (BidAskArraySz/2 )+ (Close - TodayOpenPrice) / TickSize;
if FootPrintPrice >= BarHigh then BarHigh = FootPrintPrice ;
if FootPrintPrice <= BarLow then BarLow = FootPrintPrice ;
//We move up
if close > close[1] then
begin
UpDnTick = 2; //Set the state to 2
Ask.Array[FootPrintPrice] = Ask.Array[FootPrintPrice] + Ticks;
end;

//We move down
if close < close[1] then
begin
UpDnTick =-2; //Set the state to -2
Bid.Array[FootPrintPrice] = Bid.Array[FootPrintPrice]+ Ticks;
end;

//Same close as the bar before
if close = close[1] then
begin
// last movement before was an Uptick
if UpDnTick = 2 then
begin
Ask.Array[FootPrintPrice] = Ask.Array[FootPrintPrice] + Ticks;
end;
// last movement before was an Dntick
if UpDnTick =-2 then
begin
Bid.Array[FootPrintPrice] = Bid.Array[FootPrintPrice]+ Ticks;
end;
end;




If Barcounter = SynthTimeFrame then
begin

For FootPrintPrice = BarLow to BarHigh
begin

if Bid.Array[FootPrintPrice] >0 or Ask.Array[FootPrintPrice] >0 then
begin
//TextString = NumToStr (Bid.Array[FootPrintPrice],0) +" x " + NumToStr(Ask.Array[FootPrintPrice],0)+" ";
if PlotDeltaMode <=0 then
TextString = " "+_SpacifyString(NumToStr(Bid.Array[FootPrintPrice], 0), Width, -1) + "x" + _SpacifyString(NumToStr(Ask.Array[FootPrintPrice], 0), Width, 1)+" ";

if PlotDeltaMode =1 then
TextString = _SpacifyString(NumToStr(Ask.Array[FootPrintPrice]-Bid.Array[FootPrintPrice], 0), Width+2, 1)+" ";

if PlotDeltaMode >=2 then
TextString = _SpacifyString(NumToStr(Ask.Array[FootPrintPrice]+Bid.Array[FootPrintPrice], 0), Width+3, 1)+" ";

FootPrintText = Text_New_s(Date, Time_s, 0, " ");
Text_SetString (FootPrintText, TextString);
Text_SetLocation_s(FootPrintText, Date, Time_s, (FootPrintPrice -(BidAskArraySz/2 ))*TickSize + TodayOpenPrice );
Text_SetStyle(FootPrintText, 1, 2);

if Plot.Border then
begin

if Bid.Array[FootPrintPrice] >Ask.Array[FootPrintPrice] then text_SetBGColor(FootPrintText, red) else
if Bid.Array[FootPrintPrice] <Ask.Array[FootPrintPrice] then text_SetBGColor(FootPrintText, green) else
text_SetBGColor(FootPrintText, white);
Text_SetBorder(FootPrintPrice, True);
text_SetColor(FootPrintText, black);
end else
begin
if Bid.Array[FootPrintPrice] >Ask.Array[FootPrintPrice] then text_SetColor(FootPrintText, red) else
if Bid.Array[FootPrintPrice] <Ask.Array[FootPrintPrice] then text_SetColor(FootPrintText, green) else
text_SetColor(FootPrintText, white);
end;
text_setsize (FootPrintText,TxTSize);
text_setfontname (FootPrintText,TxTFont);

end;
TotalBid = TotalBid + Bid.Array[FootPrintPrice];
TotalAsk = TotalAsk + Ask.Array[FootPrintPrice];
end;

if Plot.Candle then
begin
// To see the candle plot them [-SynthTimeFrame/10] to the right
{plot21 [-SynthTimeFrame/10](lowest(low,SynthTimeFrame ),"CL");
plot22 [-SynthTimeFrame/10](highest(high,SynthTimeFrame ),"CH");
plot23 [-SynthTimeFrame/10](Close,"CC");
Plot24 [-SynthTimeFrame/10](iff ( firstCandle =1 ,TodayOpenPrice ,OpenValue[1]),"CO") ;}
plot21 (lowest(low,SynthTimeFrame ),"CL");
plot22 (highest(high,SynthTimeFrame ),"CH");
plot23 (Close,"CC");
Plot24 (iff ( firstCandle =1 ,TodayOpenPrice ,OpenValue[1]),"CO") ;
if Plot23 > Plot24 then setplotcolor (23,cyan) else
if Plot23 < Plot24 then setplotcolor (23,magenta) else
setplotcolor (23,yellow);


end;

if Show.SubText then
begin
Plot10 (lowest(low,SynthTimeFrame )-5*ticksize, "Dummy");//set to invisible

NumBarsText = text_new_s (DATE, Time_S, lowest(low,SynthTimeFrame )-ticksize,"" );

Text_SetString (NumBarsText,
ifftext (Show.UpTminusDnT," Del: "+ NumToStr ( TotalAsk- TotalBid , 0) +newline,"")+
ifftext (Show.UpT, " Ask: "+NumToStr ( TotalAsk, 0) +newline,"")+
ifftext (Show.DnT, " Bid: "+NumToStr ( TotalBid , 0) +newline,"") +
ifftext (Show.UpTplusDnT, " Vol: "+NumToStr ( (TotalAsk+TotalBid ), 0) ,""));

if TotalAsk- TotalBid <0 then text_SetColor (NumBarsText, red) else text_SetColor (NumBarsText, green) ;
text_setsize (NumBarsText, TxTSize);
text_setborder (NumBarsText, true);
text_SetStyle (NumBarsText, 1, 0) ;
text_setfontname (NumBarsText, TxTFont);
end;
//print (barcounter, " ",FootPrintPrice," ",BarLow, " ",BarHigh);
TotalAsk = 0;
TotalBid = 0;

BarLow = 999999;
BarHigh = 0;
OpenValue = close;
FirstCandle = 0;

for ResetCounter=0 to BidAskArraySz
begin
Bid.Array [ResetCounter] = 0;
Ask.Array [ResetCounter] = 0;

end;
BarCounter = 0;
//print (barcounter, " ",FootPrintPrice," ",BarLow, " ",BarHigh);
end;

end;


{Function _SpacifyString, Return Type: String
Inputs:
Str(StringSimple),
Width(NumericSimple),
Dir(NumericSimple);


Variables:
Spaces(" "); // That should do.. :)

_SpacifyString = Str;

if (StrLen(Str) < Width) then
begin
if (Dir = 1)
then _SpacifyString = LeftStr(Spaces, Width - StrLen(Str)) + Str;

if (Dir = -1)
then _SpacifyString = Str + LeftStr(Spaces, Width - StrLen(Str));
end;
}
Attachments
foot4.png
(97.29 KiB) Downloaded 2972 times
Last edited by SP on 18 Jun 2012, edited 6 times in total.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Footprint chart with history - need some help

Postby Henry MultiСharts » 29 May 2012

Hello SP,

Our coder has adjusted the code for you. Please check the attached file.
Attachments
footprint.zip
(6.54 KiB) Downloaded 311 times

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 29 May 2012

Hi Henry,

thanks for the help. The problem still exists in live markets. It plots ok till the first reset (new SynthTimeFrame is reached). After that only some rows are plotted.


PS: There is one small further error at the { realtime branch } block. The lines need to be changed from

TotalBid = TotalBid + Bid.Array[FootPrintPrice];
TotalAsk = TotalAsk + Ask.Array[FootPrintPrice];

to
TotalBid = Array_Sum (Bid.Array,BarLow ,BarHigh);
TotalAsk = Array_Sum (Ask.Array,BarLow ,BarHigh);
for the realtime values into the box below.
Attachments
FP1.jpg
(62.48 KiB) Downloaded 2892 times

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 29 May 2012

SP, this study of yours is awesome.

Really, really good.

I've darkened the bars so they don't confuse my eyes since the important data there is the footprint.

For MC support, one problem I've noticed is the fact that the last price traded color in the Y-Scale is associated with the bar's color which messes its reading. Is it possible to detach its color from the bars so we can see it when we choose a darker color as in the image? Also, since the ES trade in quarters, why do we have those decimals in the scale? Shouldn't the scale be in quarters?

Image

Back to SP, it seems I've spoken too soon since something weird is happening with the study. It stopped plotting all price levels. I need to reload the indicator so things go back to normal.

Image

You have in the Synth TimeFrame 2000, this reports what? 2000 ticks per bar/reading?
Attachments
SP_footprint1.png
(28.34 KiB) Downloaded 3677 times
SP_footprint.png
(32.5 KiB) Downloaded 3681 times

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 29 May 2012


You have in the Synth TimeFrame 2000, this reports what? 2000 ticks per bar/reading?
2000 means it plots the same footprints as a 2000 Tick chart.
Back to SP, it seems I've spoken too soon since something weird is happening with the study. It stopped plotting all price levels. I need to reload the indicator so things go back to normal.
Thats why i asked for help :) The code posted at #1 at the code box doesnt delete the text, but doesnt plot the last live box ( it is similar to using a study with (if barstatus(1)=2) ).

The problem is that the code needs to delete and replot all text on every single tick for all arrays for the last live part.
Last edited by SP on 29 May 2012, edited 1 time in total.

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 29 May 2012

Thats why i asked for help :)
The problems is that the code needs to delete and replot all text on every simple tick for all arrays for the last live part.
Yeah, didn't notice that the problem was the same.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Footprint chart with history - need some help

Postby Henry MultiСharts » 01 Jun 2012

Hi Henry,

thanks for the help. The problem still exists in live markets. It plots ok till the first reset (new SynthTimeFrame is reached). After that only some rows are plotted.
Hello SP,

Our coder has provided a general idea of how it can be modified.
If you are interested in modifying this script in terms of custom project-please contact me directly.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Footprint chart with history - need some help

Postby Henry MultiСharts » 01 Jun 2012

Hello Arnie,
For MC support, one problem I've noticed is the fact that the last price traded color in the Y-Scale is associated with the bar's color which messes its reading. Is it possible to detach its color from the bars so we can see it when we choose a darker color as in the image?
Unfortunately that is not possible at the moment. Please vote for it in PM1 and PM2.
Also, since the ES trade in quarters, why do we have those decimals in the scale? Shouldn't the scale be in quarters?
Please go to Format->Instrument->Scaling->Set labels manually->Set step size 0.25

User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

Re: Footprint chart with history - need some help

Postby CrazyNasdaq » 04 Jun 2012

Great Job SP !!!
I've taken a quick look and made some adjustment to try make the code work fine even in real time.
Attached there are 2 screenshots, the first one is from DAX future real time with Multicharts programmer's code (the original one from MC programmers). The second one is the one with my adjustments.

I've inserted only a little logic for the real time part where the original one works not fine.
The correction is regard the counter >=1 to counter < SynthTimeFrame. In this condition you have not fully loaded ticks till SynthTimeFrame (your treshold) but you are with counter over zero.

Code: Select all

else if getappinfo(airealtimecalc) = 1 then begin
counter = -1;
For FootPrintPrice = BarLow to BarHigh
begin
counter = 1;

//>>>> If counter >=1 and counter < SynthTimeFrame then begin

if ( counter > array_getmaxindex(realtimeTextIDs) ) then
array_setmaxindex(realtimeTextIDs, array_getmaxindex(realtimeTextIDs) + idxIncrement);
.....
.....
Footprint with Original code in real time
http://img402.imageshack.us/img402/9972 ... intcod.png

Footprint with modified code in real time
http://img521.imageshack.us/img521/6986 ... intcod.png

This way the footprint works fine and each time ticks reached the new treshold (synthTimeFrame) the Footprint plots fine till the last complete treshold. There is a last bug/problem to solve, the very last footprint regard the very last ticks which plots only a partial footprint.
Maybe next days when I will have much time, I will try to solve even this bug.
A good solution is even to set the footprint not only in ticks treshold, but also in time, volume or range bars. I've some ideas, but unfortunatly not much time to work around on it.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 04 Jun 2012

I have added a function for displaying the total delta for the day on the right in realtime. The code needs a little bit longer to plot and has 3 update methods.

CrazyNasdaq,

i will contact Henry for the realtime part for the last bars. At the moment it seems that the best solution is to use the attached code for history and use the normal MD code posted here
viewtopic.php?f=5&t=10413&hilit=MD
for realtime with data2 (resolution set to SynthTimeFrame ) as the code takes less recources.
Attachments
FP3.jpg
(224.72 KiB) Downloaded 2915 times
test_footprint_V3.rar
(6.3 KiB) Downloaded 246 times

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 04 Jun 2012

Hi Henry,

thanks for the help. The problem still exists in live markets. It plots ok till the first reset (new SynthTimeFrame is reached). After that only some rows are plotted.
Hello SP,

Our coder has provided a general idea of how it can be modified.
If you are interested in modifying this script in terms of custom project-please contact me directly.

Hey Henry, you guys could be a bit more helpful here...

You already said that you are considering Footprint charts for MC and since your consideration might take 1 or more versions to be considered and since SP was kind enough to publish its own footprint, you could solve the bug that the study has so we all could use it during your "consideration" period.

Would it take that long for your "coder" to solve the problem that you guys need to charge for it?

Imagine that you guys decide to add footprint only in version 10. That at least would be 1 year or more away. You guys prefer not helping SP in facilitating this tool till it has a built in version and in the process making some clients of yours look at competition that might in the long hall make those same clients abandon MC completely?

I understand that some tools take their time to be properly developed but when someone develop that tool you should look at it as an opportunity for you guys, giving you more time to properly develop your own tool. Meanwhile you should assist that user in its tool. It will be beneficial for you in the long hall.

Sometimes it's kinda scary the lack of vision that software houses have.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

SP, what does the

Code: Select all

GetAppInfo(18) = 1
part in your latest version mean? According to the GetAppInfo wiki page, there only 14 constants?

Also, what's wrong with your latest version? It looks correct:
screenshot.726.png
(101.35 KiB) Downloaded 2899 times

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 06 Jun 2012

Josh,
GetAppInfo(18) is the same as GetAppInfo(aiRealTimeCalc).

"what's wrong with your latest version?"
It plots realtime only the full bar, for your chart (SynthTimeFrame = 500) only all 500 Ticks. What we need is the plotting for the last traded values after the last full bar (if barcounter < SynthTimeFrame).

PS: I saw that you set MaxExpectedRangeInTicks to 8000. Try to keep the array as small as possible.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

GetAppInfo(18) is the same as GetAppInfo(aiRealTimeCalc).
I didn't knew that. Thanks.
It plots realtime only the full bar, for your chart (SynthTimeFrame = 500) only all 500 Ticks. What we need is the plotting for the last traded values after the last full bar (if barcounter < SynthTimeFrame).
I'd like to help here and already spend some time on your code, but I don't understand what you mean with What we need is the plotting for the last traded values after the last full bar (if barcounter < SynthTimeFrame). I saw that your screenshots used a 1 tick bar - do you want to calculate the foot print for the last full 1 tick bar?

You could also mean 'plot the footprint for the last full synthetic bar of SyntTimeFrame ticks', but then I don't understand your barcounter < SynthTimeFrame comment since in such a case you'd need 'barcounter = SynthTimeFrame' (such as in the indicator)?

Or you could also mean that you want to calculate the footprint as long as BarCounter < SynthTimeFrame?

Please elaborate if you can/will. :)
PS: I saw that you set MaxExpectedRangeInTicks to 8000. Try to keep the array as small as possible.
I got a run time error suggesting I needed an array of 5200, hence the high array value.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

Ow wait, I think I understand what you mean -- only plot the footprint for the last SyntTimeFrame amount of ticks, and remove all other footprints?

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 06 Jun 2012

Josh,

open two 1 tick charts. 1 with the indicator posted by Henry at post #2 (with the modification of post #3) and mine at post #10.

You will see that for the code from #2 we get the last realtime data, but after the SynthTimeFrame is reached the code goes nuts sometimes, plotting not all rows.
Last edited by SP on 06 Jun 2012, edited 1 time in total.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

You will see that for the code from #2 we get the last realtime data, but after the SynthTimeFrame is reached the code goes nuts sometimes, plotting not all rows.
I can't reproduce that behaviour; the rows of both indicators are the same:
screenshot.731.png
(104.46 KiB) Downloaded 2887 times
Unless you have a screenshot or something, I'm afraid I can't be of help.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 06 Jun 2012

Josh,

jump with the playback button to the start of the day, set playback to "As (1 Tick Bar)" and play it with some speed at both charts. If it is still not clear i will post a short vid after todays session.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

jump with the playback button to the start of the day, set playback to "As (1 Tick Bar)" and play it with some speed at both charts. If it is still not clear i will post a short vid after todays session.
Indeed, in PlayBack mode the indicator from post #3 has missing rows compared with the indicator from post #1:
scr.06-06-2012 14.06.48.png
(44.14 KiB) Downloaded 2883 times
But this implies that the indicator from post #1 is correct (since this plots all rows). In that case, we're spending precious time on an indicator that doesn't work correctly (from post #3) while the one from post #1 has the correct numbers of rows (and thus is correct in this regard). Speaking of a waste of time.

Is this then the actual problem?
The problem is that the code needs to delete and replot all text on every single tick for all arrays for the last live part.
"what's wrong with your latest version?"
It plots realtime only the full bar, for your chart (SynthTimeFrame = 500) only all 500 Ticks. What we need is the plotting for the last traded values after the last full bar (if barcounter < SynthTimeFrame).
As I understand it, you're saying:
The indicator needs to plot all footprints for the historical data, which happened when SynthTimeFrame = BarCounter, but needs to update in the last part (while BarCounter < SynthTimeFrame) until this part is complete.

User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

Re: Footprint chart with history - need some help

Postby CrazyNasdaq » 06 Jun 2012

Josh, the problem as I worte in post #9
There is a last bug/problem to solve, the very last footprint regard the very last ticks which plots only a partial footprint.

" If counter >=1 and counter < SynthTimeFrame "
is when ticks have not reached the treshold limit (SynthTimeFrame) to plot the entire Footprint candle. The code reset the barcounter each time ticks reached the treshold (SynthTimeframe) and then it plots the correct complete footprint.

Code: Select all

If Barcounter = SynthTimeFrame then
begin
But when counter or barcounter is between 1 and SynthTimeFrame ?
The plotting does not work correctly, but the calculation of the variables is OK
We have to work around this aspect - The plotting and re-plotting of Footprint in real time on each new tick till it reached the SynthTimeFrame treshold.
Attachments
DAX footprint.png
(59.33 KiB) Downloaded 2906 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

But when counter or barcounter is between 1 and SynthTimeFrame ?
The plotting does not work correctly, but the calculation of the variables is OK
We have to work around this aspect - The plotting and re-plotting of Footprint in real time on each new tick till it reached the SynthTimeFrame treshold.
Thanks CrazyNasdaq, it's all making sense for me know. This might not be impossible - I've got the SubText box already 'dynamic' (meaning: moving along during BarCounter < SyntTimeFrame and static when BarCounter = SyntTimeFrame) but I'm wondering about the loop limitations. With this code segment:

Code: Select all

For FootPrintPrice = BarLow to BarHigh begin
....
end;
* Is the range between BarLow and BarHigh always an integer? Or would this be a decimal on forex instruments? (I don't have FX here in PlayBack)
* Is there loop length that is so high that it almost will never get reached (say 50)?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

Something like this? (Which works in PlayBack but haven't tested the performance during live market data yet)
scr.06-06-2012 18.00.20.png
(121.95 KiB) Downloaded 2876 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Footprint chart with history - need some help

Postby JoshM » 06 Jun 2012

It's indeed a pretty looking indicator SP, but I'm wondering if the array can be reduced. A moment ago, I needed an array of 11.000 (ES) to prevent run time errors and no wonder, it ran sluggish. Anyway, that's for you to decide since I don't fully understand footprints.

Anyway, screenshot of PlayBack mode:
scr.06-06-2012 19.11.45.png
(48.6 KiB) Downloaded 2880 times
Video showing it in real-time moments ago on the FESX: real-time video. (Have patience, it's an after hours video :) )

.pla file in the attached zip.
Attachments
testFootprintVersion4.zip
(7.53 KiB) Downloaded 203 times

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 06 Jun 2012

Anyway, that's for you to decide since I don't fully understand footprints.
You can read about it here:

http://footprintchart.com/

:)

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 06 Jun 2012

Josh,

many thanks, it seems to work. Only the lines 347/348 needs to be replaced by

Code: Select all

TotalBid = Array_Sum (Bid.Array,BarLow ,BarHigh);
TotalAsk = Array_Sum (Ask.Array,BarLow ,BarHigh);
and the MaxNumberOfRowsPerFootprint with 20 is too low for most instruments.

I dont know why you get that array error as the array size is determined by the line

Code: Select all

FootPrintPrice = (BidAskArraySz / 2) + (Close - TodayOpenPrice) / TickSize;

As i dont think your ticksize settings are wrong, it could only be that there is a misprint at one quote or the TodayOpenPrice is wrong at the first tick on the date change.
I only use the code with RTH/Pit trading sessions.


Now we only need to clean up the code, make it a little bit more efficient and usable for other synthetic timeframes like minute charts.

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 06 Jun 2012

Now we only need to clean up the code, make it a little bit more efficient and usable for other synthetic timeframes like minute charts.
Yes, minute charts would be preferable, but also volume charts.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 06 Jun 2012

Made some small adjustments and added one more plotting mode 3.
Attachments
Foot_Final V1.rar
(9.21 KiB) Downloaded 200 times
PlotDeltaMode3.png
(222.6 KiB) Downloaded 2888 times

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 06 Jun 2012

Made some small adjustments and added one more plotting mode 3.
I'm receiving this error

Image

with the "standard" inputs

Image
Attachments
study_format.png
(30.11 KiB) Downloaded 3711 times
error_foot.png
(10.21 KiB) Downloaded 3689 times

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 06 Jun 2012

arnie,

try to set Format Instrument-> Settings -> Sessions to CME: Equity Index Futures (Open Outcry)
and load only 3 trading days.

It seems there is still a problem with 24 h charts.
Last edited by SP on 06 Jun 2012, edited 1 time in total.

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 06 Jun 2012

arnie,

try to set Format Instrument-> Settings -> Sessions to CME: Equity Index Futures (Open Outcry).

It seems there is still a problem with 24 h charts.
Yes, that's the session I have selected.

EDIT: I had 1 day back selected but when I changed to 2 days it started calculating and plotted fine, although taking a lot of time to plot.

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 07 Jun 2012

Hi SP.

You really need to change some of those Inputs because it's kinda difficult to know what they refer too, even with the comments you've made in the code.

Image

You need to separate what is related to the footprint, to the profile and to the databox. I think these names are best suited to differentiate them.
If you set inputs such as FootColor, FootTxtSize, ProfColor, ProfTxtSize, BoxColor, BoxTxtSize, people will have a better understanding of what they need to change.

You need to set colors for each, text size for each, borders for each (I've been trying to remove the borders from the profile but I just can't figure out where the border for this is being set since all text is being set by Value1 variable.
I know that the profile is being set between lines 263 and 292 but where are its borders?

Also, it would be nice for the profile have an option to plot full volume instead of only full delta.

Regards,
Fernando
Attachments
MC_footprint.png
(75.13 KiB) Downloaded 3511 times

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 07 Jun 2012

I was comparing your footprint with SC's and I'm quite happy to see very little discrepancies. The existing ones might be related to the array limitation (?) or the fact that SC and MC don't initiate a 2000 tick bar right at the same second, which they don't, hence the discrepancy on volume per price.
Attachments
MC_footprint02.png
(54.43 KiB) Downloaded 2875 times

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 07 Jun 2012

As i know SC uses true AtBid/AtAsk calculation for the profile, this code here only uses an approximation with upticks/downticks.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 14 Jun 2012

Fernando,

made some small updates. Take a look if it fits your needs.
FootV2.jpg
(296.81 KiB) Downloaded 2887 times
Attachments
FootFinal 2.rar
(10.13 KiB) Downloaded 203 times

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Footprint chart with history - need some help

Postby arnie » 14 Jun 2012

Fernando,

made some small updates. Take a look if it fits your needs.
FootV2.jpg
This is really good work SP. Really good work.
Any idea on how to make the synthetic time frame to be based on minutes instead of ticks? Can MC retrieve tick data from minute charts? This is essencial not only for accurate footprint but also for volume profile.

IQFeed configuration on QM has an option to build minute and daily bars based on tick data. Can this facilitate the time based synthetic time frame?

Regards,
Fernando

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history - need some help

Postby SP » 15 Jun 2012

Any idea on how to make the synthetic time frame to be based on minutes instead of ticks?
Regards,
Fernando

To simulate a 5 minute chart you could set Show.DataBox to false and change the line at 534

Code: Select all

// Reset variables
if (BarCounter = SynthTimeFrame) then begin
to

Code: Select all

if value20 = 0 and Mod(Time,5) = 0 then value20 = 1;
if value20 = 2 and Mod(Time,5) <>0 then value20 = 0;

// Reset variables
if ( value20 = 1) then begin
value20 = 2;

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history

Postby SP » 18 Jun 2012

These will be the last changes i make for the code:

- Plotting the Volume Profile: If PlotDeltaModeProfile is set to 5 then it draws a Volume Profile on the right.

- UpDnTicksOrBidAsk : If UpDnTicksOrBidAsk is set to 2 the code use insidebid/insideask instead of up/downticks.

Keep in mind that insidebid/insideask has no history, only the Footprints for realtime data are correct, not for the history before. If the last tick is between insidebid and insideask it calculates the last tick as at ask if the last change before was a uptick and at bid if the last change before was a downtick .
Attachments
VP.png
(110.74 KiB) Downloaded 2927 times
Footprint_Final V3.rar
(12.08 KiB) Downloaded 305 times

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Footprint chart with history

Postby sptrader » 18 Jun 2012

I love the idea of a footprint study but with every version (including V3) I keep getting an array bounds error - "wrong index value : 40" , what am I doing wrong ?
CLN2 1 tick chart- 5 days loaded, MC current ver. (using V3 default values)

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history

Postby SP » 18 Jun 2012

You could open a 2000 Tick chart or the timeframe you choose at SynthTimeFrame and take a look what is the biggest range in ticks for a single bar at the last trading days.

Then increase the number at MaxNumberOfRowsPerFootprint to the highest value + x. So try a value above 100-200 for the CL.

Same for the MaxExpectedRangeInTicks. Open a daily chart to estimate what the daily range in ticks is for the CL and adjust the MaxExpectedRangeInTicks to the highest value + x. As the CL sometimes move over $4 a day, a value above 500 should do it.

The code here should be only a small help until the MC team adds a native solution in one of the next version.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Footprint chart with history

Postby SP » 18 Jun 2012

As i was asked about history with Bid/Ask, one more comment.

If you have a reliable data feed you could add 2 additional 1 tick data series to the chart (bid(data2) and ask(data3)) and replace at the code insidebid with c data2 and insideask with c data3 to get a history plot.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Footprint chart with history

Postby sptrader » 18 Jun 2012

SP: it works great with your suggestions, I just have to tweak it to taste..thx !


Return to “MultiCharts”