Cant Comment unless i see the complete alert message
I am able to fetch data only for commodity segment, I am not able to fetch data of Equity cash segment. I tried multiple times for the cash segment . But I am not receiving any ticker data for that.
Hello @Akash_Prasad
Looks like you added this on wrong thread. To answer the issue, can you check if the added instrument is correct along with the exchange also in the Security ID master list?
The instrument added has not been subscribed as well, which implies it should be incorrect.
Both security Id and exchange ID are available
Over here, you are trying to fetch BSE_EQ instrument, which has exchange segment as 4
with NSE_EQ exchange segment 1
. Hence, no data is being fetched here.
There is a work around. From mobile browser select “Desktop site option” and then login to web.dhan.co. Then browse to web.dhan.co/index/orders/webhooks. Bingo, now we can manage webhooks and generate basket json from mobile browser…
@Hardik @Shylaja
Hi,
Thanks to Dhan for coming up with automated trade, consistent updates and support. I never imagined about a signal based automated trading to be available for retail traders.
I need a help in setting up my strategy from any one of you guys here. I went through all 400+ messages in Webhook introduction thread and this thread together. I also went through videos shared by you guys. But couldn’t exactly get what I am looking for. One post shared by @Shylaja about dynamic options strike order placement is closest one to my need. But I am not sure how exactly use that in my case.
Here is what I need. Whenever I get buy signal from my pine script, I need to place Nifty FUT Long trade and along with that one Nifty PUT OPT with closest ITM strike (monthly expiry). Vice versa for sell. Nifty FUT short and Nifty CALL OPT with closet ITM (monthly expiry). I want to do this so that I can limit my loss and drawdown though it reduces my profit. Another advantage is it needs 1/3 of naked FUT trade margin. Typically one trade will be open for 1-3 days. So, this works well for me except for last week of expiry where premium reduction is sharper.
Can someone help me to set this up?
Thanks and Regards,
Shrinidhi
Hey @shrinidhibhat
Welcome to MadeForTrade community!
Great to see you are working with webhooks in your own unique way. We have @t7support who is a pinescript legend and community members like @Shylaja who will be great to assist you here.
The title is great but as a perpetual student am unworthy of it
@shrinidhibhat free resource from my side is here. To do what u want to do u need to modify the alert strings in code to reflect the instruments u want to trade in. You can use the multi leg order JSON string from Dhan and make the necessary mods in it.
Thanks for the response. I will check with these guys
@t7support thank you for the response. I will go over the video in weekend. Do you have simple example code lines for pine script alert side? In Dhan I only see fixed option strike price under multi leg order. Couldn’t understand how to use dynamic strike price for this. A sample would be great help. I will take care of actual implementation in Pine script
@shrinidhibhat the sample code is here. It has the code to auto-select the strike based on the depth set by you in the script settings from GUI.
Hello Dear,
You may still alter the below snippet script for Futures as well.
Just set the 2nd step to false. and follow as per the instruction mentioned in the said link.
However if you still need the overall flow of creating a mutli leg strategy with either futures or options you may refer below open source script of mine which is done for Crude Oil MCX.
If you still have questions you may plz ping me here or via telegram @Pavan_BreathEasy
Hello @Hardik - thank you Dhan for this webhook feature - it’s awesome. I’m able to place the buy and sell in separate alerts from trading view.
Can we send trailing stop loss along with buy alert. If yes - can you please help me with template json with parameters.
If no - can you please help do the same with alternative way.
Hi @Hardik, How can I add delay of 10 seconds between 2 trades. Like after existing long position it should wait for 10 seconds before entering short position and vice versa. This is required to use funds effectively. Currently there is no delay, exitLongCondition and shortCondition are getting executed at same time. It will reject order due to short of fund as funds are not yet released from previous exitLongCondition.
if (exitLongCondition)
strategy.close(“Long”)
if (shortCondition)
strategy.entry(“Short”, strategy.short)
if (exitShortCondition)
strategy.close(“Short”)
if (longCondition)
strategy.entry(“Long”, strategy.long)
https://www.tradingcode.net/tradingview/countdown-till-bar-close/
You could calc and place some delay in code by using barstate, timeclose, timenow and fire orders
Hi @t7support, I have tried many combinations with timenow, time_close, bar_index but it is not seems to be working. Does Dhan have built-in function allowing time delay between orders?
No there is no bulit in function with Dhan to delay orders from tradingview alerts. What u r asking for must be done in pine script only as the script is firing orders based on it’s logic.
If u see the link below u can see that there is a piece of code which closes all orders after a delay. In a strategy file, code generates a signal at the close of a candle. So u can fire first order at first tick of the next candle. Then apply the delay condition along with next signal condition to fire the next order. In short what u r asking for can be done in pine.
https://www.tradingcode.net/tradingview/countdown-price-bar/
Hi @t7support, I tried below. Still exitlongcondition and shortcondition are getting executed at same time.
timeLeft = barstate.isrealtime ?
(time_close - timenow) / 1000 :
na
// Translate seconds left into minutes and seconds
minsLeft = math.floor(timeLeft / 60)
secsLeft = timeLeft % 60
if (exitlongcondition and minsLeft <= 58)
strategy.entry(“short1”, strategy.short)
if (shortcondition and minsLeft <= 58)
strategy.entry(“short2”, strategy.short)
if (exitshortcondition and minsLeft <= 58)
strategy.entry(“long1”, strategy.long)
if (longcondition and minsLeft <= 58)
strategy.entry(“long2”, strategy.long)
Every condition is <= 58 and so everything will execute at the same time. There should be differential delay between orders.
Also, please note that in this forum I can point you to relevant resources to get u r task done. Debugging your or any one else’s code over different iterations is really out of scope of what this forum is meant to do.