Optimized Zhaocaijinbao strategyIntroduction:
The Optimized Zhaocaijinbao strategy is a mid and long-term quantitative trading strategy that combines momentum and trend factors. It generates buy and sell signals by using a combination of exponential moving averages, moving averages, volume and slope indicators. It generates buy signals when the stock is above the 35-day moving average, the trading volume is higher than the 20-day moving average, and the stock is in an upward trend on a weekly timeframe."招财进宝" is a Chinese phrase that can be translated to "Attract Wealth and Bring in Treasure" in English. It is a common expression used to wish for good luck and prosperity in various contexts, such as in business or personal finances.
Highlights:
The strategy has several special optimizations that make it unique.
Firstly, the strategy is optimized for T+1 trading in the Chinese stock market and is only suitable for long positions. The optimizations are also applicable to international stock markets.
Secondly, the trend strategy is optimized to only show indicators on the right side and oscillations. This helps to prevent false signals in choppy markets.
Thirdly, the strategy uses a risk factor for dynamic position sizing to ensure position sizes are adjusted according to the current net asset value and risk preferences. This helps to lower drawdown risks.
The strategy has good resilience even without using stop loss modules in backtesting, making it suitable for trading hourly, 2-hourly, and daily K-line charts (depending on the stock being traded). We recommend experimenting with backtesting using SSE 1-hour or 2-hour or daily Kline charts.
Backtesting outcomes:
The strategy was backtested over the period from October 13th, 2005 to April 14th, 2023, using daily candlestick charts for the commodity code SSE:600763, with a currency of CNY and tick size of 0.01. The strategy used an initial capital of 1,000,000 CNY, with order sizes set to 10% equity and a pyramid of 1 order. The strategy also had a Max Position Size of 0.01 and a Risk Factor of 2.
Here is a summary of the performance of the trading strategy:
Total net profit: 288,577.32 CNY, representing a return of 128.86%
Total number of closed trades: 61
Winning trades: 37, representing a win rate of 60.66%
Profit factor: 2.415
Largest losing trade: 222,021.46 CNY, representing a loss of 14.08%
Average trade: 21,124.22 CNY, representing a return of 3.1%
Average holding period for all trades: 12 days
Conclusion:
In conclusion, the Optimized Zhaocaijinbao strategy is a mid and long-term quantitative trading strategy that combines momentum and trend factors. It is suitable for both Chinese stocks and global stocks. While the Optimized Zhaocaijinbao strategy has performed well in backtesting, it is important to note that past performance is not a guarantee of future results. Traders should conduct their own research and analysis and exercise caution when using any trading strategy.
Indikator dan strategi
LowFinder_PyraMider_V2This strategy is a result of an exploration to experiment with other ways to detect lows / dips in the price movement, to try out alternative ways to exit and stop positions and a dive into risk management. It uses a combination of different indicators to detect and filter the potential lows and opens multiple positions to spread the risk and opportunities for unrealized losses or profits. This script combines code developed by fellow Tradingview community_members.
LowFinder
The lows in the price movement are detected by the Low finder script by RafaelZioni . It finds the potential lows based on the difference between RSI and EMA RSI. The MTF RSI formula is part of the MTFindicators library developed by Peter_O and is integrated in the Low finder code to give the option to use the RSI of higher timeframes. The sensitivity of the LowFinder is controlled by the MA length. When potential lows are detected, a Moving Average, a MTF Stochastic (based the the MTFindiicators by Peter_O) and the average price level filter out the weak lows. In the settings the minimal percentage needed for a low to be detected below the average price can be specified.
Order Sizing and Pyramiding
Pyramiding, or spreading multiple positions, is at the heart of this strategy and what makes it so powerful. The order size is calculated based on the max number of orders and portfolio percentage specified in the input settings. There are two order size modes. The ‘base’ mode uses the same base quantity for each order it opens, the ‘multiply’ mode multiplies the quantity with each order number. For example, when Long 3 is opened, the quantity is multiplied by 3. So, the more orders the bigger the consecutive order sizes. When using ‘multiply’ mode the sizes of the first orders are considerably lower to make up for the later bigger order sizes. There is an option to manually set a fixed order size but use this with caution as it bypasses all the risk calculations.
Stop Level, Take Profit, Trailing Stop
The one indicator that controls the exits is the Stop Level. When close crosses over the Stop Level, the complete position is closed and all orders are exited. The Stop Level is calculated based on the highest high given a specified candle lookback (settings). There is an option to deviate above this level with a specified percentage to tweak for better results. You can activate a Take Profit / Trailing Stop. When activated and close crosses the specified percentage, the Stop Level logic changes to a trailing stop to gain more profits. Another option is to use the percentage as a take profit, either when the stop level crosses over the take profit or close. With this option active, you can make this strategy more conservative. It is active by default.
And finally there is an option to Take Profit per open order. If hit, the separate orders close. In the current settings this option is not used as the percentage is 10%.
Stop Loss
I published an earlier version of this script a couple of weeks ago, but it got hidden by the moderators. Looking back, it makes sense because I didn’t pay any attention to risk management and save order sizing. This resulted in unrealistic results. So, in this script update I added a Stop Loss option. There are two modes. The ‘average price’ mode calculates the stop loss level based on a given percentage below the average price of the total position. The ‘equity’ mode calculates the stop loss level based on a given percentage of your equity you want to lose. By default, the ‘equity’ mode is active. By tweaking the percentage of the portfolio size and the stop loss equity mode, you can achieve a quite low risk strategy set up.
Variables in comments
To sent alerts to my exchange I use a webhook server. This works with a sending the information in the form of a comment. To be able to send messages with different quantities, a variable is added to the comment. This makes it possible to open different positions on the exchange with increasing quantities. To test this the quantities are printed in the comment and the quantities are switched off in the style settings.
This code is a result of a study and not intended for use as a worked out and full functioning strategy. Use it at your own risk. To make the code understandable for users that are not so much introduced into pine script (like me), every step in the code is commented to explain what it does. Hopefully it helps.
Enjoy!
VWAP+15EMA with RSIVWAP+EMA+RSI Strategy for the group MelléCasH
This strategy will enter a long position when the closing price is above both the VWAP and the 15 EMA, and the RSI is above the specified overbought level. It will exit the position when the price falls by the specified stop loss percentage, rises by the specified take profit percentage, or when the trailing stop loss (which trails the highest price achieved after the position was entered by the specified percentage) is hit. The VWAP, EMA, and RSI indicators are also plotted on the chart for reference.
Boftei's StrategyI wrote this strategy about a year ago, but decided to publish it just now. I have not been able to implement this strategy in the market. If you can, then I will be happy for you.
This strategy is based on my "Botvenko Script". (It finds the difference between the logarithms of closing prices from different days.) (Check this script in my profile)
Then the strategy makes trades when the "Botvenko Script" indicator crosses the levels set earlier and manually selected for each currency pair/shares: long/short opening/closing levels, long/short re-entry levels. (They are drawn with horizontal dotted lines.) The names of these lines are: buy/sell level, long/short retry - too low/high, long close up/down, dead - close the short. Manual selection of each of the parameters provides a qualitative entry of the strategy into the deal. However, without restraining mechanisms, the strategy enters into rather controversial deals. In order to avoid going long/short during bear/bull markets, which is unacceptable, I added a fan of EMA lines.
The fan consists of several EMA lines, which are set according to Fibonacci numbers (21, 55, 89, 144). If the lines in the fan are arranged in ascending order (ema_21>ema_55 and ema_55>ema_89 and ema_89>ema_144), then this indicates a bull market, during which I banned shorting. And vice versa: during the bear market (ema_21<ema_55 and ema_55<ema_89 and ema_89<ema_144) I banned long trading. If these two inequalities are not met, then this indicates that the market is flat, and during it it is allowed to enter any transactions, because a flat is a good moment to catch massive movements in the future by entering a transaction. (This is all visualized using semi-transparent thick lines of green, yellow and red colors.)
By default, all parameters are adjusted for the btc/usd (bitstamp) pair. Best of all, the strategy shows itself if 1 candle = 1 day.
At the time of writing, on the pair btcusd (bitstamp) (1d) with pyramiding = 1, the strategy shows a profit of 64728896%. If pyramiding is increased by 1, then the profit will be greater, but I still prefer pyramiding = 1.
There is a possibility that my strategy is doing complete nonsense. I don't vouch for her.
If you select parameters for other pairs of currencies/stocks, then you should not change anything in the fan of lines.
That's all, probably.
Lorentzian Classification Strategy Based in the model of Machine learning: Lorentzian Classification by @jdehorty, you will be able to get into trending moves and get interesting entries in the market with this strategy. I also put some new features for better backtesting results!
Backtesting context: 2022-07-19 to 2023-04-14 of US500 1H by PEPPERSTONE. Commissions: 0.03% for each entry, 0.03% for each exit. Risk per trade: 2.5% of the total account
For this strategy, 3 indicators are used:
Machine learning: Lorentzian Classification by @jdehorty
One Ema of 200 periods for identifying the trend
Supertrend indicator as a filter for some exits
Atr stop loss from Gatherio
Trade conditions:
For longs:
Close price is above 200 Ema
Lorentzian Classification indicates a buying signal
This gives us our long signal. Stop loss will be determined by atr stop loss (white point), break even(blue point) by a risk/reward ratio of 1:1 and take profit of 3:1 where half position will be closed. This will be showed as buy.
The other half will be closed when the model indicates a selling signal or Supertrend indicator gives a bearish signal. This will be showed as cl buy.
For shorts:
Close price is under 200 Ema
Lorentzian Classification indicates a selling signal
This gives us our short signal. Stop loss will be determined by atr stop loss (white point), break even(blue point) by a risk/reward ratio of 1:1 and take profit of 3:1 where half position will be closed. This will be showed as sell.
The other half will be closed when the model indicates a buying signal or Supertrend indicator gives a bullish signal. This will be showed as cl sell.
Risk management
To calculate the amount of the position you will use just a small percent of your initial capital for the strategy and you will use the atr stop loss or last swing for this.
Example: You have 1000 usd and you just want to risk 2,5% of your account, there is a buy signal at price of 4,000 usd. The stop loss price from atr stop loss or last swing is 3,900. You calculate the distance in percent between 4,000 and 3,900. In this case, that distance would be of 2.50%. Then, you calculate your position by this way: (initial or current capital * risk per trade of your account) / (stop loss distance).
Using these values on the formula: (1000*2,5%)/(2,5%) = 1000usd. It means, you have to use 1000 usd for risking 2.5% of your account.
We will use this risk management for applying compound interest.
> In settings, with position amount calculator, you can enter the amount in usd of your account and the amount in percentage for risking per trade of the account. You will see this value in green color in the upper left corner that shows the amount in usd to use for risking the specific percentage of your account.
> You can also choose a fixed amount, so you will have to activate fixed amount in risk management for trades and set the fixed amount for backtesting.
Script functions
Inside of settings, you will find some utilities for display atr stop loss, break evens, positions, signals, indicators, a table of some stats from backtesting, etc.
You will find the settings for risk management at the end of the script if you want to change something or trying new values for other assets for backtesting.
If you want to change the initial capital for backtest the strategy, go to properties, and also enter the commisions of your exchange and slippage for more realistic results.
In risk managment you can find an option called "Use leverage ?", activate this if you want to backtest using leverage, which means that in case of not having enough money for risking the % determined by you of your account using your initial capital, you will use leverage for using the enough amount for risking that % of your acount in a buy position. Otherwise, the amount will be limited by your initial/current capital
I also added a function for backtesting if you had added or withdrawn money frequently:
Adding money: You can choose how often you want to add money (Monthly, yearly, daily or weekly). Then a fixed amount of money and activate or deactivate this function
Withdraw money: You can choose if you want to withdraw a fixed amount or a percentage of earnings. Then you can choose a fixed amount of money, the period of time and activate or deactivate this function. Also, the percentage of earnings if you choosed this option.
Some other assets where strategy has worked
BTCUSD 4H, 1D
ETHUSD 4H, 1D
BNBUSD 4H
SPX 1D
BANKNIFTY 4H, 15 min
Some things to consider
USE UNDER YOUR OWN RISK. PAST RESULTS DO NOT REPRESENT THE FUTURE.
DEPENDING OF % ACCOUNT RISK PER TRADE, YOU COULD REQUIRE LEVERAGE FOR OPEN SOME POSITIONS, SO PLEASE, BE CAREFULL AND USE CORRECTLY THE RISK MANAGEMENT
Do not forget to change commissions and other parameters related with back testing results!. If you have problems loading the script reduce max bars back number in general settings
Strategies for trending markets use to have more looses than wins and it takes a long time to get profits, so do not forget to be patient and consistent !
Please, visit the post from @jdehorty called Machine Learning: Lorentzian Classification for a better understanding of his script!
Any support and boosts will be well received. If you have any question, do not doubt to ask!
BBPullback1.0.2This is a simple strategy script based on Bollinger Bands pullbacks.
The strategy is simple, as follows:
For LONGS: At the close of any candle, it check to see if this candle is an UP candle where the low broke below the lower Bollinger Band. If so, we call this the trigger candle. For the next bar, we issue a BUY signal if the price breaks above the high of the trigger candle. The stoploss is the low of the trigger candle. We take profit when the price goes above the middle Bollinger Band (the mean/average line).
For SHORTS: At the close of any candle, it check to see if this candle is an DOWN candle where the high broke above the upper Bollinger Band. If so, we call this the trigger candle. For the next bar, we issue a SELL signal if the price breaks below the low of the trigger candle. The stoploss is the high of the trigger candle. We take profit when the price goes below the middle Bollinger Band (the mean/average line).
AUTOMATIC GRID BOT STRATEGY [ilovealgotrading]
OVERVIEW:
This Grid trading strategy can help you maximize your profit in a ranging sideways market with no clear direction.
INDICATOR:
We can get some money by taking advantage of the movement of the price between the range we have determined.
Short positions are opened while the price is rising, long positions are opened while the price is falling.
Therefore, there is no need to predict the trend direction.
What is different in this indicator:
I want to say thank you to © thequantscience. His GRID SPOT TRADING ALGORITHM - GRID BOT TRADING strategy helped me when I was writing my indicator.
I want to explain what I have improved:
1- Grid strategy is a type of strategy that can be traded in very short time frames and users can trade this strategy algorithmically by connecting this strategy to their own accounts with the help of API systems. For this reason, I have developed a software that can give us signals by dynamically changing the long and short messages when users are trading.
2- We can change the start and end dates of our grid bot as we want. It is necessary to use this setting when setting up automatic bots, so that previously opened transactions are not taken into account.
3 - Lot or quantity size should not be excessively small when users are taking automatic trades because exchanges have limitations, to avoid this problem, I have prevented this error by automatically rounding up to the nearest quantity size inside the software.
4 - Users can avoid excessive losses by using stop loss on this grid bot if they wish.
5 - When our price is over the range high or below the range low, our open positions are closed, if the stop button is active. We can also change which close price time frame we take as a basis from the settings.
6 -Users can set how many dollars they can enter per transaction while performing their transactions automatically.
IMPLEMENTATION DETAILS – SETTINGS:
This script allows the user to choose the highs and lows leves of our range. Our bot trades in the specified range.
1. This strategy allows us to set start and end backtest dates.
2. We can change range high and range low leves of our bot
3. IF people want to trade algorithmically with the help of this bot, there are 6 different input systems that will receive the Json codes as an alarm
4. IF the price closes above the upper line or below the lower line, all transactions will be closed. We can determine in which time frame our transactions will be stopped if the price closes outside these levels.We can adjust how our bot works by activating or turning off the Stop Loss button.
5. In this strategy, you can determine your dollar cost for per position.
6. The user can also divide the interval we have determined into 10 parts or 20 equal parts.
7. The grid is divided and colored at the interval we set. At the same time, if we don't want we can turn off colored channels.
Notes:
If you're going to connect this bot to an automatic Long and Short direction,
Don’t forget! you need to Webhook URL,
Don’t miss paste this code to your message window {{strategy.order.alert_message}}
ALSO:
Set your range below the support zones and above the resistance zones.
Don't be afraid to take a wide range, it doesn't matter if you make a little money, the important thing is that you don't lose money.
If you have any ideas what to add to my work to add more sources or make calculations cooler, suggest in DM .
Moving Average Trap Strategy by D. BrigagliaThis is a strategy that follows the 200 periods moving average and fades the cross of ma3, ma5 and ma8. It is designed for profiting by mean reversion while at the same time respecting long term trend. It is designed for long term trending markets such as stocks and stock indices.
In this backtest, the strategy shows the ability to beat the S&P500 index with an average slippage set to 2 ticks. The number of trades is good (350), the profit factor is acceptable (1.67). The drawdowns are also reduced compared to the underlying asset.
Nothing of my content is financial advice.
*Backtesting System ⚉ OVERVIEW ⚉
One of the best Systems for Backtesting your Strategies.
Incredibly flexible, simple, fast and feature-rich system — will solve most of your queries without much effort.
Many systems for setting StopLoss, TakeProfit, Risk Management and advanced Filters.
All you need to do is plug in your indicator and start Backtesting .
I intentionally left the option to use my System on Full Power before you load your indicator into it.
The system uses the built-in simple and popular moving average crossover signal for this purpose. (EMA 50 & 200).
Also Highly Recommend that you Fully use ALL of the features of this system so that you understand how they work before you ask questions.
Also tried to leave TIPS for each feature everywhere, read Tips, activate them and see how they work.
But before you use this system, I Recommend you to read the following description in Full.
—————— How to connect your indicator in 2 steps:
Adapt your indicator by adding only 2 lines of code and then connect it to this Backtesting System.
Step 1 — Create your connector, For doing so:
• 1 — Find or create in your indicator where are the conditions printing the Long-Buy and Short-Sell signals.
• 2 — Create an additional plot as below
I'm giving an example with a Two moving averages cross.
Please replicate the same methodology for your indicator wether it's a MACD, RSI , Pivots, or whatever indicator with Clear Buy and Sell conditions.
//@version=5
indicator('Moving Average Cross', overlay = true)
MA200 = ta.𝚎𝚖𝚊(close, 200)
MA50 = ta.𝚎𝚖𝚊(close, 50)
// Generate Buy and Sell conditions
buy = ta.crossover (MA200, MA50)
sell = ta.crossunder (MA200, MA50)
plot(MA200, color=color.green)
plot(MA50 , color=color.red )
bgcolor(color = buy ? color.green : sell ? color.red : na, title='SIGNALS')
// ———————————————— SIGNAL FOR SYSTEM ————————————————
Signal = buy ? +1 : sell ? -1 : 0
plot(Signal, title='🔌Connector🔌', display = display.none)
// —————— 🔥 The Backtesting System expects the value to be exactly +1 for the 𝚋𝚞𝚕𝚕𝚒𝚜𝚑 signal, and -1 for the 𝚋𝚎𝚊𝚛𝚒𝚜𝚑 signal
Basically, I identified my Buy & Sell conditions in the code and added this at the bottom of my indicator code
Now you can connect your indicator to the Backtesting System using the Step 2
Step 2 — Connect the connector
• 1 — Add your updated indicator to a TradingView chart and Add the Backtesting System as well to the SAME chart
• 2 — Open the Backtesting System settings and in the External Source field select your 🔌Connector🔌 (which comes from your indicator)
_______________________________
⚉ MAIN SETTINGS ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
𝐄𝐱𝐭𝐞𝐫𝐧𝐚𝐥 𝐒𝐨𝐮𝐫𝐜𝐞 — Select your indicator. Add your indicator by following the 2 steps described above and select it in the menu. To familiarize yourself with the system until you select your indicator, you will have an in-built strategy of crossing the two moving EMA's of 50 and 200.
Long Deals — Enable/Disable Long Deals.
Short Deals — Enable/Disable Short Deals.
Wait End Deal — Enable/Disable waiting for a trade to close at Stop Loss/Take Profit. Until the trade closes on the Stop Loss or Take Profit, no new trade will open.
Reverse Deals — To force the opening of a trade in the opposite direction.
ReEntry Deal — Automatically open the same new deal after the deal is closed.
ReOpen Deal — Reopen the trade if the same signal is received. For example, if you are already in the long and a new signal is received in the long, the trade will reopen. * Does not work if Wait End Deal is enabled.
𝐓𝐚𝐤𝐞 𝐏𝐫𝐨𝐟𝐢𝐭:
None — Disables take profit. Useful if you only want to use dynamic stoplosses such as MA, Fast-Trailing, ATR Trail.
FIXED % — Fixed take profit in percent.
FIXED $ — Fixed Take in Money.
ATR — Fixed Take based on ATR.
R:R — Fixed Take based on the size of your stop loss. For example, if your stop is 10% and R:R=1, then the Take would be 10%. R:R=3 Take would be 30%, etc.
HH / LL — Fixed Take based on the previous maximum/minimum (extremum).
𝐒𝐭𝐨𝐩 𝐋𝐨𝐬𝐬:
None — Disables Stop Loss. Useful if you want to work without a stop loss. *Be careful if Wait End Deal is enabled, the trade may not close for a long time until it reaches the Take.
FIXED % — Fixed Stop in percent.
FIXED $ — Fixed Stop in Money.
TRAILING — Dynamic Trailing Stop like on the stock exchanges.
FAST TRAIL — Dynamic Fast Trailing Stop moves immediately in profit and stays in place if the price stands still or the price moves in loss.
ATR — Fixed Stop based on the ATR.
ATR TRAIL — Dynamic Trailing Stop based on the ATR.
LO / HI — A Fixed Stop based on the last Maximum/Minimum extemum. Allows you to place a stop just behind or above the low/high candle.
MA — Dynamic Stop based on selected Moving Average. * You will have 8 types of MA (EMA, SMA, HMA, etc.) to choose from, but you can easily add dozens of other MAs, which makes this type of stop incredibly flexible.
Add % — If true, then with the "𝗦𝘁𝗼𝗽 %" parameter you can add percentages to any of the current SL. Can be especially useful when using Stop - 𝗔𝗧𝗥 or 𝗠𝗔 or 𝗟𝗢/𝗛𝗜. For example with 𝗟𝗢/𝗛𝗜 to put a stop for the last High/Low and add 0.5% additional Stoploss.
Fixed R:R — If the stop loss is Dynamic (Trailing or MA) then if R:R true can also be made Dynamic * Use it carefully, the function is experimental.
_________________________________________
⚉ TAKE PROFIT LEVELS ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
A unique method of constructing intermediate Take Profit Levels will allow you to select up to 5 intermediate Take Profit Levels and one intermediate Stop Loss.
Intermediate Take Profit Levels are perfectly calculated into 5 equal parts in the form of levels from the entry point to the final Take Profit target.
All you need to do is to choose the necessary levels for fixing and how much you want to fix at each level as a percentage. For example, TP 3 will always be exactly between the entry point and the Take Profit target. And the value of TP 3 = 50 will close 50% of the amount of the remaining size of the position.
Note: all intermediate SL/TP are closed from the remaining position amount and not from the initial position size, as TV does by default.
SL 0 Position — works in the same way as TP 1-5 but it's Stop. With this parameter you can set the position where the intermediate stop will be set.
Breakeven on TP — When activated, it allows you to put the stop loss at Breakeven after the selected TP is reached. For this function to work as it should - you need to activate an intermediate Take. For example, if TP 3 is activated and Breakeven on TP = 3, then after the price reaches this level, the Stop loss will go to Breakeven.
* This function will not work with Dynamic Stoplosses, because it simply does not make sense.
CoolDown # Bars — When activated, allows you to add a delay before a new trade is opened. A new trade after CoolDown will not be opened until # bars pass and a new signal appears.
_____________________________
⚉ TIME FILTERS ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Powerful time filter code that allows you to filter data based on specific time zones, dates, and session days. This code is ideal for those who need to analyze data from different time zones and weed out irrelevant data.
With Time Filter, you can easily set the starting and ending time zones by which you want to filter the data.
You can also set a start and end date for your data and choose which days of the week to include in the analysis. In addition, you can specify start and end times for a specific session, allowing you to focus your analysis on specific time periods.
_________________________________
⚉ SIGNAL FILTERS ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Signal Filters — allows you to easily customize and optimize your trading strategies based on 10 filters.
Each filter is designed to help you weed out inaccurate signals to minimize your risks.
Let's take a look at their features:
__________________________________
⚉ RISK MANAGEMENT ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Risk management tools that allow you to set the maximum number of losing trades in a row, a limit on the number of trades per day or week and other filters.
Loss Streak — Set Max number of consecutive loss trades.
Win Streak — Max Winning Streak Length.
Row Loss InDay — Max of consecutive days with a loss in a row.
DrawDown % — Max DrawDown (in % of strategy equity).
InDay Loss % — Set Max Intraday Loss.
Daily Trades — Limit the number of MAX trades per day.
Weekly Trades — Limit the number of MAX trades per week.
* 🡅 I would Not Recommend using these functions without understanding how they work.
Order Size — Position Size
• NONE — Use the default position size settings in Tab "Properties".
• EQUITY — The amount of the allowed position as a percentage of the initial capital.
• Use Net Profit — On/Off the use of profit in the following trades. *Only works if the type is EQUITY.
• SIZE — The size of the allowed position in monetary terms.
• Contracts — The size of the allowed position in the contracts. 1 Сontract = Сurrent price.
________________
⚉ NOTES ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
It is important to note that I have never worked with Backtesting and the functions associated with them before.
It took me about a month of slow work to build this system.
I want to say Big Thanks:
• The PineScripters🌲 group in Telegram , the guys suggested how to implement some features. Especially @allanster
• Thanks to all those people who share their developments for free on TV and not only.
• I also thank myself for not giving up and finishing the project, and not trying to monetize the system by selling it. * Although I really want the money :)
I tried hard to make it as fast and convenient as possible for everyone who will use my code.
That's why I didn't use any libraries and dozens of heavy functions, and I managed to fit in 8+-functions for the whole code.
Absolutely every block of code I tried to make full-fledged modular, that it was easy to import/edit for myself (you).
I have abused the Ternary Pine operator a little (a lot) so that the code was as compact as possible.
Nevertheless, I tried very hard to keep my code very understandable even for beginners.
At last I managed to write 500 lines of code, making it one of the fastest and most feature-rich systems out there.
I hope everyone enjoys my work.
Put comments and write likes.
Strategy Template + Performance & Returns table + ExtrasA script I've been working on since summer 2022. A template for any strategy so you just have to write or paste the code and go straight into risk management settings
Features:
>Signal only Longs/only Shorts/Both
>Leverage system
>Proper fees calculation (even with leverage on)
>Different Stop Loss systems: Simple percentage, 4 different "move to Break Even" systems and Scaling SL after each TP order (read the disclaimer at the bottom regarding this and the TV % profitable metric)
>2 Take Profit systems: Simple percentages, or Risk/reward ratios based on SL level
>Additional option on TP so last one "rides free" until closure of position or Stoploss is hit (for more than 1 orders)
>Up to 5 TP orders
>Show or hide SL/TP levels on demand
>2 date filters. Manual filter is nothing new, enter two dates/hours and filter will turn on. BUT automatic filter is another thing (thanks to user @bfr_ for his help in codingthis feature)
>AUTOMATIC DATE FILTER. Allows you to split all historical data on the chart in X periods, then choose the range of periods used. Up to 10 but that can be changed, instructions included. Useful for WalkForward simulations, haven't seen a script in TradingView that allows you to do this and test your strategy on "unseen data" automatically
EXTRA SETTINGS
Besides, some additions I like to add to my codes:
>Returns table for monthly and weekly performance. Requires recalculation on every tick. This is a modified version of @QuantNomad's work. May add lower TF options later on
>Volume Based S/R system. Original work from @shtcoinr
>One feature that was made by me, the "portfolio table". Yields info and metrics of your strategy, current position and balance. You're able to turn it off and change its size
Should anyone find an error, or have any idea on how to improve this code, please contact me. Future updates could come, stay tuned
DISCLAIMER:
In order to have accurate StopLoss hit, I had to change the previous system, which was a "close position on candle close" instead at actual stoploss level. It was fixed, but resulted on inflation of the number of trading orders, thus reducing the percent profitable and making it strongly biased and unreal. Keep that in mind, that "real" profitability could be 2x or 3x the metric TradingView says. If your strategy has a really high trading frequency, resulting in 3000+ orders, might be a problem. Try to make use of the automatic/manual date filter as workaround, I have no means of changing this, seems it is not a bug but an intended design of the PineScript Code
Grospector DCA V.3This is system for DCA with strategy.
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
MTF Diagonally Layered RSI - 1 minute Bitcoin Bot [wbburgin]This is a NON-REPAINTING multi-timeframe RSI strategy (long-only) that enters a trade only when two higher timeframes are oversold. I wrote it on BTC/USD for 1min, but the logic should work on other assets as well. It is diagonally layered to be profitable for when the asset is in a downtrend.
Diagonal layering refers to entry and exit conditions spread across different timeframes. Normally, indicators can become unprofitable because in downtrends, the overbought zones of the current timeframe are not reached. Rather, the overbought zones of the faster timeframes are reached first, and then a selloff occurs. Diagonally-layered strategies mitigate this by selling diagonally, that is, selling once the faster timeframe reaches overbought and buying once the slower timeframe reaches oversold.
Thus this strategy is diagonally layered down . I may create a separate script that alternates between diagonal-up and diagonal-down based off of overall trend, as in extended trend periods up this indicator may not flash as frequently. This can be visualized in a time series x timeframe chart as an "X" shape. Something to consider...
Let me know if you like this strategy. Feel free to alter the pyramiding entries, initial capital, and entry size, as well as commission regime. My strategies are designed to maximize average profit instead of flashing super frequently, as the fees will eat you up. Additionally, at the time of publication, all of my strategy scripts are intended to have profitable Sharpe and Sortino ratios.
Timeframes, RSI period, and oversold/overbought bounds are configurable.
Kitchen [ilovealgotrading]
OVERVIEW:
Kitchen is a strategy that aims to trade in the direction of the trend by using supertrend and stochRsi data by calculating at different time values.
IMPLEMENTATION DETAILS – SETTINGS:
First of all, let's understand the supertrend and stocrsi indicators.
How do you read and use Super Trend for trading ?
The price is often going upwards when it breaks the super trend line while keeping its position above the indication level.
When the market is in a bullish trend, the indicator becomes green. The indicator level will act as trendline support in such a scenario. The color of the indicator changes to red to indicate a negative trend once the price crosses the support line. The price uses the super trend level as a trendline resistance during a bearish move.
In our strategy, if our 1-hour and 4-hour supertrend lines show the up or down train in the same direction at the same time, we can assume that a train is forming here.
Why do I use the time of 1 hour and 4 hours ?
When I did a backtest from the past to the present, I discovered that the most accurate and consistent time zones are the 1 hour and 4 hour time zones.
By the way we can change our short term timeframe(1H) and long term timeframe(4H) from settings panel.
How do you read and use the Stoch-RSI Indicator?
This indicator analyzes price dynamics automatically to detect overbought and oversold locations.
The indicator includes:
- The primary line, which typically has values between 0 and 100;
- Two dynamic levels for overbought and oversold conditions.
IF our stoch-rsi indicator value has fallen below our lower boundary line, the oversold event has been observed in the price, if our stoch-rsi value breaks up our bottom line after becoming oversold, we think that the price will start the recovery phase.(The case is also true for the opposite.)
However, this does not always apply and we need additional approvals, Therefore, our 1H and 4H supertrrend indicator provides us with additional confirmation.
Buy Condition:
Our 1H(short term) and 4H(long term) supertrrend indicator, has given the buy signal(green line and yellow line), and if our stochrsi indicator has broken our oversold line up on the past 15 bars, the buy signal is formed here.
Sell Condition:
Our 1H(short term) and 4H(long term) supertrrend indicator, has given the sell signal(red line and orange line), and if our stochrsi indicator has broken our overbuy line down on the past 15 bars, the sell signal is formed here.
Stop Loss or Take Profit Conditions:
Exit Long Senerio:
All conditions are completed, the buy signal has arrived and we have entered a LONG trade, the 1-hour supertrend line follows the price rise(yellow line), if the price breaks below the 1-hour super trend line and a sell condition occurs for 1H timeframe for supertrend indcator, LONG trade will exit here.
Exit Short Senerio:
All conditions are completed, the Sell signal has arrived and we have entered a SHORT trade, the 1-hour supertrend line follows the price down(orange line), if the price breaks up the 1-hour super trend line and a buy condition occurs for 1H timeframe for supertrend indcator, SHORT trade will exit here.
What can you change in the settings panel?
1-We can set Start and End date for backtest and future alarms
2-We can set ATR length and Factor for supertrend indicator
3-We can set our short term and long term timeframe value
4-We can set StochRsi Up and Low limit to confirm buy and sell conditions
5-We can set stochrsi retroactive approval length
6-We can set stochrsi values or the length
7-We can set Dollar cost for per position
8- We can choose the direction of our positions, we can set only LONG, only SHORT or both directions.
9-IF you want to place automatic buy and sell orders with this strategy, you can paste your codes into the Long open-close or Short open-close message sections.
For example
IF you write your alert window this code {{strategy.order.alert_message}}.
When trigger Long signal you will get dynamically what you pasted here for Long Open Message
ALSO:
Please do not open trades without properly managing your risk and psychology!!!
If you have any ideas what to add to my work to add more sources or make calculations cooler, suggest in DM .
Mean Reversion and TrendfollowingTitle: Mean Reversion and Trendfollowing
Introduction:
This script presents a hybrid trading strategy that combines mean reversion and trend following techniques. The strategy aims to capitalize on short-term price corrections during a downtrend (mean reversion) as well as ride the momentum of a trending market (trend following). It uses a 200-period Simple Moving Average (SMA) and a 2-period Relative Strength Index (RSI) to generate buy and sell signals.
Key Features:
Combines mean reversion and trend following techniques
Utilizes 200-period SMA and 2-period RSI
Customizable starting date
Allows for enabling/disabling mean reversion or trend following modes
Adjustable position sizing for trend following and mean reversion
Script Description:
The script implements a trading strategy that combines mean reversion and trend following techniques. Users can enable or disable either of these techniques through the input options. The strategy uses a 200-period Simple Moving Average (SMA) and a 2-period Relative Strength Index (RSI) to generate buy and sell signals.
The mean reversion mode is active when the price is below the SMA200, while the trend following mode is active when the price is above the SMA200. The script generates buy signals when the RSI is below 20 (oversold) in mean reversion mode or when the price is above the SMA200 in trend following mode. The script generates sell signals when the RSI is above 80 (overbought) in mean reversion mode or when the price falls below 95% of the SMA200 in trend following mode.
Users can adjust the position sizing for both trend following and mean reversion modes using the input options.
To use this script on TradingView, follow these steps:
Open TradingView and load your preferred chart.
Click on the 'Pine Editor' tab located at the bottom of the screen.
Paste the provided script into the Pine Editor.
Click 'Add to Chart' to apply the strategy to your chart.
Please note that the past performance of any trading system or methodology is not necessarily indicative of future results. Always use proper risk management and consult a financial advisor before making any investment decisions.
------
The following is a summary of the underlying whitepaper (onlinelibrary.wiley.com) for this strategy:
This paper proposes a theory of securities market under- and overreactions based on two psychological biases: investor overconfidence about the precision of private information and biased self-attribution, which causes asymmetric shifts in investors' confidence as a function of their investment outcomes. The authors show that overconfidence implies negative long-lag autocorrelations, excess volatility, and public-event-based return predictability. Biased self-attribution adds positive short-lag autocorrelations (momentum), short-run earnings "drift," and negative correlation between future returns and long-term past stock market and accounting performance.
The paper explains that there is empirical evidence challenging the traditional view that securities are rationally priced to reflect all publicly available information. Some of these anomalies include event-based return predictability, short-term momentum, long-term reversal, high volatility of asset prices relative to fundamentals, and short-run post-earnings announcement stock price "drift."
The authors argue that investor overconfidence can lead to stock prices overreacting to private information signals and underreacting to public signals. This overreaction-correction pattern is consistent with long-run negative autocorrelation in stock returns, excess volatility, and further implications for volatility conditional on the type of signal. The market's tendency to over- or underreact to different types of information allows the authors to address the pattern that average announcement date returns in virtually all event studies are of the same sign as the average post-event abnormal returns.
Biased self-attribution implies short-run momentum and long-term reversals in security prices. The dynamic analysis based on biased self-attribution can also lead to a lag-dependent response to corporate events. Cash flow or earnings surprises at first tend to reinforce confidence, causing a same-direction average stock price trend. Later reversal of overreaction can lead to an opposing stock price trend.
The paper concludes by summarizing the findings, relating the analysis to the literature on exogenous noise trading, and discussing issues related to the survival of overconfident traders in financial markets.
The Flash-Strategy (Momentum-RSI, EMA-crossover, ATR)The Flash-Strategy (Momentum-RSI, EMA-crossover, ATR)
Are you tired of manually analyzing charts and trying to find profitable trading opportunities? Look no further! Our algorithmic trading strategy, "Flash," is here to simplify your trading process and maximize your profits.
Flash is an advanced trading algorithm that combines three powerful indicators to generate highly selective and accurate trading signals. The Momentum-RSI, Super-Trend Analysis and EMA-Strategy indicators are used to identify the strength and direction of the underlying trend.
The Momentum-RSI signals the strength of the trend and only generates trading signals in confirmed upward or downward trends. The Super-Trend Analysis confirms the trend direction and generates signals when the price breaks through the super-trend line. The EMA-Strategy is used as a qualifier for the generation of trading signals, where buy signals are generated when the EMA crosses relevant trend lines.
Flash is highly selective, as it only generates trading signals when all three indicators align. This ensures that only the highest probability trades are taken, resulting in maximum profits.
Our trading strategy also comes with two profit management options. Option 1 uses the so-called supertrend-indicator which uses the dynamic ATR as a key input, while option 2 applies pre-defined, fixed SL and TP levels.
The settings for each indicator can be customized, allowing you to adjust the length, limit value, factor, and source value to suit your preferences. You can also set the time period in which you want to run the backtest and how many dollar trades you want to open in each position for fully automated trading.
Choose your preferred trade direction and stop-loss/take-profit settings, and let Flash do the rest. Say goodbye to manual chart analysis and hello to consistent profits with Flash. Try it now!
General Comments
This Flash Strategy has been developed in cooperation between Baby_whale_to_moon and JS-TechTrading. Cudos to Baby_whale_to_moon for doing a great job in transforming sophisticated trading ideas into pine scripts.
Detailed Description
The “Flash” script considers the following indicators for the generation of trading signals:
1. Momentum-RSI
2. ‘Super-Trend’-Analysis
3. EMA-Strategy
1. Momentum-RSI
• This indicator signals the strength of the underlying upward- or downward-trend.
• The signal range of this indicator is from 0 to 100. Values > 60 indicate a confirmed upward- or downward-trend.
• The strategy will only generate trading signals in case the stock (or any other financial security) is in a confirmed upward- (long entry signals) or downward-trend (short entry signals).
• This indicator provides information with regards to the strength of the underlying trend and it does not give any insight with regard to the direction of the trend. Therefore, this strategy also considers other indicators which provide technical confirmation with regards to the direction of the underlying trend.
Graph 1 shows this concept:
• The Momentum-RSI indicator gives lower readings during consolidation phases and no trading signals are generated during these periods.
Example (graph 2):
2. Super-Trend Analysis
• The red line in the graph below represents the so-called super-trend-line. Trading signals are only generated in case the price action breaks through this super-trend-line indicating a new confirmed upward-trend (or downward-trend, respectively).
• If that happens, the super trend-line changes its color from red to green, giving confirmation that the trend changed from bearish to bullish and long-entries can be considered.
• The vice-versa approach can be considered for short entries.
Graph 3 explains this concept:
3. Exponential Moving Average / EMA-Strategy
The functionality of this EMA-element of the strategy has been programmed as follows:
• The exponential moving average and two other trend lines are being used as qualifiers for the generation of trading-signals.
• Buy-signals for long-entries are only considered in case the EMA (yellow line in the graph below) crosses the red line.
• Sell-signals for short-entries are only considered in case the EMA (yellow line in the graph below) crosses the green line.
An example is shown in graph 4 below:
We use this indicator to determine the new trend direction that may occur by using the data of the price's past movement.
4. Bringing it all together
This section describes in detail, how this strategy combines the Momentum-RSI, the super-trend analysis and the EMA-strategy.
The strategy only generates trading-signals in case all of the following conditions and qualifiers are being met:
1. Momentum-RSI is higher than the set value of this strategy. The standard and recommended value is 60 (graph 5):
2. The super-trend analysis needs to indicate a confirmed upward-trend (for long-entry signals) or a confirmed downward-trend (for short-entry signals), respectively.
3. The EMA-strategy needs to indicate that the stock or financial security is in a confirmed upward-trend (long-entries) or downward-trend (short-entries), respectively.
The strategy will only generate trading signals if all three qualifiers are being met. This makes this strategy highly selective and is the key secret for its success.
Example for Long-Entry (graph 6):
When these conditions are met, our Long position is opened.
Example for Short-Entry (graph 7):
Trade Management Options (graph 8)
Option 1
In this dynamic version, the so-called supertrend-indicator is being used for the trade exit management. This supertrend-indicator is a sophisticated and optimized methodology which uses the dynamic ATR as one of its key input parameters.
The following settings of the supertrend-indicator can be changed and optimized (graph 9):
The dynamic SL/TP-lines of the supertrend-indicator are shown in the charts. The ATR-length and the supertrend-factor result in a multiplier value which can be used to fine-tune and optimize this strategy based on the financial security, timeframe and overall market environment.
Option 2 (graph 10):
Option 2 applies pre-defined, fixed SL and TP levels which will appear as straight horizontal lines in the chart.
Settings options (graph 11):
The following settings can be changed for the three elements of this strategy:
1. (Length Mom-Rsi): Length of our Mom-RSI indicator.
2. Mom-RSI Limit Val: the higher this number, the more momentum of the underlying trend is required before the strategy will start creating trading signals.
3. The length and factor values of the super trend indicator can be adjusted:ATR Length SuperTrend and Factor Super Trend
4. You can set the source value used by the ema trend indicator to determine the ema line: Source Ema Ind
5. You can set the EMA length and the percentage value to follow the price: Length Ema Ind and Percent Ema Ind
6. The backtesting period can be adjusted: Start and End time of BackTest
7. Dollar cost per position: this is relevant for 100% fully automated trading.
8. Trade direction can be adjusted: LONG, SHORT or BOTH
9. As we explained above, we can determine our stop-loss and take-profit levels dynamically or statically. (Version 1 or Version 2 )
Display options on the charts graph 12):
1. Show horizontal lines for the Stop-Loss and Take-profit levels on the charts.
2. Display relevant Trend Lines, including color setting options for the supertrend functionality. In the example below, green lines indicate a confirmed uptrend, red lines indicate a confirmed downtrend.
Other comments
• This indicator has been optimized to be applied for 1 hour-charts. However, the underlying principles of this strategy are supply and demand in the financial markets and the strategy can be applied to all timeframes. Daytraders can use the 1min- or 5min charts, swing-traders can use the daily charts.
• This strategy has been designed to identify the most promising, highest probability entries and trades for each stock or other financial security.
• The combination of the qualifiers results in a highly selective strategy which only considers the most promising swing-trading entries. As a result, you will normally only find a low number of trades for each stock or other financial security per year in case you apply this strategy for the daily charts. Shorter timeframes will result in a higher number of trades / year.
• Consequently, traders need to apply this strategy for a full watchlist rather than just one financial security.
Advanced VWAP_Pullback Strategy_Trend-Template QualifierGeneral Description and Unique Features of this Script
Introducing the Advanced VWAP Momentum-Pullback Strategy (long-only) that offers several unique features:
1. Our script/strategy utilizes Mark Minervini's Trend-Template as a qualifier for identifying stocks and other financial securities in confirmed uptrends. Mark Minervini, a 2x US Investment Champion, developed the Trend-Template, which covers eight different and independent characteristics that can be adjusted and optimized in this trend-following strategy to ensure the best results. The strategy will only trigger buy-signals in case the optimized qualifiers are being met.
2. Our strategy is based on the supply/demand balance in the market, making it timeless and effective across all timeframes. Whether you are day trading using 1- or 5-min charts or swing-trading using daily charts, this strategy can be applied and works very well.
3. We have also integrated technical indicators such as the RSI and the MA / VWAP crossover into this strategy to identify low-risk pullback entries in the context of confirmed uptrends. By doing so, the risk profile of this strategy and drawdowns are being reduced to an absolute minimum.
Minervini’s Trend-Template and the ‘Stage-Analysis’ of the Markets
This strategy is a so-called 'long-only' strategy. This means that we only take long positions, short positions are not considered.
The best market environment for such strategies are periods of stable upward trends in the so-called stage 2 - uptrend.
In stable upward trends, we increase our market exposure and risk.
In sideways markets and downward trends or bear markets, we reduce our exposure very quickly or go 100% to cash and wait for the markets to recover and improve. This allows us to avoid major losses and drawdowns.
This simple rule gives us a significant advantage over most undisciplined traders and amateurs!
'The Trend is your Friend'. This is a very old but true quote.
What's behind it???
• 98% of stocks made their biggest gains in a Phase 2 upward trend.
• If a stock is in a stable uptrend, this is evidence that larger institutions are buying the stock sustainably.
• By focusing on stocks that are in a stable uptrend, the chances of profit are significantly increased.
• In a stable uptrend, investors know exactly what to expect from further price developments. This makes it possible to locate low-risk entry points.
The goal is not to buy at the lowest price – the goal is to buy at the right price!
Each stock goes through the same maturity cycle – it starts at stage 1 and ends at stage 4
Stage 1 – Neglect Phase – Consolidation
Stage 2 – Progressive Phase – Accumulation
Stage 3 – Topping Phase – Distribution
Stage 4 – Downtrend – Capitulation
This strategy focuses on identifying stocks in confirmed stage 2 uptrends. This in itself gives us an advantage over long-term investors and less professional traders.
By focusing on stocks in a stage 2 uptrend, we avoid losses in downtrends (stage 4) or less profitable consolidation phases (stages 1 and 3). We are fully invested and put our money to work for us, and we are fully invested when stocks are in their stage 2 uptrends.
But how can we use technical chart analysis to find stocks that are in a stable stage 2 uptrend?
Mark Minervini has developed the so-called 'trend template' for this purpose. This is an essential part of our JS-TechTrading pullback strategy. For our watchlists, only those individual values that meet the tough requirements of Minervini's trend template are eligible.
The Trend Template
• 200d MA increasing over a period of at least 1 month, better 4-5 months or longer
• 150d MA above 200d MA
• 50d MA above 150d MA and 200d MA
• Course above 50d MA, 150d MA and 200d MA
• Ideally, the 50d MA is increasing over at least 1 month
• Price at least 25% above the 52w low
• Price within 25% of 52w high
• High relative strength according to IBD.
NOTE: In this basic version of the script, the Trend-Template has to be used as a separate indicator on TradingView (Public Trend-Template indicators are available in TradingView – community scripts). It is recommended to only execute buy signals in case the stock or financial security is in a stage 2 uptrend, which means that the criteria of the trend-template are fulfilled.
This strategy can be applied to all timeframes from 5 min to daily.
The VWAP Momentum-Pullback Strategy
For the JS-TechTrading VWAP Momentum-Pullback Strategy, only stocks and other financial instruments that meet the selected criteria of Mark Minervini's trend template are recommended for algorithmic trading with this startegy.
A further prerequisite for generating a buy signals is that the individual value is in a short-term oversold state (RSI).
When the selling pressure is over and the continuation of the uptrend can be confirmed by the MA / VWAP crossover after reaching a price low, a buy signal is issued by this strategy.
Stop-loss limits and profit targets can be set variably. You also have the option to make use of the trailing stop exit strategy.
Relative Strength Index (RSI)
The Relative Strength Index (RSI) is a technical indicator developed by Welles Wilder in 1978. The RSI is used to perform a market value analysis and identify the strength of a trend as well as overbought and oversold conditions. The indicator is calculated on a scale from 0 to 100 and shows how much an asset has risen or fallen relative to its own price in recent periods.
The RSI is calculated as the ratio of average profits to average losses over a certain period of time. A high value of the RSI indicates an overbought situation, while a low value indicates an oversold situation. Typically, a value > 70 is considered an overbought threshold and a value < 30 is considered an oversold threshold. A value above 70 signals that a single value may be overvalued and a decrease in price is likely , while a value below 30 signals that a single value may be undervalued and an increase in price is likely.
For example, let's say you're watching a stock XYZ. After a prolonged falling movement, the RSI value of this stock has fallen to 26. This means that the stock is oversold and that it is time for a potential recovery. Therefore, a trader might decide to buy this stock in the hope that it will rise again soon.
The MA / VWAP Crossover Trading Strategy
This strategy combines two popular technical indicators: the Moving Average (MA) and the Volume Weighted Average Price (VWAP). The MA VWAP crossover strategy is used to identify potential trend reversals and entry/exit points in the market.
The VWAP is calculated by taking the average price of an asset for a given period, weighted by the volume traded at each price level. The MA, on the other hand, is calculated by taking the average price of an asset over a specified number of periods. When the MA crosses above the VWAP, it suggests that buying pressure is increasing, and it may be a good time to enter a long position. When the MA crosses below the VWAP, it suggests that selling pressure is increasing, and it may be a good time to exit a long position or enter a short position.
Traders typically use the MA VWAP crossover strategy in conjunction with other technical indicators and fundamental analysis to make more informed trading decisions. As with any trading strategy, it is important to carefully consider the risks and potential rewards before making any trades.
This strategy is applicable to all timeframes and the relevant parameters for the underlying indicators (RSI and MA/VWAP) can be adjusted and optimized as needed.
Backtesting
Backtesting gives outstanding results on all timeframes and drawdowns can be reduced to a minimum level. In this example, the hourly chart for MCFT has been used.
Settings for backtesting are:
- Period from Jan 2020 until March 2023
- Starting capital 100k USD
- Position size = 25% of equity
- 0.01% commission = USD 2.50.- per Trade
- Slippage = 2 ticks
Other comments
- This strategy has been designed to identify the most promising, highest probability entries and trades for each stock or other financial security.
- The combination of the Trend-Template and the RSI qualifiers results in a highly selective strategy which only considers the most promising swing-trading entries. As a result, you will normally only find a low number of trades for each stock or other financial security per year in case you apply this strategy for the daily charts. Shorter timeframes will result in a higher number of trades / year.
- Consequently, traders need to apply this strategy for a full watchlist rather than just one financial security.
Cycle Position TradingTitle: Cycle Position Trading Strategy v1.0
Description: Cycle Position Trading Strategy is a simple yet effective trading strategy based on a 200-day Simple Moving Average (SMA). Users can select between two modes, "Buy Uptrend" and "Buy Downtrend," to customize the strategy according to their trading preferences. The strategy allows users to set their own stop loss (SL) and take profit (TP) levels, providing more flexibility and control over their trades.
Features:
Choose between two trading modes: "Buy Uptrend" and "Buy Downtrend."
Customize your stop loss (SL) and take profit (TP) levels.
Clear visual representation of the 200-day Simple Moving Average (SMA) on the chart.
How to use:
Add the strategy to your chart by searching for "Cycle Position Trading Strategy" in the TradingView "Indicators & Strategies" section.
Configure the strategy settings according to your preferences:
Select the trading mode from the dropdown menu. "Buy Uptrend" will open long positions when the closing price is above the 200-day SMA. "Buy Downtrend" will open long positions when the closing price is below the 200-day SMA.
Set your desired stop loss (SL) and take profit (TP) levels. The default values are 0.9 (10% below the entry price) for the stop loss and 1.1 (10% above the entry price) for the take profit.
Monitor the chart for trade signals based on the chosen mode and settings. The strategy will enter and exit trades automatically based on the selected mode and the configured stop loss and take profit levels.
Analyze the performance of the strategy by checking the TradingView strategy performance summary or by viewing individual trades in the "Trades" list.
Disclaimer: This strategy is intended for educational and illustrative purposes only. Use it at your own risk. Past performance is not indicative of future results. Trading stocks, cryptocurrencies, or any other financial instrument involves significant risk and may result in the loss of capital.
Version: v1.0
Release date: 2023-03-25
Author: I11L
License: Mozilla Public License 2.0 (mozilla.org)
Daily Investments Index ScalpThis strategy is based on the DIDI index with our own confirmations and calculated SL/TP .
You can change every setting if you want it to use for another pair, but this is fine tuned for NATURALGAS
The entries are taken when:
Long:
- Buy signal from the DIDI indicator
- Long EMA is underneath the Short EMA
- Price must be Above the Long EMA
- TP1 (default) - ATR based first TP is ATR * 1.2 Multiplier
- TP2 (default) - ATR based first TP is ATR * 2 Multiplier
- TP2 SL is the strategy entry price when we hit the first TP
- SL (default) - Latest swing low with a look back of 17 candles
Short:
- Sell signal from the DIDI indicator
- Long EMA is Above the Short EMA
- Price must be Below the Long EMA
- TP1 (default) - ATR based first TP is ATR * 1.2 Multiplier
- TP2 (default) - ATR based first TP is ATR * 2 Multiplier
- TP2 SL is the strategy entry price when we hit the first TP
- SL (default) - Latest swing low with a look back of 17 candles
It's fairly simple, and i think you can use this base so extend your own strategy
Good luck :)
If you have any questions, feel free to comment
X48 - Strategy | BreakOut & Consecutive (11in1) + Alert | V.1.2================== Read This First Before Use This Strategy ==============
*********** Please be aware that this strategy is not a guarantee of success and may lead to losses.
*********** Trading involves risk and you should always do your own research before making any decisions.
================= Thanks Source Script and Explain This Strategy ===================
► Description
Write a detailed and meaningful description that allows users to understand how your script is original, what it does, how it does it and how to use it
This Strategy Are Combine Strategy and Indicators Alert Function For Systematic Trading User.
Strategy List, Thanks For Original Source Script , From Tradingview Build-in Script From fmzquant Github
// Channel BreakOut Strategy : Calculate BreakOut Zone For Buy and Sell.
// Consecutive Bars UP/Down Strategy : The consecutive bars up/down strategy is a trading strategy used to identify potential buy and sell signals in the stock market. This strategy involves looking for a series of bars (or candles) that are either all increasing or all decreasing in price. If the bars are all increasing, it can be a signal to buy, and if the bars are all decreasing, it can be a signal to sell. This strategy can be used on any timeframe, from a daily chart to an intraday chart.
// 15m Range Length SD : Range Of High and Low Candle Price and Lookback For Calculate Buy and Sell.
Indicators Are Simple Source Script (Almost I'm Chating With CHAT-GPT and Convert pinescript V4 to V5 again for complete almost script and combine after)
// SwingHigh and SwingLow Plot For SL (StopLoss by Last Swing).
// Engulfing and 3 Candle Engulfing Plot.
// Stochastic RSI for Plot and Fill Background Paint and Plot TEXT For BULL and BEAR TREND.
// MA TYPE MODE are plot 2 line of MA Type (EMA, SMA, HMA, WMA, VWMA) for Crossover and Crossunder.
// Donchian Fans MODE are Plot Dot Line With Triangle Degree Bull Trend is Green Plot and Bear Trend is Red Plot.
// Ichimoku Cloud Are Plot Cloud A-B For Bull and Bear Trend.
// RSI OB and OS for TEXT PLOT 'OB' , 'OS' you will know after OB and OS, you can combo with other indicators that's make you know what's the similar trend look like?
// MACD for Plot Diamond when MACD > 0 and MACD < 0, you can combo with other indicators that's make you know what's the similar trend look like?
Alert Can Alert Sent When Buy and Sell or TP and SL, you can adjust text to alert sent by your self or use default setting.
========== Let'e Me Explain How To Use This Strategy =============
========== Properties Setting ==========
// Capital : Default : 1,000 USDT For Alot Of People Are Beginner Investor = It's Capital Your Cash For Investment
// Ordersize : Default Are Setting 5% / Order We Call Compounded
========== INPUT Setting ==========
// First Part Use Must Choose Checkbox For Use of Strategy and Choose TP/SL by Swing or % (can choose both)
// In Detail Of Setting Are Not Too Much, Please Read The Header Of Setting Before Change The Value
// For The Indicator In List You Want To Add Just Check ✅ From MODE Setting, It's Show On Your Chart
// You Can Custom TP/SL % You Want
========== ##### No trading strategy is guaranteed to be 100% successful. ###### =========
For Example In My Systematic Trading
Select 1/3 Strategy Setting TP/SL % Match With Timeframe TP Long Are Not Set It's Can 161.8 - 423.6% but Short Position Are Not Than 100% Just Fine From Your Aset
Choose Indicators For Make Sure Trend and Strategy are the same way like Strategy are Long Position but MACD and Sto background is bear. that's mean this time not open position.
Donchian Fans is Simple Support and Ressistant If You Don't Know How To Plot That's, This indicator plot a simple for you ><.
Make Sure With Engulfing and 3 Candle Engulfing If You Don't Know, What's The Engulfing, This Indicator are plot for you too ><.
For a Big Trend You can use Ichimoku Cloud For Check Trend, Candle Upper Than Cloud or Lower Than Cloud for Bull and Bear Trend.
I11L - Better Buy Low Volatility or High Volatility?This Pine Script code defines a TradingView strategy called "I11L - Better Buy Low Volatility or High Volatility?". The strategy aims to study the difference between buying when an asset's volatility is low and when it is high. It allows the user to select whether to buy during low or high volatility periods by changing the input variable mode.
Here's a brief explanation of the System:
The strategy is initialized with relevant settings such as overlay, pyramiding, default quantity type, initial capital, and others.
The mode input allows the user to choose between "Buy low Volatility" and "Buy high Volatility" options.
volatilityTargetRatio is the user-defined threshold to be used for making buy decisions. A value of 1 equals the average ATR (Average True Range) for the security. A lower value indicates lower volatility.
atrLength is the number of periods to calculate the ATR.
sellAfterNBarsLength sets the number of bars to hold the position before selling it.
The script calculates the ATR using the ta.atr() function, and then divides it by the closing price to normalize the value. It also calculates the simple moving average (SMA) of the normalized ATR over a period of 5 times the ATR length, and then computes the ratio between the normalized ATR and its average.
The script keeps track of the number of holding bars using the variable holdingBarsCounter. When there are open trades, the holding bars counter is incremented.
The decision to buy is made based on the selected mode and whether the computed ratio is above or below the user-defined threshold.
When the holding bars counter exceeds the user-defined limit, the position is closed.
The script plots the computed ratio with different colors based on the buy and close conditions. The ratio is plotted in green when a buy signal is triggered, red when a close signal is triggered, and white in all other cases. The value of 1 (the reference for the average ATR) is also plotted on the chart in white color.
This strategy helps traders study the difference between buying during low and high volatility periods and compare the performance of these conditions. It can be useful for analyzing the effectiveness of volatility-based trading strategies, such as entering positions when the market is calm or during periods of strong price movement.
JS-TechTrading: VWAP Momentum_Pullback StrategyGeneral Description and Unique Features of this Script
Introducing the VWAP Momentum-Pullback Strategy (long-only) that offers several unique features:
1. Our script/strategy utilizes Mark Minervini's Trend-Template as a qualifier for identifying stocks and other financial securities in confirmed uptrends.
NOTE: In this basic version of the script, the Trend-Template has to be used as a separate indicator on TradingView (Public Trend-Template indicators are available on TradingView – community scripts). It is recommended to only execute buy signals in case the stock or financial security is in a stage 2 uptrend, which means that the criteria of the trend-template are fulfilled.
2. Our strategy is based on the supply/demand balance in the market, making it timeless and effective across all timeframes. Whether you are day trading using 1- or 5-min charts or swing-trading using daily charts, this strategy can be applied and works very well.
3. We have also integrated technical indicators such as the RSI and the MA / VWAP crossover into this strategy to identify low-risk pullback entries in the context of confirmed uptrends. By doing so, the risk profile of this strategy and drawdowns are being reduced to an absolute minimum.
Minervini’s Trend-Template and the ‘Stage-Analysis’ of the Markets
This strategy is a so-called 'long-only' strategy. This means that we only take long positions, short positions are not considered.
The best market environment for such strategies are periods of stable upward trends in the so-called stage 2 - uptrend.
In stable upward trends, we increase our market exposure and risk.
In sideways markets and downward trends or bear markets, we reduce our exposure very quickly or go 100% to cash and wait for the markets to recover and improve. This allows us to avoid major losses and drawdowns.
This simple rule gives us a significant advantage over most undisciplined traders and amateurs!
'The Trend is your Friend'. This is a very old but true quote.
What's behind it???
• 98% of stocks made their biggest gains in a Phase 2 upward trend.
• If a stock is in a stable uptrend, this is evidence that larger institutions are buying the stock sustainably.
• By focusing on stocks that are in a stable uptrend, the chances of profit are significantly increased.
• In a stable uptrend, investors know exactly what to expect from further price developments. This makes it possible to locate low-risk entry points.
The goal is not to buy at the lowest price – the goal is to buy at the right price!
Each stock goes through the same maturity cycle – it starts at stage 1 and ends at stage 4
Stage 1 – Neglect Phase – Consolidation
Stage 2 – Progressive Phase – Accumulation
Stage 3 – Topping Phase – Distribution
Stage 4 – Downtrend – Capitulation
This strategy focuses on identifying stocks in confirmed stage 2 uptrends. This in itself gives us an advantage over long-term investors and less professional traders.
By focusing on stocks in a stage 2 uptrend, we avoid losses in downtrends (stage 4) or less profitable consolidation phases (stages 1 and 3). We are fully invested and put our money to work for us, and we are fully invested when stocks are in their stage 2 uptrends.
But how can we use technical chart analysis to find stocks that are in a stable stage 2 uptrend?
Mark Minervini has developed the so-called 'trend template' for this purpose. This is an essential part of our JS-TechTrading pullback strategy. For our watchlists, only those individual values that meet the tough requirements of Minervini's trend template are eligible.
The Trend Template
• 200d MA increasing over a period of at least 1 month, better 4-5 months or longer
• 150d MA above 200d MA
• 50d MA above 150d MA and 200d MA
• Course above 50d MA, 150d MA and 200d MA
• Ideally, the 50d MA is increasing over at least 1 month
• Price at least 25% above the 52w low
• Price within 25% of 52w high
• High relative strength according to IBD.
NOTE: In this basic version of the script, the Trend-Template has to be used as a separate indicator on TradingView (Public Trend-Template indicators are available in TradingView – community scripts). It is recommended to only execute buy signals in case the stock or financial security is in a stage 2 uptrend, which means that the criteria of the trend-template are fulfilled.
This strategy can be applied to all timeframes from 5 min to daily.
The VWAP Momentum-Pullback Strateg y
For the JS-TechTrading VWAP Momentum-Pullback Strategy, only stocks and other financial instruments that meet the selected criteria of Mark Minervini's trend template are recommended for algorithmic trading with this startegy.
A further prerequisite for generating a buy signals is that the individual value is in a short-term oversold state (RSI).
When the selling pressure is over and the continuation of the uptrend can be confirmed by the MA / VWAP crossover after reaching a price low, a buy signal is issued by this strategy.
Stop-loss limits and profit targets can be set variably.
Relative Strength Index (RSI)
The Relative Strength Index (RSI) is a technical indicator developed by Welles Wilder in 1978. The RSI is used to perform a market value analysis and identify the strength of a trend as well as overbought and oversold conditions. The indicator is calculated on a scale from 0 to 100 and shows how much an asset has risen or fallen relative to its own price in recent periods.
The RSI is calculated as the ratio of average profits to average losses over a certain period of time. A high value of the RSI indicates an overbought situation, while a low value indicates an oversold situation. Typically, a value > 70 is considered an overbought threshold and a value < 30 is considered an oversold threshold. A value above 70 signals that a single value may be overvalued and a decrease in price is likely , while a value below 30 signals that a single value may be undervalued and an increase in price is likely.
For example, let's say you're watching a stock XYZ. After a prolonged falling movement, the RSI value of this stock has fallen to 26. This means that the stock is oversold and that it is time for a potential recovery. Therefore, a trader might decide to buy this stock in the hope that it will rise again soon.
The MA / VWAP Crossover Trading Strategy
This strategy combines two popular technical indicators: the Moving Average (MA) and the Volume Weighted Average Price (VWAP). The MA VWAP crossover strategy is used to identify potential trend reversals and entry/exit points in the market.
The VWAP is calculated by taking the average price of an asset for a given period, weighted by the volume traded at each price level. The MA, on the other hand, is calculated by taking the average price of an asset over a specified number of periods. When the MA crosses above the VWAP, it suggests that buying pressure is increasing, and it may be a good time to enter a long position. When the MA crosses below the VWAP, it suggests that selling pressure is increasing, and it may be a good time to exit a long position or enter a short position.
Traders typically use the MA VWAP crossover strategy in conjunction with other technical indicators and fundamental analysis to make more informed trading decisions. As with any trading strategy, it is important to carefully consider the risks and potential rewards before making any trades.
This strategy is applicable to all timeframes and the relevant parameters for the underlying indicators (RSI and MA/VWAP) can be adjusted and optimized as needed.
Backtesting
Backtesting gives outstanding results on all timeframes and drawdowns can be reduced to a minimum level. In this example, the hourly chart for MCFT has been used.
Settings for backtesting are:
- Period from April 2020 until April 2021 (1 yr)
- Starting capital 100k USD
- Position size = 25% of equity
- 0.01% commission = USD 2.50.- per Trade
- Slippage = 2 ticks
Other comments
• This strategy has been designed to identify the most promising, highest probability entries and trades for each stock or other financial security.
• The RSI qualifier is highly selective and filters out the most promising swing-trading entries. As a result, you will normally only find a low number of trades for each stock or other financial security per year in case you apply this strategy for the daily charts. Shorter timeframes will result in a higher number of trades / year.
• As a result, traders need to apply this strategy for a full watchlist rather than just one financial security.
Extended Price Volume Trend Strategy : EducationalThe Extended Price Volume Trend (EPVT) is a technical indicator that is used to identify potential trend changes and measure the strength of a trend. In this strategy, we combine the EPVT with other indicators to create a trading system that aims to capture trend reversals and momentum shifts.
The EPVT indicator is calculated by taking the cumulative volume and multiplying it by the percentage change in price. We then find the highest and lowest values of this indicator over a certain period of time to determine the baseline. The difference between the EPVT and the baseline is then plotted on a chart to create the EPVT line.
To use this indicator for trading, we look for crossovers of the EPVT line with zero. When the EPVT crosses above zero, it indicates that buying pressure is increasing, and we may consider taking a long position. Conversely, when the EPVT crosses below zero, it indicates that selling pressure is increasing, and we may consider taking a short position.
To further refine our trading signals, we use three take-profit levels, which we set as a percentage of the current EPVT value. We also use a simple moving average to provide additional confirmation of trend changes.
In summary, the EPVT trading strategy is a technical analysis-based approach to trading that aims to identify potential trend reversals and momentum shifts. By combining the EPVT indicator with other technical tools, we can create a comprehensive trading system that provides clear entry and exit signals for both long and short positions. Please note that this strategy is for educational purposes only and should not be taken as financial advice.
Fair Value Strategy - ekmllThis is a strategy using SPX's Fair Value derived from Net Liquidity.
The main difference between this one and calebsandfort's one is net liquidity values in this one are calculated in TradingView and doesn't need author's daily library updates to function.
Net Liquidity function is simply: Fed Balance Sheet - Treasury General Account - Reverse Repo Balance
Formula for calculating the fair value of and Index using Net Liquidity looks like this: (WALCL - WTREGEN - RRPONTSYD)/1000000000/scalar - subtractor
The Index Fair Value is then subtracted from the Index value which creates an oscillating diff value.
When diff is greater than the overbought threshold, Index is considered overbought and we go short/sell.
When diff is less than the oversold signal, Index is considered oversold and we cover/buy.
Parameters:
Index: SPX, NDX, RUT
Strategy: Short Only, Long Only, Long/Short
Inverse (bool): check if using an inverse ETF to go long instead of short.
Scalar (float)
Subtractor (int)
Overbought Threshold (int)
Oversold Threshold (int)
Start After Date: When the strategy should start trading
Close Date: Day to close open trades. I just like it to get complete results rather than the strategy ending with open trades.
I've optimized the parameters for SPX.