Martingale + Grid DCA Strategy [YinYangAlgorithms]This Strategy focuses on strategically Martingaling when the price has dropped X% from your current Dollar Cost Average (DCA). When it does Martingale, it will create a Purchase Grid around this location to likewise attempt to get you a better DCA. Likewise following the Martingale strategy, it will sell when your Profit has hit your target of X%.
Martingale may be an effective way to lower your DCA. This is due to the fact that if your initial purchase; or in our case, initial Grid, all went through and the price kept going down afterwards, that you may purchase more to help lower your DCA even more. By doing so, you may bring your DCA down and effectively may make it easier and quicker to reach your target profit %.
Grid trading may be an effective way of reducing risk and lowering your DCA as you are spreading your purchases out over multiple different locations. Likewise we offer the ability to ‘Stack Grids’. What this means, is that if a single bar was to go through 20 grids, the purchase amount would be 20x what each grid is valued at. This may help get you a lower DCA as rather than creating 20 purchase orders at each grid location, we create a single purchase order at the lowest grid location, but for 20x the amount.
By combining both Martingale and Grid DCA techniques we attempt to lower your DCA strategically until you have reached your target profit %.
Before we start, we just want to make it known that first off, this Strategy features 8% Commission Fees, you may change this in the Settings to better reflect the Commission Fees of your exchange. On a similar note, due to Commission Fees being one of the number one profit killers in fast swing trade strategies, this strategy doesn’t focus on low trades, but the ideology of it may result in low amounts of trades. Please keep in mind this is not a bad thing. Since it has the ability to ‘Stack Grid Purchases’ it may purchase more for less and result in more profit, less commission fees, and likewise less # of trades.
Tutorial:
In this example above, we have it set so we Martingale twice, and we use 100 grids between the upper and lower level of each martingale; for a total of 200 Grids. This strategy will take total capital (initial capital + net profit) and divide it by the amount of grids. This will result in the $ amount purchased per grid. For instance, say you started with $10,000 and you’ve made $2000 from this Strategy so far, your total capital is $12,000. If you likewise are implementing 200 grids within your Strategy, this will result in $12,000 / 200 = $60 per grid. However, please note, that the further down the grid / martingale is, the more volume it is able to purchase for $60.
The white line within the Strategy represents your DCA. As the Strategy makes purchases, this will continue to get lower as will your Target Profit price (Blue Line). When the Close goes above your Target Profit price, the Strategy will close all open positions and claim the profit. This profit is then reinvested back into the Strategy, which may exponentially help the Strategy become more profitable the longer it runs for.
In the example above, we’ve zoomed in on the first example. In this we want to focus on how the Strategy got back into the trades shortly after it sold. Currently within the Settings we have it set so our entry is when the Lowest with a length of 3 is less than the previous Lowest with a length of 3. This is 100% customizable and there are multiple different entry options you can choose from and customize such as:
EMA 7 Crossover EMA 21
EMA 7 Crossunder EMA 21
RSI 14 Crossover RSI MA 14
RSI 14 Crossunder RSI MA 14
MFI 14 Crossover MFI MA 14
MFI 14 Crossunder MFI MA 14
Lowest of X Length < Previous Lowest of X Length
Highest of X Length > Previous Highest of X Length
All of these entry options may be tailored to be checked for on a different Time Frame than the one you are currently using the Strategy on. For instance, you may be running the Strategy on the 15 minute Time Frame yet decide you want the RSI to cross over the RSI MA on the 1 Day to be a valid entry location.
Please keep in mind, this Strategy focuses on DCA, this means you may not want the initial purchase to be the best location. You may want to buy when others think it is a good time to sell. This is because there may be strong bearish momentum which drives the price down drastically and potentially getting you a good DCA before it corrects back up.
We will continue to add more Entry options as time goes on, and if you have any in mind please don’t hesitate to let us know.
Now, back to the example above, if we refer to the Yellow circle, you may see that the Lowest of a length of 3 was less than its previous lowest, this triggered the martingales to create their grids. Only a few bars later, the price went into the first grid and went a little lower than its midpoint (Yellow line). This caused about 60% of the first grid to be purchased. Shortly after the price went even lower into this grid and caused the entire first martingale grid to be purchased. However, if you notice, the white line (your DCA) is lower than the midpoint of the first grid. This is due to the fact that we have ‘Stack Grid Purchases’ enabled. This allows the Strategy to purchase more when a single bar crosses through multiple grid locations; and effectively may lower your average more than if it simply executed a purchase order at each grid.
Still looking at the same location within our next example, if we simply increase the Martingale amount from 2 to 3 we can see something strange happens. What happened is our Target Profit price was reached, then our entry condition was met, which caused all of the martingale grids to be formed; however, the price continued to increase afterwards. This may not be a good thing, sure the price could correct back down to these grid locations, but what if it didn’t and it just kept increasing? This would result in this Strategy being stuck and unable to make any trades. For this reason we have implemented a Failsafe in the Settings called ‘Reset Grids if no purchase happens after X bars’.
We have enabled our Failsafe ‘Reset Grids if no purchase happens after X bars’ in this example above. By default it is set to 100 bars, but you can change this to whatever works best for you. If you set it to 0, this Failsafe will be disabled and act like the example prior where it is possible to be stuck with no trades executing.
This Failsafe may be an important way to ensure the Strategy is able to make purchases, however it may also mean the Grids increase in price when it is used, and if a massive correction were to occur afterwards, you may lose out on potential profit.
This Strategy was designed with WebHooks in mind. WebHooks allow you to send signals from the Strategy to your exchange. Simply set up a Custom TradingView Bot within the OKX exchange or 3Commas platform (which has your exchange API), enter the data required from the bot into the settings here, select your bot type in ‘Webhook Alert Type’, and then set up the alert. After that you’re good to go and this Strategy will fully automate all of its trades within your exchange for you. You need to format the Alert a certain way for it to work, which we will go over in the next example.
Add an alert for this Strategy and simply modify the alert message so all it says is:
{{strategy.order.alert_message}}
Likewise change from the Alert ‘Settings’ to Alert ‘Notifications’ at the top of the alert popup. Within the Notifications we will enable ‘Webhook URL’ and then we will pass the URL we are sending the Webhook to. In this example we’ve put OKX exchange Webhook URL, however if you are using 3Commas you’ll need to change this to theirs.
OKX Webhook URL:
www.okx.com
3Commas Webhook URL:
app.3commas.io
Make sure you click ‘Create’ to actually create this alert. After that you’re all set! There are many Tutorials videos you can watch if you are still a little confused as to how Webhook trading works.
Due to the nature of this Strategy and how it is designed to work, it has the ability to never sell unless there it will make profit. However, because of this it also may be stuck waiting in trades for quite a long period of time (usually a few months); especially when your Target Profit % is 15% like in the example above. However, this example above may be a good indication that it may maintain profitability for a long period of time; considering this ‘Deep Backtest’ is from 2017-8-17.
We will conclude the tutorial here. Hopefully you understand how this Strategy has the potential to make calculated and strategic DCA Grid purchases for you and then based on a traditional Martingale fashion, bulk sell at the desired Target Profit Percent.
Settings:
Purchase Settings:
Only Purchase if its lower than DCA: Generally speaking, we want to lower our Average, and therefore it makes sense to only buy when the close is lower than our current DCA and a Purchase Condition is met.
Purchase Condition: When creating the initial buy location you must remember, you want to Buy when others are Fearful and Sell when others are Greedy. Therefore, many of the Buy conditions involve times many would likewise Sell. This is one of the bonuses to using a Strategy like this as it will attempt to get you a good entry location at times people are selling.
Lower / Upper Change Length: This Lower / Upper Length is only used if the Purchase Condition is set to 'Lower Changed' or 'Upper Changed'. This is when the Lowest or Highest of this length changes. Lowest would become lower or Highest would become higher.
Purchase Resolution: Purchase Resolution is the Time Frame that the Purchase Condition is calculated on. For instance, you may only want to start a new Purchase Order when the RSI Crosses RSI MA on the 1 Day, but yet you run this Strategy on the 15 minutes.
Sell Settings:
Trailing Take Profit: Trailing Take Profit is where once your Target Profit Percent has been hit, this will trail up to attempt to claim even more profit.
Target Profit Percent: What is your Target Profit Percent? The Strategy will close all positions when the close price is greater than your DCA * this Target Profit Percent.
Grid Settings:
Stack Grid Purchases: If a close goes through multiple Buy Grids in one bar, should we amplify its purchase amount based on how many grids it went through?
Reset Grids if no purchase happens after X Bars: Set this to 0 if you never want to reset. This is very useful in case the price is very bullish and continues to increase after our Target Profit location is hit. What may happen is, Target Profit location is hit, then the Entry condition is met but the price just keeps increasing afterwards. We may not want to be sitting waiting for the price to drop, which may never happen. This is more of a failsafe if anything. You may set it very large, like 500+ if you only want to use it in extreme situations.
Grid % Less than Initial Purchase Price: How big should our Buy Grid be? For instance if we bought at 0.25 and this value is set to 20%, that means our Buy Grid spans from 0.2 - 0.25.
Grid Amounts: How many Grids should we create within our Buy location?
Martingale Settings:
Amount of Times 'Planned' to Martingale: The more Grids + the More Martingales = the less $ spent per grid, however the less risk. Remember it may be better to be right and take your time than risk too much and be stuck too long.
Martingale Percent: When the current price is this percent less than our DCA, lets create another Buy Grid so we can lower our average more. This will make our profit location less.
Webhook Alerts:
Webhook Alert Type: How should we format this Alert? 3Commas and OKX take their alerts differently, so please select the proper one or your webhooks won't work.
3Commas Webhook Alerts:
3Commas Bot ID: The 3Commas Bot ID is needed so we know which BOT ID we are sending this webhook too.
3Commas Email Token: The 3Commas Email Token is needed for your webhooks to work properly as it is linked to your account.
OKX Webhook Alerts:
OKX Signal Token: This Signal Token is attached to your OKX bot and will be used to access it within OKX.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
Dcastrategy
Grospector DCA V.4This is system for DCA with strategy and can trade on trend technique "CDC Action Zone".
We upgrade Grospector DCA V.3 by minimizing unnecessary components and it is not error price predictions.
This has 5 zone Extreme high , high , normal , low , Extreme low. You can dynamic set min - max percent every zone.
Extreme zone is derivative short and long which It change Extreme zone to Normal zone all position will be closed.
Every Zone is splitted 10 channel. and this strategy calculate contribution.
and now can predict price in future.
Idea : Everything has average in its life. For bitcoin use 4 years for halving. I think it will be interesting price.
Default : I set MA is 365*4 days and average it again with 365 days.
Input :
len: This input represents the length of the moving average.
strongLen: This input represents the length of the moving average used to calculate the strong buy and strong sell zone.
shortMulti: This input represents the multiplier * moveing average used to calculate the short zone.
strongSellMulti: This input represents the multiplier used to calculate the strong sell signal.
sellMulti: This input represents the multiplier * moveing average used to calculate the sell zone.
strongBuyMulti: This input represents the multiplier used to calculate the strong sell signal.
longMulti: This input represents the multiplier * moveing average used to calculate the long zone.
*Diff sellMulti and strongBuyMulti which is normal zone.
useDerivative: This input is a boolean flag that determines whether to use the derivative display zone. If set to true, the derivative display zone will be used, otherwise it will be hidden.
zoneSwitch: This input determines where to display the channel signals. A value of 1 will display the signals in all zones, a value of 2 will display the signals in the chart pane, a value of 3 will display the signals in the data window, and a value of 4 will hide the signals.
price: Defines the price source used for the indicator calculations. The user can select from various options, with the default being the closing price.
labelSwitch: Defines whether to display assistive text on the chart. The user can select a boolean value (true/false), with the default being true.
zoneSwitch: Defines which areas of the chart to display assistive zones. The user can select from four options: 1 = all, 2 = chart only, 3 = data only, 4 = none. The default value is 2.
predictFuturePrice: Defines whether to display predicted future prices on the chart. The user can select a boolean value (true/false), with the default being true.
DCA: Defines the dollar amount to use for dollar-cost averaging (DCA) trades. The user can input an integer value, with a default value of 5.
WaitingDCA: Defines the amount of time to wait before executing a DCA trade. The user can input a float value, with a default value of 0.
Invested: Defines the amount of money invested in the asset. The user can input an integer value, with a default value of 0.
strategySwitch: Defines whether to turn on the trading strategy. The user can select a boolean value (true/false), with the default being true.
seperateDayOfMonth: Defines a specific day of the month on which to execute trades. The user can input an integer value from 1-31, with the default being 28.
useReserve: Defines whether to use a reserve amount for trading. The user can select a boolean value (true/false), with the default being true.
useDerivative: Defines whether to use derivative data for the indicator calculations. The user can select a boolean value (true/false), with the default being true.
useHalving: Defines whether to use halving data for the indicator calculations. The user can select a boolean value (true/false), with the default being true.
extendHalfOfHalving: Defines the amount of time to extend the halving date. The user can input an integer value, with the default being 200.
Every Zone: It calculate percent from top to bottom which every zone will be splited 10 step.
To effectively make the DCA plan, I recommend adopting a comprehensive strategy that takes into consideration your mindset as the best indicator of the optimal approach. By leveraging your mindset, the task can be made more manageable and adaptable to any market
Dollar-cost averaging (DCA) is a suitable investment strategy for sound money and growth assets which It is Bitcoin, as it allows for consistent and disciplined investment over time, minimizing the impact of market volatility and potential risks associated with market timing
3Commas Bot DCA Backtester & Signals FREEThis is a DCA Strategy backtester + signals, built to emulate the 3Commas DCA bots. It uses your choice of 4 different buy signals, 2 of which can be adjusted in the settings. Everything is customizable so you can backtest specific settings with different buy signals and find the best performing strategy for your risk tolerance and capital. It can be used to backtest strategies on stocks as well, but just make sure your base order is larger than the share price for the entire backtesting range or it will not calculate properly.
You can use this template to code your own buy signals and then backtest them as a DCA strategy if you know some basic pine script.
The indicator shows all of your backtesting orders on the chart. The red line is your take profit level, the blue line is your average price level, the white line is your first order and the green lines are your average down orders. If you enable a stop loss in the settings your stop loss will be shown as an orange line once all of your average down orders have been hit, it will not be set until price has dipped below your covered trading range.
These levels update when things change during backtesting so you can visualize your strategy and how it would perform as well as see if your percentage deviation is large enough to cover dips. When backtesting trades are taken, the chart will show where they were taken(in backtesting) along with info on those trades such as the number each order is, the size of that order and the percentage deviation that order is from the initial buy.
SENDING SIGNALS TO 3COMMAS
Tradingview cannot sync this backtester to 3Commas and with the way alerts are setup for strategies on Tradingview, the best option for you to give signals to your bot would be to use this backtester to figure out what trigger you want to use and then setup that indicator separately to send alerts to your bot. All of the indicators used for signals in this backtester are available for free and can be configured to match this backtester and send alerts to 3Commas for you. Just make sure you set your alerts to once per bar close and don’t use less than a 15 second timeframe because then you could trigger the Tradingview threshold for alerts and get your alerts shut off.
You can also use this backtester with your own buy triggers if you know a little pine script. Just make copy of the script and code in your own buy signals and see how it backtests.
INFO PANEL FOR ANALYZING YOUR STRATEGY
The right hand side of the screen will show an info panel that shows a lot of different information so you can quickly see your bot settings and how it performed right on the screen.
In the top right corner you will see in purple your bot settings. These include your stoploss % if turned on, take profit %, average down order %, average down order % multiplier, volume multiplier, max number of orders allowed and size of your base order.
The top section of the first column “Current Trade” shows these stats: the open trade’s average price, the open trade’s take profit price, the open trade’s PNL, how far price is from your open tarde’s take profit level in percentage, your open position size and number of open orders.
The bottom section of the first column “Overall Performance” shows these stats: total number of trades taken during backtesting range, the largest amount of trades that were open at one time during backtesting, the max drawdown, the average number of bars per trade, gross profit, net profit, percent profit from your initial capital, current portfolio value and your initial capital.
CUSTOMIZABLE OPTIONS TO FIND THE PERFECT STRATEGY
Stoploss On/Off
This will turn your stoploss on or off. By default it is set to off and will not affect anything unless turned on.
Stoploss Percentage
This is the percentage below your final average down order price that will be set as a stoploss to keep your account from going too far in the red on big dips.
Take Profit Percentage - This is the percentage of profit you want the trade to hit before taking profit on your entire DCA trade. This level updates everytime you average down.
Average Down Percentage - This is the percentage that price has to drop from your initial order to initiate your first safety order. If the Average Down Percent Multiplier is set to 1 then this percentage will be the same for every average down order.
Average Down Percentage Multiplier - This multiplies your Average Down Percentage so each safety order needs a larger percentage deviation than the previous one. This keeps your buys closer together at the beginning and further apart when you hit more orders so you can extend your trading range but still be aggressive when price is going sideways.
Volume Multiplier Per New Order - This multiplies the size of each trade based on your base order. If you set it to a 2x multiplier then each average down order will be 2 times the size of the last one. So for example, a $100 base order with a 2x multiplier would have these values for the first 3 average down orders: 200, 400, 800.
Size Of Base Order - This is the size of your first position entry and will be used as a starting point for the volume multiplier. If your base order is $100 then it will buy $100 worth of whatever crypto you are backtesting this on. If you are looking at stock charts, you need to make sure your base order is higher than the share price across the entire backtesting range or it will not perform correctly.
Max Number Of Orders - This is the maximum number of orders the bot can take, including your base order. Adjust this to suit the amount of capital you are willing to allocate to your bot based on how much money it will require to run according to your bot settings.
TIPS ON HOW TO USE FOR BEST RESULTS
If you don’t have a lot of capital to work with, then use longer timeframes with a reasonable take profit percentage so that you don’t need a lot of average down orders. You can also try keeping the volume multiplier close to 1.
You can use the 3Commas dca bot settings page to see how much capital you will need for your strategy if you match it to the settings you have on this indicator. You can also check to see how much of a percentage deviation your bot is covering to make sure you have a reasonable range to trade in and orders to cover big dips. You can also check your coverage by seeing how far down the chart the green lines cover, which are your average down orders.
Make sure the initial capital in the properties tab of the settings has enough to cover all of your orders otherwise you will get unrealistic backtesting results. Also, make sure you leave the order size in the properties tab on contracts so it calculates your trades correctly. The only settings you need to touch in the properties tab is the initial capital. Unless you are trading somewhere that has lower commission fees, then you can change that to match, but leave all the other settings as is for it to function properly.
Increasing the volume multiplier will make your average price and take profit target follow the price action a lot closer as price falls, but it can also lead to having very large orders very quickly once you get into the 1.5-3x multiple range. Try using a high volume multiplier with less safety orders and you will get better results, however you need to have money on the sidelines to add on major dips to keep your bot turning a profit. Be very careful with this as greed and impatience will hurt your overall performance. This bot is meant to make money with lots of small wins so don’t get greedy and make sure you have enough money to cover large dips. If you are being aggressive with your bot, then I recommend only using 25% or less of your portfolio to trade aggressively and then use the smart trade feature on 3commas to add chunks of funds to your trades when price dips below your last safety order. Or if you want it to run without any supervision, then use lower volume multipliers and have lots of safety orders that can cover entire bear markets and still keep buying lower.
It’s a good idea to have some capital on the sidelines that you can add in when price dips quickly. This will help lower your average price and allow your bot to get out in profit quicker. 3Commas bot has a smart trade feature that will allow you to track your average price when adding extra funds and it will automatically update your other orders which is very convenient. Look at the longer timeframes when price dips and only add chunks at major areas where price is very likely to bounce. Or you can be aggressive when trading and add to your position when price dips and is at a likely bounce zone to maximize profits.
Only trade coins that have a good amount of liquidity as the larger your orders get, the harder it will be to sell if there isn’t much liquidity. Also, beware of how large your first order is as it will usually be a market order and can move the market if there is not much liquidity.
Since this bot takes a lot of trades and performs best when taking small profits consistently, you will need to factor in exchange fees. The bot is set to .5% commission(you can change this) on the buy and sell orders as most exchanges charge that amount. Some exchanges offer no fee trading on certain coins so be sure to look around for those so you can keep the commissions and maximize profits.
I strongly encourage you to try out a lot of different setting combinations across multiple different coins and do it across a few months to see how it would have performed under various market conditions. This will help you get a better idea of how much of a percentage deviation you’ll need to be able to cover to keep your bot running and making constant profits. You can also use the deep backtesting feature of the strategy panel to see how it would have done, but just beware that the info panel of the indicator will not reflect deep backtesting results, only the normal backtesting range.
MARKETS
This backtester can be used on any market including crypto, stocks, forex & futures. You just need to make sure your base order is larger than the share price when using this on things besides crypto.
TIMEFRAMES
This backtester can be used on all timeframes.