Drawing Templates
Trading Platform 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.
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
:ok
orerror
data
: Array of drawing templates namesname
: the drawing template name (example,Test
)
SAVE TEMPLATE
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 tooltemplateName
: custom template namebody
: { content: content }content
: saved content of the template
RESPONSE: JSON Object
status
:ok
orerror
LOAD TEMPLATE
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 tooltemplateName
: template name to get
RESPONSE: JSON Object
status
:ok
orerror
data
: Objectcontent
: saved content of the template
DELETE 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 tooltemplateName
: name of template to remove
RESPONSE: JSON Object
status
:ok
orerror
Using Demo Drawing Templates Storage
We're running a demo drawing templates storage service to let you save/load drawing templates as soon as you build your Trading Platform. 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.
save_load_adapter
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 behavior on Drawing settings floating panel. In addition 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 drawing template.
toolName
- name of the drawing tool.content
- content of the drawing 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.