//Author: Erik A Garland-Success Over Stress- http://www.youtube.com/@SuccessOverStress -Email: SuccessFromStress@gmail.com. Discord: https://discord.gg/3hdkfE8fyU
//Date: 09-11-25
//Design: Demonstrate use of event handler to handle object click
using charting;
using elsystem.drawingobjects;
var: rectangle rect(null);
//================= LOAD RECTANGLES ON CHART ONCE ==========================
method void xloadobjects()
var: int idxa;
begin // LOOP THROUGH THE OBJECTS IN THE COLLECTION SO YOU CAN ASSIGN AN EVENT HANDLER
for idxa=0 to drawingobjects.items[objectcategory.rectangle].count-1
begin
rect=drawingobjects.items[9].at(idxa) astype rectangle; //ASSIGN THE INDEXED OBJECT TO THE RECTANGLE
rect.click+=Rectangle1_Click; //ASSIGN THE METHOD TO HANDLE THE CLICK EVENT
end;
end;
//================= METHOD EVENT TO HANDLE OBJECT CLICK ==========================
method void Rectangle1_Click( elsystem.Object sender, elsystem.drawingobjects.DrawingObjectEventArgs args )
var: rectangle temprect; // LOCALLY DECLARE TEMPORARY RECTANGLE TO HANDLE SENDER
begin
temprect=sender astype rectangle; //ASSIGN THE SENDER TO YOUR TEMPORARY RECTANGLE
print (temprect.startpoint.tostring(), "|", temprect.endpoint.tostring());//USE DOT OPERATORS TO GET INFO FROM SENDER
end;
//================= MAIN BODY ==========================
once xloadobjects();
//Author: Erik A Garland-Success Over Stress- http://www.youtube.com/@SuccessOverStress -Email: SuccessFromStress@gmail.com. Discord: https://discord.gg/3hdkfE8fyU
//Date: 09/14/25
//Design: Demonstrating the power of methods with simple plot bars...Ultimately using a print statement to
//show how to return from a method.
using elsystem.drawing;
var: zstring("");
method string xplot(int zcolor, int zweight )
begin
if l< low[1] and high>high[1] then
begin
plot51(low, "hhll", zcolor, default, zweight);
return bardatetime.tostring();
end;
return "" ;
end;
if close< sa9 then zstring=xplot(0, 2) else
if high > average(close, 5) then zstring=xplot(16711935, 4) else
if high> highd(1) then zstring=xplot(8388608,6);
if zstring<>"" then print (zstring);
//Author: Erik A Garland-Success Over Stress- http://www.youtube.com/@SuccessOverStress -Email: SuccessFromStress@gmail.com. Discord: https://discord.gg/3hdkfE8fyU
//Date: 09/15/25
//Design: Demonstrating how to properly use arrays
using elsystem.drawingobjects;
//No namespace needed for using arrays
input: i_length(0);
var: mvwap(0), rectangle rect(null), count_seat(0);
array: Array_Vwap[](""); //0,1,2,3,4; Arrays have to be declared with their own Section
constant: permanent_value(4); // constants have permanent
//value99=permanent_value;
if t=1000 then
begin
array_setmaxindex(array_vwap,count_seat+1);// For dynamic arrays you can set the Max index within the code
array_vwap[count_seat]=bardatetime.tostring();
count_seat+=1; //Be sure to use some type of indexing function to be sure that your array assignments are not out of range
end;
if lastbaronchartex {array_getmaxindex(array_vwap)>=10} then print( array_vwap[9]);
//Call the right from their container name. They do not have to be astyped such as when using a vector or dictionary
Maximizing chart space is important. In order to maximize chart space we can reduce the size of the title bar. However, when we do that we lose the immediate handles of manipulation controls. Here is an easy way to still manage the windows with the title bars hidden.
//Author: Erik A Garland-Success Over Stress- http://www.youtube.com/@SuccessOverStress -Email: SuccessFromStress@gmail.com. Discord: https://discord.gg/3hdkfE8fyU
//Date: 092025
//Design: How to use the event handler methods of chartinghost to control window resize events and manage object repositioning
using elsystem.drawingobjects;
var: textlabel tlabel(null), charting.chartinghost chost(null);
input: rt_margin_offset(130)[DisplayName="Margin Offset", Tooltip="Offset from rt margin"];
method void chost_OnSize( elsystem.Object sender, charting.OnSizeEventArgs args )
var: xypoint xyp;
begin
print ( string.format("New Size: X: {0}, Y: {1}", args.width, args.height));
if tlabel<>null then
begin
xyp=tlabel.points[0] astype xypoint;
tlabel.setpointvalue(xypoint.create(args.width-rt_margin_offset,xyp.y));
end;
end;
//=============================main ======================
once
begin
chost = new charting.ChartingHost;
chost.onsize += chost_OnSize;
chost.Name = "chost";
tlabel=textlabel.create(xypoint.create( chost.clientwindow.width-rt_margin_offset,40), "1MIN");
tlabel.lock=true;
tlabel.font=elsystem.drawing.font.create("Georgia", 14, elsystem.drawing.fontstyle.bold);
drawingobjects.add(tlabel);
end;
//Author: Erik A Garland-Success Over Stress- http://www.youtube.com/@SuccessOverStress -Email: SuccessFromStress@gmail.com. Discord: https://discord.gg/3hdkfE8fyU
//Date: 09/29/2025
//Design: How to manipulate trendlines with BNPOINT and DTPOINTs
using tsdata.common;
using elsystem.drawing;
using elsystem.drawingobjects;
using elsystem.collections;
using elsystem;
var: dtpoint dtps(null), dtpoint dtpe(null),
bnpoint bnps(null), bnpoint bnpe(null),
vector vhigh_p(null), vector vval(null),
trendline tline(null), datetime dte(null), datetime dts(null), startstring(""), datetime tempdt(null);
once
begin
vval=new vector;
vhigh_p=new vector;
end;
if d=currentdate and t> 0900 then
begin
if $sh(6)> 0 and bear[6]and (close[6]> open[7]) then
begin
plot51[6](high[6], "", red);
//vval.insert(0, high[6]);
//vhigh_p.insert(0,barnumber+maxbarsback-1-6); //bnpoint
vval.insert(0, high[6]);
vhigh_p.insert(0, bardatetime[6] ); //bnpoint
end;
end;
if d=currentdate and t> 1335 then once
begin
{dte=datetime.create(); dts=datetime.create();
dte.eldatetimeex=vhigh_p[0] astype double;
dts.eldatetimeex=vhigh_p[1] astype double; }
tempdt=vhigh_p[1] astype datetime;
dts=new datetime; //dts.eltime=0900 ;
dts.eldatetimeex=stringtodatetime(tempdt.tostring() );
{bnps=bnpoint.create(vhigh_p[1] astype int,vval[1] astype double);
bnpe=bnpoint.create(vhigh_p[0] astype int,vval[0] astype double); }
dtps=dtpoint.create(dts,vval[1] astype double);
dtpe=dtpoint.create(vhigh_p[0] astype datetime ,vval[0] astype double);
tline=trendline.create(dtps, dtpe);
//tline=trendline.create(bnps, bnpe);
//tline.extright=true;
drawingobjects.add(tline);
end;
if tline<>null and t> 1335 and t< 1355 then
begin
tline.extright=true; ;
//tline.setendpoint(bnpoint.create(barnumber+maxbarsback-1, high));
tline.setendpoint(dtpoint.create(bardatetime , high));
//tline.extright=true;
end;
//Author: Erik A Garland-Success Over Stress- http://www.youtube.com/@SuccessOverStress -Email: SuccessFromStress@gmail.com. Discord: https://discord.gg/3hdkfE8fyU
//Date: 10-17-25
//Design: TS forums request to have an indicator that will import positions symbols onto the chart so one can see relatively where they are: percent based chart
USING TSDATA.common;
using elsystem.drawing;
using elsystem.drawingobjects;
using elsystem.collections;
var: textlabel tlabel(null), vector vlabels(null);
method void PositionsProvider1_StateChanged( elsystem.Object sender, tsdata.common.StateChangedEventArgs args )
VAR: INT IDXA;
begin
IF PP.STATE=DATASTATE.LOADED AND PP.COUNT>0 AND CHOST.datastreams.COUNT=1 THEN
ONCE
FOR IDXA=0 TO PP.COUNT-1
BEGIN
runcommand(".ISY " +PP.position[IDXA].symbol);
END;
end;
method void xlabels()
var: int idxa, string strsymbol;
begin
//value99=c of data(idxa);
for idxa=1 to chost.datastreams.count
begin
strsymbol=symbol of data(idxa); strsymbol=string.format("{0,10}", strsymbol);
tlabel=textlabel.create(dtpoint.create(bardatetime, c of data(idxa)), strsymbol);
tlabel.hstyle=horizontalstyle.left ;
tlabel.lock=true;
tlabel.persist=true;
tlabel.tagtext=numtostr(idxa,0);
drawingobjects.add(tlabel);
vlabels.push_back(tlabel);
end;
end;
method void xupdatelabels()
var: int idxa, textlabel templabel;
begin
for idxa=0 to vlabels.count-1
begin
templabel=vlabels[idxa] astype textlabel;
templabel.setpointvalue(dtpoint.create(bardatetime, c of data(strtonum(templabel.tagtext))));
end;
end;
once vlabels=new vector;
if lastx then
begin
once xlabels();
if vlabels.count>0 then xupdatelabels();
end;