Time & Sales EL for multicharts .net - how to convert?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
Azharr
Posts: 13
Joined: 04 Apr 2013
Has thanked: 3 times

Time & Sales EL for multicharts .net - how to convert?

Postby Azharr » 09 Apr 2013

Code: Select all

// Original Code from https://www.TS.com/Discussions/Topic.aspx?Topic_ID=104700
// Solidus SDO time and sales
// Use on daily chart with Streaming Data Optimization enabled
// see input descriptions below


// Added or changed by SP for MC: TextLocation, Automatic Decimals, Block Alert as border, TextSize

//DefineDLLFunc: "GetMachineTime.dll", Float,"MachineTimeMillD";

input:
Rows ( 30 ), // max of 100
Show.Header ( false ), //added Jan 2011 by SP
Auto.Decimals ( true ), //added Jan 2011 by SP
Dec.Places ( 2 ), //decimal places for price data
Short.Price ( 0 ), //abbreviates price display, e.g., 25.25 instead of 2025.25
Volume.Threshold ( 20 ), //minimum volume to display
Show.Block ( true ), //added Jan 2011 by SP, draw a border on block levels
Alert.Threshold ( 50 ), //minimum volume to alert; must be larger than volume.threshold
//Alert.Divisor ( 100 ), // used to shorten alert sound; suggested value:100
Time.Setting ( 1 ), //time setting=2 to show full time; setting=1 to drop hours
Text.Size ( 8 ), //added Jan 2011 by SP
Up.Color ( green ), // color when trade is an uptick
Down.Color ( red ), //color when trade is a downtick
Heading.Color ( yellow ) , //color of heading at top
Block.Color ( White ); //added Jan 2011 by SP
var: Label.Text("-"), MyDecimalPlaces ( 0 ),
ii(0), hval(0), lval(0), diff(0), price(0), p.txt(" p"), vol.dat(0),
intrabarpersist updn.col(0), intrabarpersist prev.p(c), intrabarpersist prev.ticks(0),
intrabarpersist initialized(false), intrabarpersist last.tick(0), intrabarpersist this.bar(0),
intrabarpersist updn(0), t.val(0), Hr(0), One60th(1/60), Min(0), min2ts(0), sec(0),
time.string(" "), h.string(" "), m.string(" "), s.string(" "), rowz(rows+1);

array: Vol.txt[101](0), intrabarpersist Vol.str[101](" --- "), intrabarpersist vol.block [101](0), intrabarpersist Vol.col[101](getbackgroundcolor);

once begin
for ii=0 to rows begin
vol.txt[ii]=text_new_s(d,time_s,c,"text string");
text_setstyle( vol.txt[ii],1,0);
text_setcolor( vol.txt[ii],getbackgroundcolor);
end;
If Auto.Decimals = true then
begin
if PRICESCALE = 100000 then MyDecimalPlaces = 5
else
if PRICESCALE = 10000 then MyDecimalPlaces = 4
else
If PRICESCALE = 1000 then MyDecimalPlaces = 3
else
If PRICESCALE = 100 then MyDecimalPlaces = 2
else
If PRICESCALE = 32 then MyDecimalPlaces = 5
else
If PRICESCALE = 10 then MyDecimalPlaces = 1
else
If PRICESCALE = 8 then MyDecimalPlaces = 3
else
If PRICESCALE = 1 then MyDecimalPlaces = 0;
end;
If Auto.Decimals = false then MyDecimalPlaces = Dec.Places;

If Show.Header then begin
text_setstring(vol.txt[0],"T+S "+ symbolroot + " Trades>"+numtostr(Volume.Threshold,0) );
text_setcolor(vol.txt[0],heading.color);
text_setsize(vol.txt[0],text.size);
end;

end;

hval=GetAppInfo( aiHighestDispValue );
lval=GetAppInfo( ailowestdispvalue );
diff=(hval-lval)/rowz;
text_setlocation_s(vol.txt[0],d,time_s,hval);

if GetAppInfo(aiRealTimeCalc)=1 then
begin

if currentbar>this.bar then
begin //if new bar
this.bar=currentbar;
vol.dat=ticks;
end

else vol.dat=ticks - prev.ticks; // else old bar


if c>last.tick then updn.col=up.color else if c< last.tick then updn.col=down.color;

if initialized and vol.dat >= Volume.Threshold then
begin

//if vol.dat>=Alert.Threshold then alert(numtostr( intportion(vol.dat/Alert.Divisor),0) );

for ii = rows downto 1 begin
vol.str[ii]=vol.str[ii-1];
vol.col[ii]=vol.col[ii-1];
vol.block[ii] = vol.block[ii-1];
end;

if short.price>0 then price=fracportion(c/100)*100 else price=c;

p.txt=numtostr (price,MyDecimalPlaces); //price string
if intportion(price)<10 then p.txt="0"+p.txt;

vol.str[0]= numtostr (vol.dat,0); //volume string
if c>prev.p then vol.str[0]= vol.str[0]+" ++"+ p.txt+" "
else if c<prev.p then vol.str[0]= vol.str[0]+" --"+ p.txt+" "
else vol.str[0]= vol.str[0]+" "+ p.txt+" ";
vol.block[0] = vol.dat;

if Time.Setting>0 then
begin
t.val=fracportion(computerdatetime)*1440;

Hr = Mod(IntPortion( t.val * One60th ), 24 ) ;
Min = t.val - 60 * Hr ;
sec=intportion(fracportion(min)*60);

Min= intportion(min);
m.string=numtostr(min,0);
if min<10 then m.string="0"+m.string;

s.string=numtostr(sec,0);
if sec<10 then s.string=":0"+s.string else s.string=":"+s.string;

if hr>12 then hr=hr-12;
h.string=numtostr(Hr,0);
if hr<10 then h.string=" "+h.string;

if Time.Setting>1 then time.string= h.string+ ":"+m.string + s.string
else time.string=m.string + s.string;

vol.str[0]=vol.str[0]+ time.string;
end;

vol.col[0]=updn.col;

prev.p=c;

// set text strings, locations, color


for ii=1 to rows
begin
text_setsize (vol.txt[0],text.size);
text_setstring (vol.txt[ii]," "+vol.str[ii-1]+ " ") ;
text_setcolor (vol.txt[ii],vol.col[ii-1]);
Text_SetLocation_s (vol.txt[ii], d, intportion (MinutesToTime ((GetAppInfo (7))*60*24)*100) , hval-diff*(ii+1));
if Show.Block and vol.block[ii-1]>=Alert.Threshold then Text_Setborder(vol.txt[ii], true)
else Text_Setborder(vol.txt[ii], false) ;
end;

end;

prev.ticks=ticks; // set up for next tick
last.tick=c;
initialized=true;

end;
wonder when will 8.7 be released...

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

Re: Time & Sales EL for multicharts .net - how to convert?  [SOLVED]

Postby Henry MultiСharts » 09 Apr 2013

MultiCharts .Net 8.7 with Time and Sales functionality is (roughly) expected in May.

FB2013
Posts: 20
Joined: 12 Mar 2013
Has thanked: 3 times
Been thanked: 5 times

Re: Time & Sales EL for multicharts .net - how to convert?

Postby FB2013 » 09 Apr 2013

That fast, really great development cycle.


Return to “MultiCharts .NET”