Risk to Reward - FIXED SL BacktesterDon'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
Breakeven
Breakeven Line DemoPlug the breakeven line code into the bottom of your strategy to get visualization of your breakeven price. Line is green when net position is long, red when net short and invisible when strategy is risk neutral. Most useful for strategies which use pyramiding (successive entries in same direction stacked upon each other) as it can be difficult to track where prices needs to return to to allow closing in profit. Disclaimer: the strategy logic is garbage do not use it. It is only there so you can see how Breakeven Line logic is implemented.
[Fedra Algotrading Strategy]English / Spanish
Algotrading strategy optimized for cryptocurrencies. Originally conceived to trade automatically through bots (that's how I use it), it also works to get signals and trade manually in any exchange.
It works in spot. It does not repaint. Works in 15M, 30M, 1H and 4H (I prefer short periods).
Features:
Buy the dip:
Attempts to buy on the dip, finding entries when the price makes abrupt dips that break the linear regression of the last periods (default 40).
Trailing Take Profit:
Once the percentage established for the take profit is reached, the strategy follows the price if it is rising until it stops rising and only then makes the sale.
Trend Detection:
Determines whether the market is in an uptrend or downtrend by crossing 2 SMAs. This affects the performance of the strategy. This works as a filter to avoid making entries in a downtrend.
Trailing Break Even:
If the market enters a downtrend with an open trade, a Trailing Break Even is triggered, (configurable, default 1.5%). The intention is to close the trade as soon as possible, but without losses. The value of 1.5% is intended to cover commission costs and a possible spread. Like the Take Profit, the Trailing Break Even follows the price as it rises until it stops doing so before closing the trade.
How to use this strategy?
In the properties of the strategy you assign the amount you will trade (default 100), the percentage of the total capital you will use in each trade (default 100%) and the value of the commissions (default 1%).
Select the pair to trade. The strategy is optimized for trading pairs with stable coins. The strategy benefits from volatility so choosing among currencies with a market cap between 50M and 10,000M gives better profits than with top 10 currencies.
In the strategy options, disable the stoploss by setting it to 100% to be able to concentrate on the Take Profit.
With an eye on the "Net Profit" of the strategy, start with the take profit at 3% (for lower percentages there is the Break Even) and increase it 1 by 1 until determining which is the best for our pair (the one that gives us a better net profit).
Once the Take Profit is established, enable the StopLoss starting from 1 and choosing the best parameter looking for the balance that makes us feel comfortable between the Net Profit and the total of closed operations.
Test this same with candles of different periods (I trade with 15M and 30M candles).
Tip:
To trade automatically using a bot, I recommend using pairs in which the strategy has a profitability higher than 80%.
To counteract possible overfitting, when the strategy has given me a 30% profit, I recalculate the optimal parameters.
If you are interested in auromatizing it to trade on Binance, Binance US, AAX, Kucoin, Liquid, Okex, Bitfinex, Bittrex, Coinbase Pro, Gemini, HitBTC, Kraken or Poloniex, I recommend using Quadency bots, they are free and the ones I use.
This will eventually be a paid script, but you can request free access for now.
I am still working on optimizations, improvements, and more features.
DCA version coming soon.
I leave some optimizations of the spares I am trading at the moment (On 15M candles):
PAIR SL TP Bars Profit Profit Rentability
OM 3 4 96 70 2703.41% 88.57%
NU 4 3 96 81 1170.38% 86.42%
ONE 4 4 192 83 756% 91.57%
FTM 8 4 192 80 900.00% 92.50%
LUNA 3 8 192 78 410.98% 83.33%
OMG 6 4 192 72 408.75% 88.89%
FRONT 2 5 96 61 406% 85.25%
SOL 5 10 96 84 381.78% 83.33%
UTK 2 4 192 59 520.00% 88.06%
NMR 2 3 96 76 279% 80.26%
STPT 1 4 96 84 272.34% 79.76%
ROSE 5 4 96 59 478.00% 88.00%
clv 4 5 192 46 216% 78.26%
XTZ 4 6 96 87 216.00% 82.76%
C98 1 6 96 36 184.46% 80.56%
ALGO 7 4 192 61 222.00% 88.52%
ATOM 6 4 96 73 160.40% 86.30%
DOT 3 6 96 75 156.54% 84%
REEF 4 4 96 67 154.90% 85.07%
AUDIO 10 5 192 62 128.48% 83.87%
DYDX 1 10 96 20 120.76% 90%
DOT 4 6 96 77 111.33% 83.12%
KEEP 7 5 96 69 110% 87%
MINA 7 6 96 23 100.29% 86.96%
OPUL 1 5 96 18 95.26% 100%
HBAR 1 3 192 76 91.82% 81.58%
VRA/USDT 7 4 96 81 89.35% 81.48%
XEC 3 14 96 27 89.24% 85.19%
*****************************************************SPANISH*****************************************
Estrategia de Algotrading optimizada para criptomonedas. Originalmente concebida para operar de manera automática mediante bots (así la utilizo yo), funciona también para obtener señales y operar manualmente en cualquier exchange.
Funciona en spot. No repinta. Funciona en 15M, 30M, 1H y 4H (Yo prefiero periodos cortos)
Características:
Buy the dip:
Intenta comprar en el dip, encontrando entradas cuando el precio hace bajadas abruptas que rompen la regresión lineal de los últimos periodos (por defecto 40)
Trailing Take Profit:
Una vez alcanzado el porcentaje establecido para el take profit, la estrategia acompaña al precio si está en ascenso hasta que deja de subir y recién ahí realiza la venta.
Detección de Trend:
Determina si el mercado tiene una tendencia alcista o bajista mediante el cruce de 2 SMAs. Esto afecta el funcionamiento de la estrategia. Esto funciona como filtro para evitar realizar entradas en una tendencia bajista.
Trailing Break Even:
Si el mercado entra en tendencia bajista con una operación abierta, se activa un Trailing Break Even, (configurable, por defecto 1.5%). La intención es cerrar la operación lo antes posible, pero sin pérdidas. El valor de 1.5% está pensado para cubrir los costos de comisiones y un posible spread. Al igual que el Take Profit, El Trailing Break Even acompaña al precio mientras sube hasta que deja de hacerlo antes de cerrar la operación.
Cómo utilizar esta estrategia?
En las propiedades de la estrategia se le asigna el monto con el que va a operar (por defecto 100), el porcentaje del total de capital que utilizará en cada operación (por defecto 100%) y el valor de las comisiones (por defecto 1%)
Seleccionar el par a operar. La estrategia está optimizada para operar en pares con stablecoins. La estrategia se beneficia con la volatilidad por lo que elegir entre las monedas con un market cap de entre 50M y 10.000M da mejores beneficios que con monedas del top 10
En las opciones de la estrategia, deshabilitar el stoploss configurándolo en 100% para poder concentrarnos en el Take Profit.
Con un ojo en el “Beneficio Neto” de la estrategia, comenzar con el take profit en 3% (para porcentajes menores está el Break Even) e ir aumentándolo de 1 en 1 hasta determinar cuál es el mejor para nuestro par (el que nos proporciona un major beneficio neto).
Establecido el Take Profit, habilitar el StopLoss partiendo de 1 y eligiendo el mejor parámetro buscando el equilibrio que nos haga sentir cómodos entre el Beneficio Neto y el total de operaciones cerradas.
Probar esto mismo con velas de diferentes periodos (Yo opero con velas de 15M y 30M)
Consejo:
Para operar de manera automática mediante un bot, recomiendo utilizar pares en los que la estrategia tenga una rentabilidad superior al 80%
Para contrarestar posible overfiting, cuando la estrategia me ha dado un 30% de profit, vuelvo a calcular los parámetros óptimos.
Si te interesa auromatizarla para operar en Binance, Binance US, AAX, Kucoin, Liquid, Okex, Bitfinex, Bittrex, Coinbase Pro, Gemini, HitBTC, Kraken o Poloniex, recomiendo usar los bots de Quadency, son gratiutos y los que yo utilizo.
Este será eventualmente un script pago, pero puedes solicitar acceso gratuito por ahora.
Sigo trabajando en optimizaciones, mejoras, y más funciones.
Próximamente versión DCA.
Dejo algunas optimizaciones de lo spares que yo estoy operando en este momento (En velas de 15M contra BUSD):
PAR SL TP Bars Operaciones Profit Rentabilidad
OM 3 4 96 70 2703.41% 88.57%
NU 4 3 96 81 1170.38% 86.42%
ONE 4 4 192 83 756% 91.57%
FTM 8 4 192 80 900.00% 92.50%
LUNA 3 8 192 78 410.98% 83.33%
OMG 6 4 192 72 408.75% 88.89%
FRONT 2 5 96 61 406% 85.25%
SOL 5 10 96 84 381.78% 83.33%
UTK 2 4 192 59 520.00% 88.06%
NMR 2 3 96 76 279% 80.26%
STPT 1 4 96 84 272.34% 79.76%
ROSE 5 4 96 59 478.00% 88.00%
clv 4 5 192 46 216% 78.26%
XTZ 4 6 96 87 216.00% 82.76%
C98 1 6 96 36 184.46% 80.56%
ALGO 7 4 192 61 222.00% 88.52%
ATOM 6 4 96 73 160.40% 86.30%
DOT 3 6 96 75 156.54% 84%
REEF 4 4 96 67 154.90% 85.07%
AUDIO 10 5 192 62 128.48% 83.87%
DYDX 1 10 96 20 120.76% 90%
DOT 4 6 96 77 111.33% 83.12%
KEEP 7 5 96 69 110% 87%
MINA 7 6 96 23 100.29% 86.96%
OPUL 1 5 96 18 95.26% 100%
HBAR 1 3 192 76 91.82% 81.58%
VRA/USDT 7 4 96 81 89.35% 81.48%
XEC 3 14 96 27 89.24% 85.19%
Plot Break-even PriceThis indicator simply plots your entry price and the break-even point (green line). Area between the entry price and the break-even point will “eat” you profit by exchange fees. You can use the green line to lock your break-even point. I do not recommend using this strategy for trading, because the entry logic is based on SMA crosses. However, this script could be used within you own strategy to plot the break-even point.
For example, there is 0.1% Maker fee and 0.1% Taker fee at Binance spot exchange. You need to sum up those two fees to calculate the break-even point. Every exit above/below the green line will guarantee a profit (in our case it means 0.2% above the entry price for long position and 0.2% below the entry price for short position).
Jeremy: Candle StrategyPrice action strategy developed for a Backtest Rookies service customer. Published for verification and acceptance.
Please visit the Backtest Rookies website if you are interested in Development services
Features
Hammer / Hanging man candle detection with variable inputs
2 position entries
2 different SL and TP ratios
Custom position sizing algorithm
Move the second position to break even once the first take profit is hit