R3c0nTrader

Dual Fibonacci Zone & Ranged Vol DCA Strategy - R3c0nTrader

What does this do?
This is for educational purposes and allows one to backtest two Fibonacci Zones simultaneously. This also includes an option for Ranged Volume as a parameter.

Pre-requisites:
First off, this is a Long only strategy as I wrote it with DCA in mind. It cannot be used for shorting. Shorting defeats the purpose of a DCA bot which has a goal that is Long a position not Short a position. If you want to short, there are plenty of free scripts out there that do this.

You must have some base knowledge or experience with Fibonacci trading, understanding what is ADX , +DI (and -DI ), etc.

You can use this script without a 3Commas account and see how 3Commas DCA Bot would perform. However, I highly recommend inexperienced uses get a free account and going through the tutorials, FAQ's and knowledgebase. This would give you a base understanding of the settings you will see in this strategy and why you will need to know them. Only then should you try testing this strategy with a paper bot.

Background
After I had created and released "Fibonacci Zone DCA Strategy", I began expanding and testing other ideas.
The first idea was to add Ranged Volume to the Fibonacci Zone DCA strategy which I wanted for providing further confirmation before entering a trade. The second idea was to add a second Fibonacci Zone that was just as configurable as the first Fibonacci Zone. I managed to add both and they can be easily enabled or disabled via the strategy settings menu.

Things Got Real Interesting
Things got real interesting when I started testing strategies with two Fibonacci zones. Here's a quick list of what I found I was able to do:
Mix and match exit strategies. I could set the Fib-1 zone strategy to exit with a take profit % and separately set the Fib-2 zone strategy to exit when the price crosses the top-high fib border

Trade the trend. A common phrase amongst traders is "the Trend is your friend" and with the help of an additional Fib Zone, I was able to trade the trend more often by using two different Fib Zone strategies which if configured properly can shorten time to re-deploy capital, increase number of closed trades, and in some cases increase net profit.
Trade both bull market uptrends and bear market downtrends in the same strategy. I found I could configure one Fib Zone strategy to be really good in uptrends and another Fib Zone strategy to be really good in downtrends. In some cases, with both Fib Zone strategies enabled together in a single strategy I got better results than if the strategies were backtested separately.


There are many other trade strategies I am finding with this. One could be to trade a convergence or divergence of the two different Fib Zones. This could possibly be achieved by setting one strategy to have different Fibonacci length.

