Universal Signal Trading Tool : Single Target

Overview
This script by maurya_algo_trader is designed for four major things
- Connect external buy/sell entry signal (from indicator) as well as optional exit signal (bool as well as limit) if available
- SL/Target/TSL : Set various types of Target, Stoploss and trailing stoploss through this script
- Trade/Risk Managements : Control the no of trades, day or month profits or loss etc.
- Time managements : Sessions for trade timings
- Execute trades (Equity, Futures and Options) on various brokers (Currently available for Dhan, Flattrade, 5Paisa, Anand Rathi and Delta exchange) automatically via webhook features through only single alerts
- (currently available only for indian market : NSE, BSE, MCX and Delta exchange India crypto)
How to Connect External Signals for Entry, Exit(optional)
To connect external signals it is mandatory that the external signal script must be in the form of an “indicator” (Not in strategy).
In the tradingview community indicator you can find readymade indicator buy/sell signals (e.g. ut bot alerts). Mostly the buy/sell signal plotted via plotshap() function which gives the particular value (mostly: 1). This can be seen in “Data Window” (Right side of Tradingview just below the alert section). When you keep the cursor on the candle at buy or sell signal, it gives the value “1” and on the rest of the candles it will be “0”.
In Settings/Input tab you will find “EXTERNAL ENTRY” section where you can select the buy signal in drop down menu of “External Ling Entry Signal” and in same line default value 1 is already present (You can change it if plotted signal showing any other numbers for Buy signal). Similarly Choose sell signal in drop down menu of “External Short Entry Signal”. It also has the same “1” value by default but if it is different like” -1” you can change it manually.
If you have your own strategy, you need to convert it into an indicator first by removing the strategy function from the entire script (if you know the pine script coding or you can message me for the same). Then set the variable for the logic (bool condition) of long entry and short entry. And then plot the logic by following pine codes :
This will create the external plots which can be retrieved in the dropdown menu of “EXTERNAL ENTRY”.
If you have any external exits (other than opposite entry) you can use them similarly in sections of “EXTERNAL EXIT”. If you have any Take profit or take SL (at limit price) then it can also be retrieved in External TAKE PROFIT and EXTERNAL TAKE SL section by selecting the appropriate option in the dropdown menu.
Once proper signal attachment done with dropdown menu, you can see various entry exit labels like : “Long Entry”, “Short Entry”, “Long Exit” and “Short Exit”.
In addition to original entry, advance entry options are available like : “Entry at second candle of the day if no position”; “Entry at high/low breakout of actual Buy/Sell candle”; and “Add buffer to high/low of buy sell candle in points/percentage (inputs).
SL/Target Settings
By default, target and SL are off.
You can select various target types below and set the value accordingly (additional multiplier input available to optimize various interval of target level) :
Value (INR 1000 : not applicable of Index);
Percentage,
Points,
R:R (Multiplier of SL (Point/Percentage) );
No of Bars: Exit at set no of bars after entry.
Various stoploss types available like :
Value (INR 1000 : not applicable of Index);
Percentage,
Points,
Low/High During entry : A fix SL as low or high of no of candle back
Following options are one kind trailing Stoploss
HH/LL of period of candle : As candle moves ahead fix length of candle’s low or high move a one kind of trailing stoploss
ATR : Supertrend as trailing SL you need to add length and multiplier in respective input tabs
Pivot : This is the pivot point of right and left side candles length (low for long side and high for short) add left and right side candle length in respective input tabs.
Opposite band of Bollinger : Lower Band for Long Side and Upper band for Short side
TSL settings
TSL settings have the following types of options. By default it is off. This section is specifically designed to activate TSL after some market achieved some distance from its entry and TSL can be started from desired distance from entry or SL.
High/Low : It trails by distance of previous to new high created after entry
Step : It trails by by given inputs of distance: at every 50 points trails 50 points
Pivot/HH/LL od period of candle, ATR, opposite band of Bollinger these options are same as available in Stoploss section. The difference is only You can choose where the TSL is activated where it start from that you can decide in section.
Trade/Risk Managements
Trade direction : Both/Only Long/ Only short
Reverse Trade : You can reverse the trade if SL/TSL hit if it is in loss/profit options
Skip Opposite trade: If SL and Target or TSL is set then you can skip opposite trade until your SL/Target or TSL hit
Close trade if profitable at no of candle new highest close (for long) and lowest close (for short)
Max no of orders per day
Max Profit Per day
Max loss per day
Max Profit per month
Max Loss per month
Kill All Trades on chart
This option enables you to take only fresh entries after creating the alert. So many times Trade is running on chart and still we have not taken any order or created alert and I want a fresh entry signal (with any exit signal of previous entry). So for that you need to set the current date and times after the last entry on the chart. This will show you a pink color vertical draggable line. Before the pink line all signals disappear. Only after that you have to create an alert to take trade.
Date Filter
This filter is enabled to backtest from a specific date. But remember that date should not be beyond the unavailable candles on the chart. For Deep backtest you must use the tradingview premium plan feature in the strategy section.
Always unclick this option if you are trading via webhook
Time Management
Auto square off on click option available for NSE, NSE and MCX symbols, where mostly between 15:00 to 15:30 hours for NSE/BSE and 23:00 to 23:30 hours for MCX depending upon timeframe.
Upto two sessions you can set for trading: 0000 to 0000 means continue trading without any time restriction: Always set in 24 hour format. Input always shows in candles opening time instead of closing time.
Example
Trade timing : 09:30 - 15:00 (All entry and exit as per logic)
Squareoff timing : 15:00 – 15:30 (Only Exit happen at first candle close between 15:00 to 15:30, for 1 min TF it square off on 15:01, for 5 min TF 15:05 and for 15 min TF 15:15)
Algo Settings
Select broker : Dhan, Flattrade, 5Paisa,Anand Rathi, Delta Exchange
Instrument: Option, Future, Equity (What are you trading?)
For Future always use 1! (for current month) and 2! (for next month expiry) symbol chart (eg. NIFTY1! Or NIFTY2!)
Order type: Delivery (carry forward), Intraday ( Always set autosquare off of square off settings in time management). This selection also affects signals on the equity chart, Intraday shows both long and short signals while Delivery option shows only long side signals because in equity short trade is not allowed in delivery.
Quantity: for equity use no of shares that you what to trade, for future and options always use no of lot: enter 1 for 1 lot (please do not use lot size).
Client ID: You need to add client Id if you use broker Flattrade or Anand Rathi
Secret key from Json : Paste secret code for Dhan/Flattarde/Anand Rathi while strategy Id for delta exchange, no need of secret code for 5 paisa.
Secret code for Dhan: Order/Webhook/ Manage/ select webhook expiry/ creat webhook/ add any script/ creat json/ copy secret code from json without any inverted coma
Secret code from Flattrade: Order/webhook/login to creat webhook/ copy code from json (longer in character)
Strategy Id for Delta exchange: Algo/trading bot/Creat webhook/OTP-2FA-submit/ copy strategy id from json
https://deltaexchangeindia.freshdesk.com/support/solutions/articles/80001141030-tutorial-trading-view-automation-on-delta-exchange
Option settings
If you are trading options then select OPTION in instrument.
Option Buyer or seller: If you are option buyer then by default it is OPT BUYING
OPT BUYING: buy CE when long entry and buy PE when short entry on index chart, while it shows only long trades on option premium chart
OPT SELLING: sell PE when long entry and sell CE when short entry on index chart, while it shows only short trade on option premium chart
BOTH: This option is only used when you want to trade both long (Option Buying) and short signal (Option Selling) on option premium charts. Do not use on index chart; this is exclusively for option premium chart.
Strike selection : ATM : At the money, OTM: out of the Money (low Premium), ITM : In the money (Higher Premium)
You can trade the strike in multiple of your choice like in Nifty strike difference is 50 , but if dont want to trade 50 multiple strike 25850 or 25950 and you only want to trade 25800, 25900 then click on that option and enter strike difference 100.
Set expiry: for NSE and BSE according to instrument it has specific expiry day
Current Auto Expiry : Nearest expiry date (tuesday for NSE and thursday for BSE) for nifty50 current week tuesday and for Banknifty Current month last tuesday.
Current week/Next week/Next to Next week : for Nifty50 only
Current Month: Monthly expiry for NSE and BSE
Next Month: Next Monthly Expiry for NSE and BSE
Manual Date Input : Select this option for MCX and delta exchange india as well as NSE/BSE if date is not accurate automatically function. Suppose any Tuesday expiry for NSE is on holiday then you must select Manual date input.
Manual Expiry date: When you select Manual Input Date in above option then only you can select particular date of option expiry.
Delay Entry order by approx seconds: This option exclusively for Future and equity where new entry and previous exit order fire at the same time which cause margin release issues and hence order rejected due to low margin. This option gives signals at the same time but fires order after some seconds. Minimum 5 seconds are set but according to your symbols liquidity increases seconds specifically in MCX market where more than 10 seconds is appropriate. Always monitor such trades.
Consent and disclaimer
Always click this option : 'Trading involves a risk of loss and may not appropriate for every one. Please consider carefully if trading is appropriate for you. Past performance is not indicative of future results. Any signals appear on chart are for education purpose only. This signals can be optimised by yourself changing the variables in the indicator\'s input tab on various instruments and timeframe. It is your responsibility knowing that by clicking you are accepting that indicator would trade on your behalf at your own risk. We are not SEBI registered.'
Show Monthly Performance Table
This option enable the Monthly Performance in table form where month wise profit and loss are showing (on index it shows in point form). Percentage in () depends upon initial capital set in the property tab. Various Statistical parameters are also seen in table like : % profitability, profit factor, No of trades (W winnings and L Lossing), Max Run-Up, Max Drawdown, Initial capital, Backtest Range. This data only shows that shows on strategy tester without any deep backtesting.
Show Small PNL Table
This option enables a small profit and loss table for today’s trade only (except the last candle close)
Show Algo Setting Details Table
This table enables you to show which settings have you done for automation and also guides if you select the wrong option showing in red background color. Symbols, instruments, broker, client id, secret key, position on chart, expiry date (most important for FNO) please verify this date with actual option chain expiry date. Wrong expiry date lead to no execution of trade.
Creat Alert for Automation
At the end of indicator on three dot click on “Add alert on Universal Signal Trading Tool : Single Target”. Which Creat on Pop-Out Page with three different tab:
Settings Message and Notifications
#Settings
Symbols : current symbol
Condition: Universal Signal Trading Tool : Single Target
Interval: Same as chart
#Message
Alert Name: Type your Custom alert name
Message: by default you will this message : {{strategy.order.alert_message}}
Please do not change this message, do not use any json message here
#Notifications
Click on webhook url : (Only available if you have Tradingview subscription and two factor authentication is done) paste brokers valid webhook here (Use only active webhook). Please do not use api webhook, use only tradingview webhook separately available for tradingview User’s broker account.
Play sound as per your need
How to update an alert?
Once you create an alert on the current indicator and current chart with the same timeframe then green color watch you can see next to indicator name on chart. If green watch does not appear then the current indicator setting/symbol/timeframe is different from the setting in alert.
So if you have made any changes then you must update the alert.
See the right top side of the alert in the alert section: pause/ restart, edit and delete option are available. Click on edit option then pop-up window will open, select appropriate symbol if it is different, in condition dropdown menu if indicator name shows two time means second name is the new settings, so select second indicator name and select timeframe as same as chart and then click ok. Check if the green watch appears or not.
Trouble shooting
Q : I am not able to see signals on chart?
Check initial capital on chart, increase zero at end if required.
Always unclick the backtest date filter.
Check entry exit external signal properly selected.
Q: Trade not executing on broker panel?
Is alert generated in alert log? If yes then check secret code, expiry date if trading FNO, valid webhook and symbols. If No then update your alert.
Q: Order fails at broker?
Click on the failed order and see the reason and approach us via message on tradingview.
Note: Strategy used in the above strategy is only for example and demonstration purpose. It does not indicate to use the same strategy.
Results shown here are using the supertrend indicator (attached to this script as external indicator) with ATR length 1 and factor 30 on Nifty 50 index chart on 5 minute timeframe.
Always use your own criteria, risk management and proper backtesting before using the live capital. Do not go for blind trading, always monitor the automated trade in synchronization. Any misbehave by system or technical glitches leads to unwanted loss. So, think first, practice and go according to your analysis.
Your feedback and reporting any kind of bug is appreciable. Please reach us via message, comment or communication method available in our profile.
Skrip jemputan sahaja
Hanya pengguna disahkan oleh penulis boleh mengakses skrip ini. Anda perlu memohon dan mendapatkan kebenaran untuk menggunakannya. Keizinan selalunya diberikan selepas pembayaran. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi MAURYA_ALGO_TRADER secara terus.
TradingView TIDAK menyarankan pembayaran atau penggunaan skrip kecuali anda mempercayai sepenuhnya penulis dan memahami bagaimana ia berfungsi. Anda juga boleh menjumpai alternatif sumber terbuka dan percuma yang lain di dalam skrip komuniti kami.
Arahan penulis
WhatsApp : +916351098498
Penafian
Skrip jemputan sahaja
Hanya pengguna disahkan oleh penulis boleh mengakses skrip ini. Anda perlu memohon dan mendapatkan kebenaran untuk menggunakannya. Keizinan selalunya diberikan selepas pembayaran. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi MAURYA_ALGO_TRADER secara terus.
TradingView TIDAK menyarankan pembayaran atau penggunaan skrip kecuali anda mempercayai sepenuhnya penulis dan memahami bagaimana ia berfungsi. Anda juga boleh menjumpai alternatif sumber terbuka dan percuma yang lain di dalam skrip komuniti kami.
Arahan penulis
WhatsApp : +916351098498