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.
Holy
Backwards price projection - few bars ahead reverse chartEver wondered what the chart would look like if it's flipped upside down and flipped horizontally into the future? The idea is that when there is a trend, a repeating pattern tends to occur. Going backwards and projecting that movement into the future can supposedly show what the future price will be.
Somehow I haven't found anyone try it like this and I am currently trying to find a way to use a reversed moving average or plot of some kind to project further ahead. TV at the moment does not allow offsets on candle plot(as far as I know) and I am only allowed a certain number of plots to go on the chart, so I put as many price moves ahead as I could to project the future price. It's a bit sloppy with all those forced plots but it gets the job done. I'll see if I can improve it with a moving average or something and possibly make a strategy out of it in the future.
Scalp God (top and bottom finder) (SATURN)I am very happy to present the Tradingview community the first of my new line of powerful indicators.
This is the SCALP GOD. It will clearly label market tops and bottoms for you, if you are scalping and looking to open or close a position this indicator will mark the local highs and lows for you. Or if you are a swing trader this can also give good signals as this indicator works on any pair and any timeframe! When you see the chart turning green you know for sure that a market top is forming, if the chart is turning red you know for sure a market bottom is forming. It is sometimes the absolute top or bottom and sometimes just an important local top or bottom. PM me if you find a better top & bottom indicator because I am trying to make this better than everything out there.
It absolutely can not repaint under any circumstances.
There are a few inputs for you to think about here:
-First is the length, this just decides how many previous bars to consider, making it longer will focus on more historical information while making shorter will make it focus on what has recently happened. 12 seems to be a good value, but it's not as important as the next two options.
-Next is the threshold value, setting it very low will mean that signals will get triggered very quickly, while a higher threshold will take more movement to trigger.
-Last and most important is the sensitivity value. A lower value here will make the signals much more sensitive and therefore able to flip and trigger faster. A higher sensitivity value will make the signals less sensitive and harder to flip, meaning that it will only look for movements that agree with the longer term trend. This is great for swing traders and scalpers that go with the trend.
-There is also a smoothening option, this will make it so the signals don't come on and off so much. Sometimes this will not be good for timing, but other times it will be a more certain signal for traders specifically looking for where the top or bottom ends.
It gets better because I added several of these indicators into one script, so if there is a particular set of sensitivities and thresholds that you like you can look at them all on the same chart without opening so many copies of this. To turn on an additional copy just check the "Sensitivity # On" box.
Everyone can try this for free for 3 days and after that it will be 0.025 BTC for lifetime use and this will include all future updates to this project. This is Project Saturn and this is the first indicator from a new series of indicators that will be coming out over the next year.
Hopefully this makes a lot of you rich! I'm very excited to see all of the uses people make with it.
Happy trading & good health!
VJ_Holy_Grail_ScalperA simple scalping indicator
Green triangle = Buy
Red triangle = Sell
Added buy/sell alerts for Autoview
VJ_Holy_Grail_Scalper_Swing_Trader_v1// Added Scalper and Swing Trader in 1 indicator to help those who are using free version on TV
// Added Alerts for Scalp Buy/Sell, Swing Buy/Sell and TP alerts(for both scalper and swing trader) to work with Autoview
Best Holy Grail Indicator V3Thanks to everyone that has been contacting me about the holy grail project, your comments and feedback have made this project much more rewarding. I'm excited for your further feedback. Here is Version 3.
How to use:
At the heart of this projects is a new kind of moving average that I have been developing. As such it is reasonable to think of these lines as highly enhanced and finely tuned moving averages. Their slopes, crossovers, spreads, and behaviors are all meaningful, just as in other moving averages. What is special about these is that if you trade their price crossovers, it almost never generates a real loss, just consistent profits. In trending markets these lines can give you all you need to know about trend entry/exit and details inbetween, effectively letting you get in/out at the top/bottom. In a ranging market they will show you ideal lines of mean reversion, and how to play them.
Description (Upgrades from V2), there are 3 huge improvements from V2:
1) It follows the price better: In the inputs window there is now a box called “Responsiveness”, it can have values from 0 to 5. At 0 Version 3 looks a lot like V2. When you turn up the responsiveness the lines follow closer when they should, and repel themselves when they should be distant. Unfortunately the lines are no longer as smooth, but it isn’t much of a problem. When you turn this up the lines can generate losses if you blindly use the crossover, this is because the slopes of these lines now have more meaning as they focus on the trend, and not how price moves right around it. This can also give very powerful signals if all 5 lines crossover in the same place. Mess with it.
2) There are too many neutral entries: Now every trade can be closed profitably! I posted an idea a few weeks back about “smart execution traces”, it is an intelligently suggested stop loss. The way you set it is in the inputs window at “Smart Execution Baseline”. If you are using crossover signals from Line 4, then set this to 4, if you use line 3 then set it to 3, ect… Unfortunately the lines are also not so smooth, but this can be a very helpful tool. If you play with it you can easily get a feeling for it.
3) Flipping between timeframes is now easier: Here you can bring a line in from another time frame. In the input window there is a box “Line from other timeframe?”. Here you can select the line you are interested in. Next you have to choose which timeframe you are interested it, you can choose this in the “timeframe multiplier” box. This multiplies you current time frame to get the desired one. If you are on the hourly charts and are interest in line 4 on the 6 hour charts, you first choose line 4, then in the timeframe multiplier you enter 6 to see the 6 hour red line in the 1 hour time frame. Likewise if you are still in the 1 hour and want to see the 15 minute red line, simply multiply by 0.25 (which is 1/4). Due to the limitations of pinescript it is easier to see smaller timeframes, getting a higher timeframe line requires more data. If you don’t want to consult another timeframe leave both of these at 0 to cut down on computational time.
After enough inquiries, the source code is now for sale.
If you are making money with this system and want to share it, here are my addresses. If you donated and want to see some of the indicators I am currently working on just message me so I can privately tag you in.
ETH: 0xcf1ca127d9cefb5efbe9557fa09a05cf4daea6c1
ZEC: t1dSFhH9jkG1z9AdGA27e2UqCMLdA2Y1or1
LTC: LQ1cssjU3dhqSa9K85ErqZYuRAPLfGKivA
BCH: 15zwnh2t2nM2bufnuPv12hJvJhFrU8iSFk
Please feel free to write in further questions in the comments below. Hope this makes some of you rich, happy trading!
Blair Momentum IndicatorThis is a very interesting momentum indicator for everyone to take a look at. To understand the concept behind it please see my previous idea "Adaptive Derivative Analysis", and the short Bitcoin prediction that was concurrent.
At its core this indicator takes the derivative of a custom adaptive moving average and adaptively weights the results. This is what the big black line is, the "Blair Line". When it is above 0 there is upward momentum, and downward when it is below 0. However, simply watching the movement of the Blair line doesn't seem especially helpful, so to aid the eye there are clouds around it. 2 fast clouds, 1 medium cloud, and 1 slow cloud. When the Blair line goes under a cloud it is a good time to sell, when it goes above a cloud it is a good time to buy. The red and orange clouds provide the quickest signals about the behavior of the momentum. The yellow cloud provides more certainty. When all three of these clouds align on the same side of the Blair line, it is a very good indication about the current momentum in the market. The Blue cloud is the slowest cloud, and provides the greatest confluence. Since the market can be in varying degrees of volatility there is a button to adjust the sensitivity of the indicator, called the "Roughness". When the roughness is at its maximum of 6 the indicator takes lots of weight for the most recent price movement, when the roughness is at a minimum of 1 it only looks at really long term behavior. The indicator seems to be the best at a roughness between 2 to 4. Since this is a momentum indicator it will not tell you what is the best time to buy at the lowest and sell at the highest, but it will give you a very good idea about the momentum in the markets, and much more importantly when the momentum will reverse.
It is recommended to use this indicator at a timeframe or two higher than where you are trading for a good overview. If you are trading on the 5 minute charts, look at the Blair momentum indicator of the 1 hour to 2 hour charts. If you trade on the daily charts then look at the weekly Blair momentum.
The power of this tool is in its ability to show where the momentum is changing, a long time before the price action changes. Please apply this indicator to the charts you are working with and see its predictive behavior around breakouts and sideways action.
Happy trading! Always feel free to message me with questions.
Holy Grail indicator (possibly) Version 2This is a continuation of the previous (possible) Holy Grail script. This is designed for forex and crypto trading.
The when the price crosses over a line it is a buy/sell signal. When the price crosses the blue area it is a great opportunity to ride the momentum, although quite risky. It is good to follow this in periods of high volume where the smallest trends can be caught. When the price crosses the pink area it is a little less risky than the blue area, but also doesn't catch every wave. When the price crosses back into the blue area it is a good signal that the small trend may be reversing, which also applies to the pink area. Although the pink area provides a little more certainty
The large red line provides the most stable entry points. For everyone that keeps asking, the backtests of the red line are generally very good, it lets profits ride and has almost nonexistent drawdowns. I would be interested in automating it, but it will enter and exit a position way too many times in certain circumstances creating an issue with fees.
The thin purple line shows the general trend. It reacts too slowly to give entry and exit points, but it may be helpful to watch it's behavior. Feel free to message me with any questions, ideas, or interests in collaborations in automated trading.
Cheers
The best Holy Grail indicator (currently)These have been optimized for the cryptocurrency markets, but also seems to work really well in commodities, futures, and forex. A crossover with the closing is treated as a buy or sell signal. The 4 lines provided have different sensitivities and therefore can be treated in combination or separately. This seems to be highly effective in trending markets as a trend follower, and in a ranging market the signals can pretty reliably be reversed for profit. I made this code private because it is still a work in progress and I am interested in hearing people's thoughts and experiences with it for further developments. This is well on the way to becoming a holy grail!
All the best, happy trading
-mcbw_