- Desktop
- Tools
- PASCAL Programming
- GetData Example - Tool Programming
GetData Example - Tool Programming
The GETDATA function can be used to retrieve data from a security different from the chart to which the tool is applied.
To use the GETDATA function you just pass the code you want to open, easiest way is to open it as a TDataList and you can access the data like a plot i.e.
var D1 : TDataList;
procedure Process(Tool : TTool; ProcessStart : Integer; ProcessEnd : Integer; DataIn : TDataList);var i : Integer; iIndex : Integer;begin D1 := GetData('CODE=SPX:WI'); // this means code is SPX from the World Indices Exchange (WI) for i := ProcessStart to ProcessEnd do begin iIndex := D1.DateToIndex(DataIn.Row[i].Date); if iIndex >=0 then begin Plot1.Row[i].Date := D1.Row[iIndex].Date; Plot1.Row[i].Close := D1.Row[iIndex].Close; end; end;end;Now because the number of bars for the result from GETDATA might be different from the number of bars in the chart, the rows will not have the same index. So to compare bars of the same date you will need to find the correct index from the date using the DateToIndex function e.g.
D1 := GetData('CODE=SPX:WI');//loop through the source codefor i := 0 to DataIn.Count-1 dobegin // lookup the SPX index for each bar date iIndex := D1.DateToIndex(DataIn.Row[i].Date); if iIndex > 0 then bClosesHigher := DataIn.Row[i].close) > D1.Row[iIndex].Close;end;Forum Discussion
Your privacy choices
We use cookies and similar technologies to make the site work, see how it's used, and improve it. Analytics and advertising cookies only run with your consent — see our Privacy Policy for details.