Trend-following Microprofit w/ Smart DCA BACKTESTING VERSIONCompanion to the alert script:
Tradingview doesn't like backtesting with too little capital or trade sizes less than 1 share, so the "Net Profit" number may not be accurate right off the bat. To get a better idea, change the order size or initial capital so the strategy is trading the appropriate % of initial capital. For example, if your personal capital is $2000 and you are making $100 trades, your trades are 5% of initial capital. That is roughly equivalent to the defaults using orders of 1 BTC with $100,000 capital.
Tightening the stop level will improve the Net Profit to Max Drawdown ratio, making the strategy more suitable for large trade sizes.
This script does not provide alerts for Gunbot. Find the settings you like using this strategy script, then plug those values into the alert script.
If you like this you can buy me chocolate below. Cheers!
Automated
Trend-following Microprofit w/ Smart DCA + Profit Plot + AlertsThis alert script is oriented towards automated trading with Gunbot.
I call it "Options Galore" because of all the user-configurable settings it offers for up-trending and down-trending markets. (See: " Market Tone " study).
A strategy script for quantitative backtesting, smarter buy/sell indicator such as TSI or Stoch RSI, and stop loss/trailing stop are all in the pipeline. Please share any other suggestions in the comments!
Features:
Set backtesting range, or start forward testing from the current time. Historical Renko charts can lead to repainting, which is avoided by keeping the chart open in your browser and running with real time data.
Average protection: only buy if price drops by a certain % below your average price -- can be automatically toggled by market trender if we want to continue buying during an uptrend. This reduces net profit but increases gross profit.
Gain protection: only sell if price is a certain % above your average price -- can be automatically toggled by market trender. Wait for larger profits in an uptrend, but sell earlier in a down trend.
Minimum percent gain can also be set to a negative value to allow selling at a loss. This is not true stop loss behavior, we still need a sell signal from the indicator. This means we will try to get the best price above your price floor, but in some rare situations we may not sell before the price drops below your price floor.
Position plotter: plots average long position price relative to current price.
Plot loss level: plots average price - loss %. With pyramiding turned off, this can be used to find out where to set your stop loss.
This script is free to use, just comment or PM for access. It is mainly meant to showcase some new features, and is only safe to use in carefully selected markets such as USDT-BTC.
Stay posted for upcoming scripts with smarter signaling and additional features! If you would like to add these features to your own preferred strategy, please PM me.
5 minute XAUUSD Strategy (Gold)Most definitely this is the best strategy I have ever coded. (Read Note Below)
Version 3 of PineScript code, 2 contract/lot trades at once, pyramiding = 2.
Commission of 100 pips included on each trade, accurate representation of actual spreads, commission_value = 0.02.
This is essentially 270% of profit in a single month - check the date on the first trade.
Trend following strategy as all the previous ones before, but this one is crazy.
Max drawdown is 34%, all that drawdown and more is profit made, but there cannot be any emotional involvement in this strategy.
Choppy markets produce losses, as is with all trend-following strategies.
(4 lines of code, nice and simple)
Downside - the last month in which this was backtested may not provide actual representation of past movement (market could have been exceptionally trending the last month), (but maybe it does ;v)
Unfortunately, we cannot know because "TRADINGVIEW WON'T OFFER BACKTESTING FOR FARTHER BACK!" fix this please.
Auto-Support v 0.2Same script as the previous version with a slight twist
Have added (lines) "Transparency" to the settings to avoid having to edit every line individually ...
Cheers
Auto-SupportFairly simple script that automatically draws highs and lows for the past X periods at various intervals.
3 Settings :
"Sensitivity" which amounts to the horizontal separation from one high to the next high (default multiplicator : 10)
Variable "b" which is the HEX color for resistances (default : red)
Variable "c" which is the HEX color for supports (default : blue)
More HEX color codes on www.hexcolortool.com (not my webpage :)
Feel free to edit the script to your taste.
MACDouble + RSI (rec. 15min-2hr intrv) Uses two sets of MACD plus an RSI to either long or short. All three indicators trigger buy/sell as one (ie it's not 'IF MACD1 OR MACD2 OR RSI > 1 = buy", its more like "IF 1 AND 2 AND RSI=buy", all 3 match required for trigger)
The MACD inputs should be tweaked depending on timeframe and what you are trading. If you are doing 1, 3, 5 min or real frequent trading then 21/44/20 and 32/66/29 or other high value MACDs should be considered. If you are doing longer intervals like 2, 3, 4hr then consider 9/19/9 and 21/44/20 for MACDs (experiment! I picked these example #s randomly).
Ideal usage for the MACD sets is to have MACD2 inputs at around 1.5x, 2x, or 3x MACD1's inputs.
Other settings to consider: try having fastlength1=macdlength1 and then (fastlength2 = macdlength2 - 2). Like 10/26/10 and 23/48/20. This seems to increase net profit since it is more likely to trigger before major price moves, but may decrease profitable trade %. Conversely, consider FL1=MCDL1 and FL2 = MCDL2 + (FL2 * 0.5). Example: 10/26/10 and 22/48/30 this can increase profitable trade %, though may cost some net profit.
Feel free to message me with suggestions or questions.
MACD, backtest 2015+ only, cut in half and doubledThis is only a slight modification to the existing "MACD Strategy" strategy plugin!
found the default MACD strategy to be lacking, although impressive for its simplicity. I added "year>2014" to the IF buy/sell conditions so it will only backtest from 2015 and beyond ** .
I also had a problem with the standard MACD trading late, per se. To that end I modified the inputs for fast/slow/signal to double. Example: my defaults are 10, 21, 10 so I put 20, 42, 20 in. This has the effect of making a 30min interval the same as 1 hour at 10,21,10. So if you want to backtest at 4hr, you would set your time interval to 2hr on the main chart. This is a handy way to make shorter time periods more useful even regardless of strategy/testing, since you can view 15min with alot less noise but a better response.
Used on BTCCNY OKcoin, with the chart set at 45 min (so really 90min in the strategy) this gave me a percent profitable of 42% and a profit factor of 1.998 on 189 trades.
Personally, I like to set the length/signals to 30,63,30. Meaning you need to triple the time, it allows for much better use of shorter time periods and the backtests are remarkably profitable. (i.e. 15min chart view = 45min on script, 30min= 1.5hr on script)
** If you want more specific time periods you need to try plugging in different bar values: replace "year" with "n" and "2014" with "5500". The bars are based on unix time I believe so you will need to play around with the number for n, with n being the numbers of bars.