Credits:
Thank you "EvoCrypto" for granting me permission to use "Ranged Volume" to create this strategy
Thank you "eykpunter" for granting me permission to use "Fibonacci Zones" to create this strategy
Thank you "junyou0424" for granting me permission to use "DCA Bot with SuperTrend Emulator" which I used for adding bot inputs, calculations, and strategy
הערות שחרור: Fib Stoploss options were in reverse order when compared to the Entry and Exit options. They now all have the same order for Fib borders.
Fixed issue where if Fib-1 zone strategy was set to exit at Top-High fib border and Fib-2 set to exit at Top-Center fib border, an order started with Fib-1 would exit with Fib-2's Exit at Top-Center fib border instead of Fib-1 Top-High fib border.
Since this changes the calculation for trade exits, using this updated version could greatly change some backtest results and would require new backtests to determine what the new settings should be.
In the example I gave, the solution would be to change Fib-1 zone strategy Exit setting from using the Top-High fib border to instead use the Top-Center Fib border since it was exiting at that point prior to the update.
הערות שחרור: Fixed fib-2 zone take profit calculation
הערות שחרור: Added options for specifying the "Min -DI value to open trade" and "Max -DI value to open trade" to both the 1st and 2nd Fibonacci trade entry settings. (Recommend using TradingView's built-in DMI indicator for viewing the +DI and -DI values)
הערות שחרור: Minor update: Corrected group for Fib Based Stop Loss settings.
הערות שחרור: Updates:
Added option for specifying the "Max ADX value" to both Fib-1 and Fib-2 zone trade entry settings.
Updated several tooltips.
Minor code optimizations and standardizations.

Example of using the Min and Max settings for ADX, +DI, and -DI:

הערות שחרור: No impactful updates. Performed code cleanup.
הערות שחרור: Updates:
Fixed issue with Fib-1 strategy's take profit when Fib-2 strategy was enabled.
Fixed issue with Fib-2 strategy's ADX min/max input values not being used correctly.
Cleaned up code.
הערות שחרור: New Features in this update:
1. Added new emojis (as icons) to the Input Menu and Chart for quicker, easier, visual cues (Menu didn't have any visual cues)
a. Fib-1 is the First Place Medal
b. Fib-2 is the Second Place Medal
c. Trailing deviation is the Traffic Light
d. Fib-Based Stop Loss is the Stop sign
e. Take Profit is the money bag
2. Added feature to remove the bar coloring If Ranged Volume is disabled and use standard candle colors instead. The custom Ranged Volume colors will only appear if it is enabled.
3. Added input for Fib-2 trailing deviation. Can now setup 2 different trailing deviations, one for each Fib Zone strategy!
4. Added option for Fib-2 Fib-Stop Loss. Can now setup 2 different Fib-Stob Losses, one for each Fib Zone strategy!
5. When "Trailing Deviation" is used, the following lines will now appear on the chart (these can be disabled in 'Style' Menu):
Original TTP value = White line showing the original target take profit value
Stop Value = Red line which follows the price based on the trailing value and is used to help calculate the trailing stop. If the price moves up, this pushes the yellow Trailing Stop Loss line up.
Trailing Stop Loss = Yellow line showing the trailing stop loss.
6. Updated comments on chart for when the trade closes to include the which Fib strategy was closed (Fib-1 or Fib-2). This makes it easier to see which Fib zone strategy closed, especially for trades that have a long hold time. No longer need to scroll to the beginning of the trade.

Fixed Issues in this update:
1. Fixed issue with Fib-2 strategy using Fib-1's ADX setting
2. Fixed trades not closing according to specified trailing deviation % ; Found trades were closing far later than they should be. Researched new calculation to fix this.
3. Fixed issue where sometimes no trades are shown and only the orange Avg Price line appears.
הערות שחרור: Fixed issue where sometimes the safety order opened after the trade was supposed to be closed.
Depending on what strategy was being used and how close the take profit was to the SO condition, this issue could have appeared during a back test.
Study script was not showing same issue and did not see any indication of it.
הערות שחרור: New Features in this update:
1. Added 3Commas webhook to the strategy which can be used for sending Buy and Sell signals to a 3Commas bot. No longer have to use the study script. All you need is your "bot id" and your "email token." To get these go to your 3Commas bot settings and expand the "Message for deal start signal." Both should be listed there.
a. c. (You can still use the study script if you can't figure out how to setup the webhook or you just like doing it the old way. I know I still do on most of my bots. Eventually though I will likely migrate these to the webhook as it is easier to setup.)
2. Speaking of which, if it is now easier to see if your "Strategy" settings and your "Study" settings are lined correctly. Added the same Green and Red background color option to the strategy for all buys and sells. This way you can tell very quickly if something is not set correctly.
a. 3. Updated the comment for the trades closed by trailing to include both the price and the PnL percentage

Fixed Issues in this update:
1. Updated the Fib-Based Stop Loss routine to fix issue where sometimes Fib-2 zone strategy was using Fib-1's Fib-based stop loss.
2. On lower time frames, fixed issue where sometimes Fib-1 and Fib-2 zones appeared to open a trade on the same candle.
3. Fixed issue where sometimes the white and red lines for the trailing stop would continue to be drawn past the take profit point.
4. Added code to make sure additional variables are zeroed out after trades are closed to prevent issues with trades not closing when a different strategy opens the next trade (this was a result of adding the above "fix" which was needed)
הערות שחרור: New Feature:
Added option to select the 3commas bot type (Simple or Composite)

Fixes:
Fixed issue when 3Commas webhook was used and the sell alerts would not send during a regular closing of the trade (meaning no trailing enabled or stop loss enabled). Other closing types like Trailing close and Fib-based Stop Loss do not appear to be affected.
הערות שחרור: Updating Chart
הערות שחרור: Update:
Fixed trailing deviation. Somehow it broke after adding new features in last update.
הערות שחרור: Corrected labels for "Bear Trap Close"
הערות שחרור: Update:
Increased max label count to 500!
הערות שחרור: Updates:
Corrected PnL Percent calculation. (It was showing the wrong values but should now show the proper values. Verified by measuring on the chart)
Added PnL Percent value to all labels for closing trades.
Truncated values in labels and trade text on chart so values fit better.
הערות שחרור: Fixed bug with "Long Entry Labels" not reflecting the user input for what was selected for "sourceInput." This did not affect the trade entry just the what was shown in the labels. The non-label comments (if you unchecked option for showing labels) on the chart were set correctly and showing the proper values.
הערות שחרור: New Features
Added feature to limit trade entries to minimum volume amount and/or Volume MA

Added feature to limit trade entry based on RSI level (this currently uses Fib-1's source input and applies to both Fib-1 and Fib-2 strategies; If your Fib-1 and Fib-2 strategy both use the same source input like the "close" you shouldn't have any issues. If Fib-2 is using a different source input (e.g HL2) then keep in mind this RSI setting is will be using Fib-1's source input (e.g. "close")

Added options to open/exit trades faster and not wait for candle close. Enable this if you do not want to wait for a closing candle to open/exit a trade. The candle's high or low value will be used instead (the wick will be the trigger). Will use the appropriate high/low signal based what you selected for Fib entry (Crosses, Crosses up, Crosses down). Can be useful if a bot is opening/exiting trades slower than you would like.

Add optioned to enable/disable Repainting on entire Dual Fib Zone Strategy

Fixes
Updated Labels to showing which SO was triggered

Update chart comments for SO's to show which strategy the SO was triggered

Added extra space to trade exit comments. Example: "Fib-1Close @" , change to "Fib-1 Close @"

Removed "use_bar_magnifier=true" as it is a Premium User only feature. Script still works fine without it.

Fixed "fb_tp_condition" and "fb_tp_condition_2" not being used for taking profit. Was disabled in older update to fix a bug. Has now been re-enabled.

Updated Bull and Bear Trap to close to use the appropriate source input based on the active strategy (Fib-1 or Fib-2) and a different value if re-painting was disabled.
Updated many input options to have a "minval" parameter set and prevent entry of invalid values.

Fixed Fib-based stop loss for Fib-2 which was set to use Fib-1's "sourceInput" instead of Fib-2 "sourceInput_2"; this would only be noticed if a different source for Fib-2 was used than Fib-1

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?