Drawing Templates - SpartaCommodities/Trading_view_wiki GitHub Wiki
Traiding Terminal sends HTTP/HTTPS commands to charts_storage_url/charts_storage_api_version/drawing_templates?client=client_id&user=user_id. charts_storage_url, charts_storage_api_version, client_id and user_id are the arguments of the widget constructor.
You should implement the processing of 4 requests: save template / load template / delete template / list templates.
GET REQUEST: charts_storage_url/charts_storage_api_version/drawing_templates?client=client_id&user=user_id&tool=toolName
-
toolName: name of the drawing tool
RESPONSE: JSON Object
-
status:okorerror -
data: Array of drawing templates names-
name: the drawing template name (example,Test)
-
POST REQUEST: charts_storage_url/charts_storage_api_version/drawing_templates?client=client_id&user=user_id&tool=toolName&name=templateName
-
toolName: name of the drawing tool -
templateName: custom template name -
body: { content: content }-
content: saved content of the template
-
RESPONSE: JSON Object
-
status:okorerror
GET REQUEST: charts_storage_url/charts_storage_api_version/drawing_templates?client=client_id&user=user_id&chart=chart_id&tool=toolName&name=templateName
-
toolName: name of the drawing tool -
templateName: template name to get
RESPONSE: JSON Object
-
status:okorerror -
data: Object-
content: saved content of the template
-
DELETE REQUEST: charts_storage_url/charts_storage_api_version/drawing_templates?client=client_id&user=user_id&chart=chart_id&tool=toolName&name=templateName
-
toolName: name of the drawing tool -
templateName: name of template to remove
RESPONSE: JSON Object
-
status:okorerror
We're running a demo drawing templates storage service to let you save/load drawing templates as soon as you build your Trading Terminal. Here is the link http://saveload.tradingview.com. Note that it's provided as-is since it's a demo.
We do not guarantee its stability. Also, note that we delete the data in the storage on a regular basis.
Starting from version 1.12.
One of the parameters in Widget Constructor, this is basically an object containing the save/load functions. It is used to customize the Templates dropdown behaviour on Drawing settings floating panel. In adition to required fields you should add drawing templates methods:
-
getDrawingTemplates(toolName: string): Promise<string[]>A function to get names of all saved drawing templates.
-
toolName- name of the drawing tool.
-
-
removeDrawingTemplate(toolName: string, templateName: string): Promise<void>A function to remove a drawing template.
-
saveDrawingTemplate(toolName: string, templateName: string, content: string): Promise<void>A function to save a study template.
-
toolName- name of the drawing tool. -
content- content of the study template.
-
-
loadDrawingTemplate(toolName: string, templateName: string): Promise<string>-
toolName- name of the drawing tool. -
templateName- name of the template.
A function to load a drawing template from the server.
-
IMPORTANT: All functions should return a Promise (or Promise-like objects).
In-memory example for testing purposes.