How-to
Load and Save Technical Analysis Definitions
API, How-to
The following API calls offers saving and loading of the entire Chart
state, including price-type, time-scale, selected symbol, drawings and
indicators.
Get Data From The Chart (For Saving):
1 2 3 |
//Prototype: objJSONObject = GetTAObject(blnSymbol, blnTimeScale, blnDrawing, blnIndicators, blnPriceType); |
Name | Type | Description |
blnSymbol | Boolean | True to include current symbol id and name. |
blnTimeScale | Boolean | True to include current time-scale. |
blnDrawing | Boolean | True to include all drawings. |
blnIndicators | Boolean | True to include all indicators. |
blnPriceType | Boolean | True to include the current price-type. |
Return Value
The return value is the definition JSON object.
Loading Data Back Into The Chart:
1 2 |
//Prototype: SetTAObject(objJSONObject); |
Name | Type | Description |
objJSONObject | JavaScript object | The Technical Analysis data |
Return Value
There is no returned value
Examples
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
function SaveUserDrawings(){ SaveToCookie("UserDraw1", objChartMain1.chart.GetTAObject(true, true,true,true,true)); } function OpenUserDrawings(){ objChartMain1.chart.SetTAObject(LoadFromCookie("UserDraw1")); } function SaveToCookie(name, value) { var cookie = [name, '=', JSON.stringify(value), '; domain=.', window.location.host.toString(), '; path=/;'].join(''); document.cookie = cookie; } function LoadFromCookie(name) { var result = document.cookie.match(new RegExp(name + '=([^;]+)')); result && (result = JSON.parse(result[1])); return result; } function DeleteCookie(name) { document.cookie = [name, '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.', window.location.host.toString()].join(''); } |
Example2:
1 2 3 4 5 6 7 8 9 10 |
var objTAJson = null; function SaveUserDrawings(){ objTAJson = objChartMain1.chart.GetTAObject(true, true,true,true,true); } function OpenUserDrawings(){ if (objTAJson != null) objChartMain1.chart.SetTAObject(objTAJson); } |
Callbacks For Timing Load/Save Of Data
In addition, you can add callbacks to the chart in order to know when it is safe to load or save this data.
The first parameter is for Future-Use (please ignore it). You can use the symbol and timescale as key for saving.
1 2 3 4 5 6 7 8 9 |
//Callback for saving objChartMain1.chart.UI.funcOnCanSaveTA = function (objParameter, strSymbolID, strTimeScale){ ...Do you saving } //Callback for Loading objChartMain1.chart.UI.OnCanLoadTA= function (objParameter, strSymbolID, strTimeScale){ ...Do you saving } |