Can I get more efficiency in use of array and box drawing than the code attached below. I ask because it seems to slow the chart down and takes a while to write the initial boxes.
Many thanks for any thoughts,
Anthony
Code: Select all
// This indicator reads a text file on the server desktop at start of day and creates boxes on the ES chart.
// File reading dll function
defineDLLfunc: "C:\Program Files\TS Support\MultiCharts64\IOData\x64\Release\IOData.dll", int, "RFile", lpstr;
defineDLLfunc: "C:\Program Files\TS Support\MultiCharts64\IOData\x64\Release\IOData.dll", lpstr, "InData", int;
// text file location to read
input: DataFile("C:\Users\Administrator\Desktop\Levels.txt"); // { "C:\Users\hello\OneDrive\Desktop\Date.txt" }
// variable definition
Var: n (0),
LinesCount (0);
// array definition
Array: MYIODATA[50]("StringSimple");
// count the number of lines in the text file to use in loop
LinesCount = RFile(DataFile);
// loop to read text file into array
if date <> date[1]
and date = currentDate
then begin
for n = 0 to LinesCount begin
array_SetStringValue(MYIODATA,n,inData(n));
end;
end;
// loop to create boxes on charts
for n = 0 to Linescount begin
// create rectangle and parse text for useful numbers
rectangleNew(date, 0000, StrToNum(leftStr(MYIODATA[n],7)), date, time, StrToNum(midStr(MYIODATA[n],9,7)));
// get newly created box ID number for use below
value2 = rectangleGetActive;
// using Box ID define box attributes
value1 = rectangleSetStyle(value2,1);
value1 = rectangleSetColor(value2,DarkBlue);
value1 = rectangleSetPattern(value2,5);
value1 = rectangleSetFillColor(value2,DarkBlue);
end;
// sample of text file
{3958.50,3967.50,R,Strong
3953.00,3953.00,R,Normal
3934.50,3943.50,R,Normal
3926.50,3926.50,L,Normal
3896.00,3909.00,R,Normal
3886.50,3886.50,L,Normal
3873.50,3878.50,R,Normal
3862.00,3868.00,R,Normal
3856.00,3856.00,L,Normal
3838.25,3848.25,R,Normal
3822.25,3833.25,R,Normal
3797.75,3807.75,R,Normal
3793.40,3794.00,L,Normal
3774.50,3786.00,R,Normal
3755.50,3763.50,R,Normal
3731.75,3742.75,R,Normal
3719.50,3726.00,R,Normal
3699.25,3702.25,S,Normal
3685.75,3695.75,S,Normal
3672.75,3678.75,S,Strong
3658.50,3664.50,S,Normal
3649.50,3654.50,S,Normal
3640.25,3646.25,S,Normal
3627.00,3635.00,S,Normal
3620.25,3620.25,S,Normal
3617.00,3617.00,L,Normal
3608.75,3615.75,S,Strong}