TradingView
TZack88
8 jul 2023 00:21

Risk to Reward - FIXED SL Backtester 

LDO / TetherUSBinance

Beskrivning

Don't know how to code? No problem! TradingView is an excellent platform for you. ✅ ✅

If you have an indicator that you want to backtest using a risk-to-reward ratio or fixed take profit/stop loss levels, then the Risk to Reward - FIXED SL Backtester script is the perfect solution for you.

introducing Risk to Reward - FIXED SL Backtester Script which will allow you to test any indicator / Signal with RR or Fixed SL system

How does it work ?!

Once you connect the script to your indicator, it will analyze your entry points and perform calculations based on them. It will then open trades for you according to the specified inputs in the script settings.

HOW TO CONNECT IT to your indicator?

simply open your indicator code and add the below line of code to it
plot(Signal ? 100 : 0,"Signal",display = display.data_window)




Replace Signal with the long condition from your own indicator. You can also modify the value 100 to any number you prefer. After that, open the settings.



Once the script is connected to your indicator, you can choose from two options:

  • Risk To Reward Ratio System
  • Fixed TP/ SL System




🔸if you select the Risk to Reward System ⤵️

The Risk-to-Reward System requires the calculation of a stop loss. That's why I have included three different types of stop-loss calculations for you to choose from:

  • ATR Based SL
  • Pivot Low SL
  • VWAP Based SL


Your stop loss and take profit levels will be automatically calculated based on the selected stop loss method and your risk-to-reward ratio.
You can also adjust their values to match your desired risk level. The trades will be displayed on the chart.

with the ability to change their values to match your risk.
once this is done, trades will be displayed on the chart

🔸if you select the Fixed system ⤵️

You have 2 inputs, which are FIXED TP & Fixed SL
input the values you want, and trades will be on your chart...


I have also added a Breakeven feature for you.
with this Breakeven feature the trade will not just move SL to Entry ?! NO NO, it will place it above entry by a % you input yourself, so you always win! 🚀



Here is an example



Enjoy, and have fun, if you have any questions do not hesitate to ask
Kommentarer
tradingaccount7777777
Hey mate, thanks a lot. I would have two things: 1) Could you please also make it for short positions 2) It doesn't work on futures like ES, NQ.
Thanks
trade4life_de
I tested your tool with the RSI, but I do not understand what exactly is being tested here.. Can I test - for example - to buy when the RSI is below 30?
TZack88
@trade4life_de,
this is a backtester to your premade signals

if you have an indicator which produce signals , this backtester will test it with Risk to reward ratio or Fixed TP , so you know if this signal is profitable or not
bluemua456
tks for your share
mneveu
getting an error once i paste your code in
"Undeclared identifier 'display.data_window'"
ideas?
TZack88
@mneveu,

YOUR indicator is not version 5

convert it to version 5 or use the following code
plot(Signal ? 100 : na,"Signal")
zpeach
Great script. Kind of mind blowing! Really appreciate you posting this!! Could you accommodate Shorts in the future?
TZack88
@zpeach,

Hey , thanks for your comment , yes i will add this to my to do list , glad you like the script
immoz1
@TZack88, Hi.. Thanks for great script. Did you btw added yet the short script?
has001u
When you have a moment could you add it to your RSI momentum indicator? It would give us 'No-coders' a visual model to work from. Thanks either way. I enjoy your work!
Mer