Pinescript v4 - The Holy Grail (Trailing Stop)After studying several other scripts, I believe I have found the Holy Grail! (Or perhaps I've just found a bug with Tradingview's Pinescript v4 language) Anyhow, I'm publishing this script in the hope that someone smarter than myself could shed some light on the fact that adding a trailing stop to any strategy seems to make it miraculously...no that's an understatement...incredulously, stupendously, mind-bendingly profitable. I'm talking about INSANE profit factors, higher than 200x, with drawdowns of <10%. Sounds too good to be true? Maybe it is...or you could hook it up to your LIVE broker, and pray it doesn't explode. This is an upgraded version of my original Pin Bar Strategy.
Recommended Chart Settings:
Asset Class: Forex
Time Frame: H1
Long Entry Conditions:
a) Exponential Moving Average Fan up trend
b) Presence of a Bullish Pin Bar
c) Pin Bar pierces the Exponential Moving Average Fan
Short Entry Conditions:
a) Exponential Moving Average down trend
b) Presence of a Bearish Pin Bar
c) Pin Bar pierces the Exponential Moving Average Fan
Exit Conditions:
a) Trailing stop is hit
b) Moving Averages cross-back (optional)
c) It's the weekend
Default Robot Settings:
Equity Risk (%): 3 //how much account balance to risk per trade
Stop Loss (x*ATR, Float): 0.5 //stoploss = x * ATR, you can change x
Stop Loss Trail Points (Pips): 1 //the magic sauce, not sure how this works
Stop Loss Trail Offset (Pips): 1 //the magic sauce, not sure how this works
Slow SMA (Period): 50 //slow moving average period
Medium EMA (Period): 18 //medium exponential moving average period
Fast EMA (Period): 6 //fast exponential moving average period
ATR (Period): 14 // average true range period
Cancel Entry After X Bars (Period): 3 //cancel the order after x bars not triggered, you can change x
Backtest Results (2019 to 2020, H1, Default Settings):
AUDUSD - 1604% profit, 239.6 profit factor, 4.9% drawdown (INSANE)
NZDUSD - 1688.7% profit, 100.3 profit factor, 2.5% drawdown
GBPUSD - 1168.8% profit, 98.7 profit factor, 0% drawdown
USDJPY - 900.7% profit, 93.7 profit factor, 4.9% drawdown
USDCAD - 819% profit, 31.7 profit factor, 8.1% drawdown
EURUSD - 685.6% profit, 26.8 profit factor, 5.9% drawdown
USDCHF - 1008% profit, 18.7 profit factor, 8.6% drawdown
GBPJPY - 1173.4% profit, 16.1 profit factor, 7.9% drawdown
EURAUD - 613.3% profit, 14.4 profit factor, 9.8% drawdown
AUDJPY - 1619% profit, 11.26 profit factor, 9.1% drawdown
EURJPY - 897.2% profit, 6 profit factor, 13.8% drawdown
EURGBP - 608.9% profit, 5.3 profit factor, 9.8% drawdown (NOT TOO SHABBY)
As you can clearly see above, this forex robot is projected by the Tradingview backtester to be INSANELY profitable for all common forex pairs. So what was the difference between this strategy and my previous strategies? Check my code and look for "trail_points" and "trail_offset"; you can even look them up in the PineScript v4 documentation. They specify a trailing stop as the exit condition, which automatically closes the trade if price reverses against you.
I however suspect that the backtester is not properly calculating intra-bar price movement, and is using a simplified model. With this simplfied approach, the trailing stop code becomes some sort of "holy grail" generator, making every trade entered profitable.
Risk Warning:
This is a forex trading strategy that involves high risk of equity loss, and backtest performance will not equal future results. You agree to use this script at your own risk.
Hint:
To get more realistic results, and *maybe* overcome the intrabar simulation error, change the settings to: "Stop Loss Trail Points (pips)": 100
I am not sure if this eradicates the bug, but the entries and exits look more proper, and the profit factors are more believable.
趋势分析
Noro's SRSI StrategyIndicator
Blue line - common RSI indicator.
Red line - SMA based on RSI
Upper black line - 50% + limit (custom parameter, 65% by default)
Lower black line - 50% - limit (custom parameter, 35% by default)
Strategy
If the red line (SMA) is higher than the upper black line, open a long position (and close the short position).
If the red line (SMA) is lower than the lower black line - open a short position (and close the long position).
For
Cryptocurrencies
Timeframes: 1h, 4h, 1d
Options
1) Length for RSI indicator
2) Length for RSI-based SMA
3) Limit - shift from 50% RSI (above and below, black lines)
Idea
As a rule, if the RSI indicator started to show high values, after that the price rises more often than falls. The opposite is true. When the RSI indicator is at its lowest values for a long time, the price usually keeps falling. The SMA is needed to reduce the error of RSI signals. Limit is needed to reduce a trades (a many trades is a many fees).
Renko Strategy T3 V1An interesting strategy using Renko calculations and Tilson T3 on normal charts targeted for cryptocurrencies but can work with different assets.
Tested on Daily but can work with lower frames using Renko Size and T3 Length adjustments.
== Description ==
Strategy get Renko close/open/high/low values and smooth them with T3 Tilson.
Base on these results the strategy triggers a long and short orders, where green uptrending and red downtrending.
Including Alerts
== Repaint ==
There seems to be some sort of inconsistency when doing 'Replay' function with the strategy, which means using Replay function won't trade like if you see the trading results without Replay. Regarding real time, it does not seem to repaint, besides that you need to wait for the last active bar to complete for it to give you indication.
You can disable strategy to use it has a sole indicator.
There might be a new strategy of Renko Strategy V2 in the future as i have an in progress prototype, Follow to get updated:
www.tradingview.com
Buy the Dips (by Coinrule)Taking your first steps into automated trading may be challenging. Coinrule's mission is to make it as easy as possible, also for beginners.
Here follows the best trading strategy to get started with Coinrule. This strategy doesn't involve complex indicators, yet was proved to be effective in the long term for many coins. Results seem to be improved when trading a coin vs Bitcoin.
The strategy buys the dips of a coin to sell with a profit. A stop-loss protects every trade.
Crypto markets offer high volatility and, thus, excellent opportunities for trading. Excluding times of severe downtrend, buying the dip is a simple and effective long-term trading strategy. The buy-signal is set to a 2% drop in a 30-minutes time frame.
Each trade comes with a take profit and a stop loss. Both set at 2%.
You can adjust these percentages to the market volatility as an advanced setup. You can backtest the outcomes using the backtesting tool from Tradingview
The strategy assumes each order to trade 30% of the available capital. A trading fee of 0.1% is taken into account. The fee is aligned to the base fee applied on Binance, which is the largest cryptocurrency exchange.
SuperTREX strategyThis is the strategy of Super Trex that i put as open source before
i just add option for non security MTF and take profit steps as i shown before
for different coins or assets you need to set different parameters
RSI of VWAPThis strategy inputs the vwap as source to RSI indicator.
ENTRY
When RSIofVwap crossover 70 and price is above ema200
partial exits
when RSIofVwap reaches 90 level take a portion of profit
Exit
When RSIofVwap crossdown 30
stoploss
defaulated to 5%
Risk Level
Defaulted to 10%. Based on this startegy calcuclates hiw many units can be purchased adhering to stoploss value
Note: code doesnt draw the RSI (vwap) indicator to the chart. if you want to see how these signals are generated , you can select RSI and VWAP of 14 period length.
warning
For educational purposes only
Backtest Custom HiLo StrategyThis script implements the HiLo trend follower strategy for backtesting the HiLo indicator. It comes with some custom options. Among them is the Type option that allows to choose between the moving averages for the highs and lows (HiLo), or highest and lowest values for those moving averages, respectively (HiLo Activator).
Long only strategy VWAP with BB and Golden Cross EMA50/200
This is strategy, mainly designed for stock markets
It makes uses of the EMA 50/ 200 ( Golden cross) and VWAP and Bollinger bands.
It only takes long positions. It can be adapted to all time frames, but preferably to be used with longer timeframes 1h +
The rules for entry are the next ones :
1. EMA50 > EMA 200
2. if current close > vwap session value
3. check if price dipped BB lower band for any of last 10 candles
EXIT RULE
1. price closes above BB upper
STOP LOSS EXIT
1. As configured --- default is set to 1%
Short In Downtrend Below MA100 (Coinrule)This is a simple strategy to take advantage of downtrends. It's useful to run such a strategy as a hedge in times of market uncertainty.
The Sell Condition - Entry
The sell signal triggers when:
the coin has MA (100) greater than the price in a timeframe of 15 minutes, meaning that the coin is in a short-term downtrend.
the coin has an RSI greater than 30 in a timeframe of 15 minutes, indicating that it didn't reach oversold conditions yet, so there is still room for a further price drop.
On Coinrule, you can launch the strategy on real market conditions, setting up multiple sequential sell orders. The strategy would keep selling while the price stays below the MA(100). In that case, it's advisable to set low amounts for the sell orders. the position will grow gradually while the downtrend intensifies. Set a minimum time interval between the sell orders will also help to have control over the overall position size.
The Buy Condition - Exit
The bot connects to each trade a stop loss and a take profit. The percentages are optimized for short term trades on mid-cap coins. You can adjust the percentages depending on the specific coin you are trading. A ratio of 1:1.5 between the stop loss and the take profit could work as the strategy trades in the same direction of the trend.
Stop loss at 3% from the entry price
Take profit at 2% from the entry price
A slightly larger stop loss allows tolerating more volatility to reduce the case of stops triggering when it shouldn't.
T3 Ichimoku Cloud StrategyThis strategy utilizes a variation of the Ichimoku Cloud based on T3 moving averages to smooth the outline of the cloud. With less noise and conflicting signals, it is an effective strategy when paired with a trailing stop loss.
BuyTheDipWell, I often had arguments in online forum with a guy who claimed to time the market perfectly without any technical analysis or prior experience. He often claimed that technical analysis does not work and it only works when you trade on other's emotions. He also argued that algorithmic trading isn't profitable - if so, everyone would do that. Hence, I thought I will convert his idea to algorithm.
In his own words, the strategy is as below:
Chose an instrument which is in full uptrend.
Wait for the panic sell and buy the dip
Once market recovers back exit immediately
It seems to do just fine with indexes. But, not so good when it comes to stocks.
Ichimoku with MACD/ CMF/ TSI This is a strategy made from ichimoku cloud , together with MACD, Chaiking Money FLOW and True Strenght Index.
It can be adapted to any timeframe and any type of financial markets.
The idea behind its very simple,
We combine the long / short strategy from ichimoku, like cross between lines and below/above cloud together with histogram from MACD for positive/negative level. We use the same criteria for TSI and CMF, to check if its above or below 0 level.
Based on that we have a long or a short entry. The exit happens when the next options triggers, like for example we had long signal, we exit when we receive the short signal and viceversa.
It can be adapted with a risk management to apply a tp/sl level.
For any suggestion or details , let me know.
London breakout GBPUSD daytradeHello,
First I want to WARN THAT YOU NEED A MINIMUM OF 30X LEVERAGE FOR THIS STRATEGY IN ORDER TO WORK.
THE REASON IS THAT THE SIZE IS CALCULATED BASED ON A VERY SHORT STOP LOSS LEVEL IN PIPS
UTILIZE IT AT YOUR OWN RISK
This is a daytrading strategy, that's suited for GBPUSD 1H timechart.
It a very simple strategy that utilizes 2 moving averages : a very fast one and a very slow one.
It will always enter only at the beginning candle of London session, and it will always exit at the candle at the finish of London session.
So the rules are simple :
If its 8 am GMT and the candle close or high cross the slow moving average and we are above at the same over the slow moving average we make a long movement. The oposite condition is applied for short.
At the same time we always use a very small stop loss = 50-100 points ( 5-10 pips).
We dont have a take profit, in our case the trade ends always at the end of London session. In this case at 15h GMT
It might work on other currencies aswell, but it has to be tested first.
For any questions or suggestions, please let me know.
Y-Profit Maximizer Strategy with Exit PointsThis script based on KivancOzbilgic 's PMax indicator. I modified a bit. Added Filters, Exit (TP) Levels and few indicator in it. This script opening only Long Positions.
I have used this indicators in this strategy:
-Moving Stop Loss (Most) by ceyhun
-PMax Explorer STRATEGY & SCREENER
-Bollinger Bands on Macd
-Tillson T3 Moving Average by KIVANÇ fr3762
I am open to suggestions for improve this script.
PS: Script is in Turkish Language.
BB21_MA200_StrategyThis strategy follows the trend and keeps you in the trend until it breaks SMA 200
SMA setting is 200
BB setting is 21
BUY
====
when BB is (lower band and upper band) above SMA 200 and price crossing above BB middle line
Partial Exit
==========
When Lower BB crossing down SMA200 , exit 30%
Total Exit
=========
When BB middle band crosses down SMA200 , exit ALL
Stop Loss
======
default is set to 5%
Risk Management
================
This is new parameter I have introduced in my strategies. Default value is 10% . That means , if your capital is 10000 , you are willing to risk 10% of it ... i.e 1000.
It doesnot mean that you are buying shares/units for 1000 only. It is different ...see below
Your trade size is calculated based on Risk% .... capital x risk 5 / stop Loss units
for further explanation you can check Alexander Elder's risk management rule. He mentioned 2% rule for 100K account. But most of us dont have 100K accounts .. . so I have defaulted 10% on 10K account. You can change this values and see the results. It wont change the number of trades or profit factor. It will increase the net profit.
Warning
=======
For educational purposes only
Combo Backtest 123 Reversal & FX Sniper: T3-CCI This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This simple indicator gives you a lot of useful information - when to enter, when to exit
and how to reduce risks by entering a trade on a double confirmed signal.
You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
WARNING:
- For purpose educate only
- This script to change bars colors.
EMA_HMA_RSI_StrategyThis strategy BUYS when HMA is below EMA (default setting is 200) and HMA turning to green and RSI 13 is below 70
Adds to existing position when current price is below BUY price and RSI crossing above 30 or 40
Exits the long position when HMA crosses down EMA
when you select Take Profit setting , partial profits are taken when current price > BUY price and RSI 13 crossing down 80
Bar color changes to purple when RSI13 is above 80 (if only in Long position exists)
Tested for SPY QQQ AAPL on hourly and 30 mins chart
Warning : For educational purposes only
Combo Backtest 123 Reversal & Volatility Finite Volume ElementsThis is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This is another version of FVE indicator that we have posted earlier
in this forum.
This version has an important enhancement to the previous one that`s
especially useful with intraday minute charts.
Due to the volatility had not been taken into account to avoid the extra
complication in the formula, the previous formula has some drawbacks:
The main drawback is that the constant cutoff coefficient will overestimate
price changes in minute charts and underestimate corresponding changes in
weekly or monthly charts.
And now the indicator uses adaptive cutoff coefficient which will adjust to
all time frames automatically.
WARNING:
- For purpose educate only
- This script to change bars colors.
Triple EMA Scalper low lag stratHi all,
This strategy is based on the Amazing scalper for majors with risk management by SoftKill21
The change is in lines 11-20 where the sma's are replaced with Triple ema's to
lower the lag.
The original author is SoftKill21. His explanation is repeated below:
Best suited for 1M time frame and majors currency pairs.
Note that I tried it at 3M time frame.
Its made of :
Ema ( exponential moving average ) , long period 25
Ema ( exponential moving average ) Predictive, long period 50,
Ema ( exponential moving average ) Predictive, long period 100
Risk management , risking % of equity per trade using stop loss and take profits levels.
Long Entry:
When the Ema 25 cross up through the 50 Ema and 100 EMA . and we are in london or new york session( very important the session, imagine if we have only american or european currencies, its best to test it)
Short Entry:
When the Ema 25 cross down through the 50 Ema and 100 EMA , and we are in london or new york session( very important the session, imagine if we have only american or european currencies, its best to test it)
Exit:
TargetPrice: 5-10 pips
Stop loss: 9-12 pips
Aroon Oscillator StrategyThis is simple strategy based on Aroon Oscillator. I have found that using length 144 or 169 on hourly chart shows excellent results.
Tested on SPY , QQQ and AAPL. Especially when you look at AAPL results , it has 60% profitable in recent trades. ( Dont assume this will be same for other stocks or ETFs)
Aroon Oscillator setting : 169 ( 169 is square root of 13 ... you can also use fib level 144 , which is square root of 12 )
BUY
When Aroon Oscillator crosses above zero line
Add
if Long position is already opened, and current close is less than BUY price and RSI 13 crossing above 30 line
Exit
when Aroon Oscialltor crosses below zero line
Stop Loss
default stop loss has been set to 5%
Note: I have not plotted RSI to the chart. Please include RSI 13 to see how position gets added ... Also add ema 169 to see how the price is aligned with the Aroon Oscillator
Warning
For the educational purposes only
TrendMaAlignmentStrategy - Long term tradesThis is another strategy based on moving average alignment and HighLow periods. This is more suitable for long term trend traders and mainly for stocks.
Candle is colored lime if : Lookback Period has at least one bar with moving averages fully aligned OR None of the bars in Lookback periods has negatively aligned moving averages (More than half are positively aligned).
Candle is colored orange if : Lookback Period has at least one bar with moving averages fully aligned in negative way OR none of the bars in lookback has positively aligned moving averages (More than half are negatively aligned).
If either of above conditions are met, candle is colored silver.
Moving average alignment parameters:
Moving Average Type : MA Type for calculating Aligned Moving Average Index
Lookback Period : Lookback period to check highest and lowest Moving Average index.
HighLow parameters:
Short High/Low Period: Short period to check highs and lows
Long High/Low Period: Longer Period to check highs and lows.
If short period high == long period high, which means, instrument has made new high in the short period.
ATR Parameters:
ATR Length: ATR periods
StopMultiplyer: To set stop loss.
ReentryStopMultiplyer: This is used when signal is green buy stop loss on previous trade is hit. In such cases, new order will not be placed until it has certain distance from stop line.
Trade Prameters:
Exit on Signal : To be used with caution. Enabling it will allow us to get out on bad trades early and helps exit trades in long consolidation periods. But, this may also cause early exit in the trend. If instrument is trending nicely, it is better to keep this setting unchecked.
Trade direction : Default is long only. Short trades are not so successful in backtest. Use it with caution.
Backtest years : limit backtesting to certain years.
Part of the logic used from study's below:
Other strategies based on these two studies are below (which are meant for short - medium terms):
Combo Backtest 123 Reversal & FSK (Fast and Slow Kurtosis) This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
This indicator plots the Fast & Slow Kurtosis. The Kurtosis is a market
sentiment indicator. The Kurtosis is constructed from three different parts.
The Kurtosis, the Fast Kurtosis(FK), and the Fast/Slow Kurtosis(FSK).
WARNING:
- For purpose educate only
- This script to change bars colors.
Easy System 420In this strategy, 15 indicators are used, each giving its results as a numerical value, which then is added or subtracted from the total points, gathered from all 15 indicators.
Many thanks to RafaelZioni for his great work making the EasySys1 script which i modified to create this script.
Onchart is drawn some of the indicators, but not all, a info panel is drawn showing the value each indicator has calculated. The info panel can be turned on or off.
Many of the indicator settings can be changed by user, and this is recommended, to tune the strategy to users chosen pair/timeframe.
Therefore any pair or timeframe can be used, the strategy tester results showing possible results, remember to set commission to match your broker. example chart settings here have common crypto exchange commission value: 0.25%
indicator list : SAR + STT + ZigZag + ROC + DMI + CCI + Weis + SMA + AO + MOM + Hist + BB + Ichimoku + HMA