charting-library-examples icon indicating copy to clipboard operation
charting-library-examples copied to clipboard

How to set the position of TP/SL during initialization?

Open ujfjntevtee28230 opened this issue 11 months ago • 1 comments

According to the document convention, I implemented 'IBrokerWithoutRealtime' in the code. When initializing the position acquisition, I obtained the takeProfit/stopLoss fields, and their values ​​are inconsistent; but why is there only one line on the chart showing the draggable TP/SL button? I understand that the data and the chart are bound, but now it seems that this is not the case. If I want to immediately draw the takeProfit/stopLoss in the positions to the corresponding TP/SL line after obtaining them, what should I do? Looking forward to your reply, thank you very much.

Version:charting_library V26. Example: export default class BrokerApi implements IBrokerWithoutRealtime { ... async positions(): Promise<Position[]> { const position = await Store.position.get(); return position || []; } ... }

Image

ujfjntevtee28230 avatar Mar 11 '25 06:03 ujfjntevtee28230

I would recommend reading our article about Bracket Orders. The way the library works is that you'll need to plot the main order and then link each bracket order (for TP & SL) to it.

SimonMorda avatar Mar 14 '25 18:03 SimonMorda