Modifications needed in code to try algo trading with dhan app via trading view

Dear Dhan community,
I have programmed several pinescript code strategies and I wish to use them for algo trading. I just wish to know what modifications I need to do with the code in order to make it compatible to fire orders on my dhan app. My dhan app webhook, buy/sell basket order json are available to me generated from dhan account.

Hi @elishablacksmith07 Welcome to Dhan community. Didn’t follow your ask, if you are looking to use webhooks via TradingView, request you to check this video for full details:

Well Sir, I understood how to add webhook and using the alert message to put the json of the the buy/sell signal. But my strategy contains both buy and sell orders along with exit buy and exit sell orders. How do I include all that in one single alert message. Can you please show some sample examples, so that accorrdingly I can add webhook and the json to the alert message and start algo trading?

I am facing issue when my webhook alert try reversing the position as per my strategy. I have generated a double size sell order to convert buy into sell position, but when this triggers, broker fails the order because of margin. Then I tried using the reversal of position by putting alert one by one in the code like first line for exiting the position & second for the entry of new short but still facing same issue because exit donot happen by the time the new sell order comes and again margin issue. Please help how do i reverse the positions using TV & dhan pinescript