The strategy is highly customizable. I've set the default values to suit ETH/USD 15m. If you're trading this on another ticker or timeframe, make sure to play around with the settings. There is an explanation of each input in the script comments. I found this to be profitable across most 'common sense' values for settings, but tweaking led to some pretty promising results. I leaned more towards high risk/high trade .
Always remember though: historical performance is no guarantee of future behavior. Keep settings within your personal risk tolerance, even if it promises better profit. Anyone can write a 100% profitable script if they assume price always eventually goes up.
Check the script comments for more details, but, briefly, you can customize:
-How many bases to keep track of at once
-How those bases are calculated
-What defines a 'base break'
-Safety order count
Here's the basic algorithm:
--Have previous candles found bottoms in the same area of the current candle bottom?
--Is this support unique enough from other areas of support?
-Determine if support is broken.
--Has the price crossed under support quickly and with certainty?
-Enter trade with a percentage of initial capital.
-Execute safety orders if price continues to drop.
-Exit trade at profit target or stop loss.
Take profit is dynamic and calculated on order entry. The bigger the 'break', the higher your take profit percentage. This target percentage is based on average position size, so as safety orders are filled, and average position size comes down, the target profit becomes easier to reach.
Stop loss can be calculated one of two ways, either a static level based on initial entry, or a dynamic level based on average position size. If you use the latter (default), be aware, your real losses will be greater than your stated stop loss percentage. For example:
-stop loss = 15%, capital = 100.00, safety order threshold = 10%
-you buy $50 worth of shares at $1 - price average is $1
-you safety $25 worth of shares at $0.9 - price average is $0.966
-you safety $25 worth of shares at $0.8. - price average is $0.925
-you get stopped out at 0.925 * (1-.15) = $0.78625, and you're left with $78.62.
This is a realized loss of ~21.4% with a stop loss set to 15%. The larger your safety order threshold, the larger your real loss in comparison to your stop loss percentage, and vice versa.
Indicator plots show the calculated bases in white. The closest base below price is yellow. If that base is broken, it turns purple. Once a trade is entered, profit target is shown in silver and stop loss in red.
-increased pyramiding to account for up to 5 safety orders
-the Safety Order Max Count wasn't actually being checked, haha. This also caused a side effect bug in safety order sizes. I resolved both of those issues by adding a variable to track the number of active safety orders.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.
I tried to apply this on some other cryptos on 15m tf but on some of them, there were really few signals or no signals, even tough there seems to be base breaks.
What should I do to get more signals especially on 15m tf? Or is it normal to have few or no signals.
Also for higher tfs what values are the most important ones to change?
Sorry some of my questions maybe silly.
If you're looking to increase the amount of signals, the best inputs to change would be your 'Base Break Detection' variables. A lower threshold and higher window will increase signals. You'll definitely want to lower your break threshold as you move to quicker timeframes.
The break threshold is really the main entry indicator. If price falls suddenly by this amount, we enter a trade. So, generally speaking, increasing this will reduce signals, but hopefully provide more profitable trades at the same time.
You can also increase signals by decreasing your unique base deviation while increasing max bases. This will allow for a denser area of potential trades, but I'm not sure if these signals would be as profitable.
As you go up in time frames, you'll want to increase the unique base deviation (to allow for larger price movement). Increasing the confidence level on higher time frames can also help with profitability I've found.
Still lots of testing to be done with this algorithm! If you find a good combination of significant settings, let me know!
var safetyOrderQty = ((strategy.initial_capital*(1-i_initialOrder))/i_safetyCount)/100
var safetyOrderQty is meant to equal the percentage of my trading capital to use for each safety order. So, if I have $100, use $25 on my initial order, and have 3 safety orders, then safetyOrderQty should equal 0.25 (divide my remaining capital after entry by my amount of possible safety orders).
((100 * 0.75)/3)/100 = 0.25
I then use that percentage in my strategy.entry() to calculate how many units to actually buy. I want to spend $25 on my safety order (initial capital * safetyOrderQty = $25), so I divide $25 by the current closing price to see how many units I can afford.
I'm not sure if all that addresses your question, but hopefully this clears something up; please clarify if I totally missed the point!
line41/ var safetyOrderQty = (((strategy.initial_capital + strategy.netprofit)*(1-i_initialOrder))/i_safetyCount)
line83/ strategy.entry(id="Long", long=strategy.long, qty=((strategy.initial_capital + strategy.netprofit) * i_initialOrder)/close, comment="Buy=$"+tostring(((strategy.initial_capital) * i_initialOrder), "####.##"))
line89/ strategy.entry(id="Long", long=strategy.long, qty=(safetyOrderQty)/close, comment="SafetyOrder=$"+tostring(safetyOrderQty, "####.##"))
your ordering system doesnt take into account profit gained from day one....and /100 that you use on line 41 doesnt make sense...check your orders on strategy list of trades to see what i mean....
And that's a good alternative in regards to the /100 part. It's a bit redundant I suppose, but making safetyOrderQty a percentage helps keep lines 83 and 89 more consistent with each other. Whatever fits your preference
Thanks for the feedback and different perspective!
By the way, loved your solution to the 'infinity' grid concept here
...I was trying to do the same thing with mvs1231 script but couldn't cause plotting doesn't work with arrays...your solution of using 15 pre plotted sma's was pure genius...
I am doing crypto for the last 6 months and i really think grids are the way to go... nothing better than the old dollar averaging i guess...