3C QFL Mean reversal

Kveie Zaktualizowano   
What is QFL trading strategy?

QFL stands for Quickfingersluc, and sometimes it is referred to as the Base Strategy or Mean Reversals. Its main idea is about identifying the moment of panic selling and buying below the base level and utilizing Safety orders.

What is Base level or Support Level?

Base level or Support Level refers to the lowest price level that was reached before the moment the price started increasing again. At that level, you can notice that buyers of some cryptocurrencies make a strong reaction.

In this strategy we can also reverse the strategy and go short. But i must warn you that that is alot riskier.

QFL is meant to be used on higher TF's like 1hr, 2hr and 4hr. But this strategy also work well on lower Timeframes.

The script also simulates DCA strategy with parameters used in 3commas DCA bots for futures trading.
Experiment with parameters to find your trading setup.

Beware how large your total leveraged position is and how far can market go before you get liquidated!
Do that with the help of futures liquidation calculators you can find online!


An internal average price and profit calculating, instead of TV`s native one, which is subject to severe slippage.
A graphic interface, so levels are clearly visible and back-test analyzing made easier.
Long & Short direction of the strategy.
Table display a summary of past trades
Vertical colored lines appear when the new maximum deviation from the original price has
been reached
All the trading happens with total account capital, and all order sizes inputs are expressed in percent.
Informacje o Wersji:
Minor polishing on the code
Informacje o Wersji:
Added 3 commas connector

How to use:
- Add the script to the current chart
- Open the strategy settings
-Tweak the settings to to your liking.
-Make a SIMPLE bot in 3commas and use the same settings as you did in tradingview. The strategy will only send signal to start the deal and 3 commas will handle the rest. (I will look into the script making entry, safety and deal close later)
- Insert bot details using the deal start condition message found in your 3commas bot.
- When happy, right click on the "..." next to the study name, then "Add alert'".
- Under "Condition", on the second line, chose "Any alert () function call". Add the webhook from 3commas( 3commas.io/trade_signal/trading_view ), give it a name, and "create".

Since this is a strategy script you will get alerts every time a buy or sell signal is plotted, but dont worry the script will send only one signal to 3commas. So as long you have deal running it will not open another.
If anyone have a solution to the alert not sending a message evry time a signal is plotted give me a heads up :)
Informacje o Wersji:
Last update showed a chart layout without trades
Informacje o Wersji:
Pretty huge update from last time.
- Updated the backtester, so that you can use whatever BO and SO you want. PNL will be based of max allocation. (Remember to use leverage calculator if trading futures, will look to add it in this script)

- Stoploss is added.(Must be below last safety to trigger)

- Added support for Take Profit Type: "From Base order" (fixed amount based on BO size) and "From Total Volume" (Amount increases as more SO are placed)

- Added a table with DCA Settings for easier overview on the chart (Off by default it needs to be enabled in Settings)

- Safety order command for 3commas bot. This is implemented using Add funds in the quote currency (for pair eg. BTCUSDT the quote currency is USDT)
The SO size is calculated using the configuration of steps, for exact order size (and price) use the built-in Steps table. IMPORTANT! This only works on spot. If you trade futures check only "deal start" and configure rest in 3commas as before.
Because of this i had to update the 3commas connector.

- Fixed bug where safety would only be placed on next candle.

Overview of the script features:

- Because of Tradingview limitations on how orders are grouped into Trades, this Strategy statistics are calculated by the script, so please ignore the Strategy Tester statistics completely
Statistics Table explained:
- Status: either all deals are closed or there is a deal still running, in which case additional info
is provided below, as when the deal started, current PnL , current SO
- Finished deals: Total number of closed deals both Winning and Losing.
A deal is comprised as the Base Order (BO) + all Safety Orders (SO) related to that deal, so this number
will be different than the Strategy Tester List of Trades
- Winning Deals: Deal ended in profit
- Losing deals: Deals ended with loss due to Stop Loss. In the future I might add a Deal Stop condition to
the script, so that will count towards this number as well.
- Total days ( Max / Avg days in Deal ):
Total Days in the Backtest given by either Tradingview limitation on the number of candles or by the
config of the script regarding "Limit Date Range".
Max Days spent in a deal + which period this happened.
Avg days spent in a deal.
- Required capital: This is the total capital required to run the Backtester and it is automatically calculated by
the script taking into consideration BO size, SO size, SO volume scale. This should be the same as 3commas.
This number overwrites strategy.initial_capital and is used to calculate Profit and other stats, so you don't need
to update strategy.initial_capital every time you change BO/SO settings
- Profit after commission
- Buy and Hold return: The PnL that could have been obtained by buying at the close of the first candle of the
backtester and selling at the last.
- Covered deviation: The % of price move from initial BO order covered by SO settings
- Max Deviation: Biggest market % price move vs BO price, in the other direction (for long
is down, for short it is up)
- Max Drawdown: Biggest market % price move vs Avg price of the whole Trade (BO + any SO), in the other
direction (for long price goes down, for short it goes up)
This is calculated for the whole Trade so it is different than List of Trades
- Max / Avg bars in deal
- Total volume / Commission calculated by the strategy. For correct commission please set Commission in the
Inputs Tab and you may ignore Properties Tab
- Close stats for deals: This is a list of how many Trades were closed at each step, including Stop Loss (if
configured), together with covered deviation for that step, the number of deals, and the percentage of this
number from all the deals

- Settings Table that can be enabled / disabled just to have an overview of your configs on the chart, this is a
drawn on bottom left

- Steps Table similar to 3commas, this is also drawn on bottom left, so please disable Settings table if you want
to see this one

- Base order and safety orders configs similar to 3commas (order size, percent deviation, safety orders,
percent scale and volume scale)

- Long and Short

- Stop Loss

- Support for Take profit from base order or from Total volume of the deal

- Configs help (besides self explanatory):
- Chart theme: Adjust according to the theme you run on. There is no way to detect theme at the moment.
This adjust different colors
For example you could start a deal when Volume is greater than xxxx, or code a custom indicator that plots
different values based on your conditions and test those values
- Visuals / Decimals for display: Adjust according to your symbol
- BO Entry Price for steps table: This is the BO start deal price used to calculate the steps in the table

Please let me know if you encounter any bugs, or you have suggestions for improvments.
Informacje o Wersji:
Fixed(hopefully) a bug in the 3commas connector
Informacje o Wersji:
Should work now

remember to enter {{strategy.order.alert_message}} in the message field
Informacje o Wersji:
Fixed major bug causing shorts starting from the wrong base.
Thanks to @OutsourcE for bringing it to my attention.

Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?