Machine Learning: SuperTrend Strategy TP/SL [YinYangAlgorithms]The SuperTrend is a very useful Indicator to display when trends have shifted based on the Average True Range (ATR). Its underlying ideology is to calculate the ATR using a fixed length and then multiply it by a factor to calculate the SuperTrend +/-. When the close crosses the SuperTrend it changes direction.
This Strategy features the Traditional SuperTrend Calculations with Machine Learning (ML) and Take Profit / Stop Loss applied to it. Using ML on the SuperTrend allows for the ability to sort data from previous SuperTrend calculations. We can filter the data so only previous SuperTrends that follow the same direction and are within the distance bounds of our k-Nearest Neighbour (KNN) will be added and then averaged. This average can either be achieved using a Mean or with an Exponential calculation which puts added weight on the initial source. Take Profits and Stop Losses are then added to the ML SuperTrend so it may capitalize on Momentum changes meanwhile remaining in the Trend during consolidation.
By applying Machine Learning logic and adding a Take Profit and Stop Loss to the Traditional SuperTrend, we may enhance its underlying calculations with potential to withhold the trend better. The main purpose of this Strategy is to minimize losses and false trend changes while maximizing gains. This may be achieved by quick reversals of trends where strategic small losses are taken before a large trend occurs with hopes of potentially occurring large gain. Due to this logic, the Win/Loss ratio of this Strategy may be quite poor as it may take many small marginal losses where there is consolidation. However, it may also take large gains and capitalize on strong momentum movements.
Tutorial:
In this example above, we can get an idea of what the default settings may achieve when there is momentum. It focuses on attempting to hit the Trailing Take Profit which moves in accord with the SuperTrend just with a multiplier added. When momentum occurs it helps push the SuperTrend within it, which on its own may act as a smaller Trailing Take Profit of its own accord.
We’ve highlighted some key points from the last example to better emphasize how it works. As you can see, the White Circle is where profit was taken from the ML SuperTrend simply from it attempting to switch to a Bullish (Buy) Trend. However, that was rejected almost immediately and we went back to our Bearish (Sell) Trend that ended up resulting in our Take Profit being hit (Yellow Circle). This Strategy aims to not only capitalize on the small profits from SuperTrend to SuperTrend but to also capitalize when the Momentum is so strong that the price moves X% away from the SuperTrend and is able to hit the Take Profit location. This Take Profit addition to this Strategy is crucial as momentum may change state shortly after such drastic price movements; and if we were to simply wait for it to come back to the SuperTrend, we may lose out on lots of potential profit.
If you refer to the Yellow Circle in this example, you’ll notice what was talked about in the Summary/Overview above. During periods of consolidation when there is little momentum and price movement and we don’t have any Stop Loss activated, you may see ‘Signal Flashing’. Signal Flashing is when there are Buy and Sell signals that keep switching back and forth. During this time you may be taking small losses. This is a normal part of this Strategy. When a signal has finally been confirmed by Momentum, is when this Strategy shines and may produce the profit you desire.
You may be wondering, what causes these jagged like patterns in the SuperTrend? It's due to the ML logic, and it may be a little confusing, but essentially what is happening is the Fast Moving SuperTrend and the Slow Moving SuperTrend are creating KNN Min and Max distances that are extreme due to (usually) parabolic movement. This causes fewer values to be added to and averaged within the ML and causes less smooth and more exponential drastic movements. This is completely normal, and one of the perks of using k-Nearest Neighbor for ML calculations. If you don’t know, the Min and Max Distance allowed is derived from the most recent(0 index of data array) to KNN Length. So only SuperTrend values that exhibit distances within these Min/Max will be allowed into the average.
Since the KNN ML logic can cause these exponential movements in the SuperTrend, they likewise affect its Take Profit. The Take Profit may benefit from this movement like displayed in the example above which helped it claim profit before then exhibiting upwards movement.
By default our Stop Loss Multiplier is kept quite low at 0.0000025. Keeping it low may help to reduce some Signal Flashing while not taking extra losses more so than not using it at all. However, if we increase it even more to say 0.005 like is shown in the example above. It can really help the trend keep momentum. Please note, although previous results don’t imply future results, at 0.0000025 Stop Loss we are currently exhibiting 69.27% profit while at 0.005 Stop Loss we are exhibiting 33.54% profit. This just goes to show that although there may be less Signal Flashing, it may not result in more profit.
We will conclude our Tutorial here. Hopefully this has given you some insight as to how Machine Learning, combined with Trailing Take Profit and Stop Loss may have positive effects on the SuperTrend when turned into a Strategy.
Settings:
SuperTrend:
ATR Length: ATR Length used to create the Original Supertrend.
Factor: Multiplier used to create the Original Supertrend.
Stop Loss Multiplier: 0 = Don't use Stop Loss. Stop loss can be useful for helping to prevent false signals but also may result in more loss when hit and less profit when switching trends.
Take Profit Multiplier: Take Profits can be useful within the Supertrend Strategy to stop the price reverting all the way to the Stop Loss once it's been profitable.
Machine Learning:
Only Factor Same Trend Direction: Very useful for ensuring that data used in KNN is not manipulated by different SuperTrend Directional data. Please note, it doesn't affect KNN Exponential.
Rationalized Source Type: Should we Rationalize only a specific source, All or None?
Machine Learning Type: Are we using a Simple ML Average, KNN Mean Average, KNN Exponential Average or None?
Machine Learning Smoothing Type: How should we smooth our Fast and Slow ML Datas to be used in our KNN Distance calculation? SMA, EMA or VWMA?
KNN Distance Type: We need to check if distance is within the KNN Min/Max distance, which distance checks are we using.
Machine Learning Length: How far back is our Machine Learning going to keep data for.
k-Nearest Neighbour (KNN) Length: How many k-Nearest Neighbours will we account for?
Fast ML Data Length: What is our Fast ML Length?? This is used with our Slow Length to create our KNN Distance.
Slow ML Data Length: What is our Slow ML Length?? This is used with our Fast Length to create our KNN Distance.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
Learning
Machine Learning: Donchian DCA Grid Strategy [YinYangAlgorithms]This strategy uses a Machine Learning approach on the Donchian Channels with a DCA and Grid purchase/sell Strategy. Not only that, but it uses a custom Bollinger calculation to determine its Basis which is used as a mild sell location. This strategy is a pure DCA strategy in the sense that no shorts are used and theoretically it can be used in webhooks on most exchanges as it’s only using Spot Orders. The idea behind this strategy is we utilize both the Highest Highs and Lowest Lows within a Machine Learning standpoint to create Buy and Sell zones. We then fraction these zones off into pieces to create Grids. This allows us to ‘micro’ purchase as it enters these zones and likewise ‘micro’ sell as it goes up into the upper (sell) zones.
You have the option to set how many grids are used, by default we use 100 with max 1000. These grids can be ‘stacked’ together if a single bar is to go through multiple at the same time. For instance, if a bar goes through 30 grids in one bar, it will have a buy/sell power of 30x. Stacking Grid Buy and (sometimes) Sells is a very crucial part of this strategy that allows it to purchase multitudes during crashes and capitalize on sales during massive pumps.
With the grids, you’ll notice there is a middle line within the upper and lower part that makes the grid. As a Purchase Type within our Settings this is identified as ‘Middle of Zone Purchase Amount In USDT’. The middle of the grid may act as the strongest grid location (aside from maybe the bottom). Therefore there is a specific purchase amount for this Grid location.
This DCA Strategy also features two other purchase methods. Most importantly is its ‘Purchase More’ type. Essentially it will attempt to purchase when the Highest High or Lowest Low moves outside of the Outer band. For instance, the Lowest Low becomes Lower or the Higher High becomes Higher. When this happens may be a good time to buy as it is featuring a new High or Low over an extended period.
The last but not least Purchase type within this Strategy is what we call a ‘Strong Buy’. The reason for this is its verified by the following:
The outer bounds have been pushed (what causes a ‘Purchase More’)
The Price has crossed over the EMA 21
It has been verified through MACD, RSI or MACD Historical (Delta) using Regular and Hidden Divergence (Note, only 1 of these verifications is required and it can be any).
By default we don’t have Purchase Amount for ‘Strong Buy’ set, but that doesn’t mean it can’t be viable, it simply means we have only seen a few pairs where it actually proved more profitable allocating money there rather than just increasing the purchase amount for ‘Purchase More’ or ‘Grids’.
Now that you understand where we BUY, we should discuss when we SELL.
This Strategy features 3 crucial sell locations, and we will discuss each individually as they are very important.
1. ‘Sell Some At’: Here there are 4 different options, by default its set to ‘Both’ but you can change it around if you want. Your options are:
‘Both’ - You will sell some at both locations. The amount sold is the % used at ‘Sell Some %’.
‘Basis Line’ - You will sell some when the price crosses over the Basis Line. The amount sold is the % used at ‘Sell Some %’.
‘Percent’ - You will sell some when the Close is >= X% between the Lower Inner and Upper Inner Zone.
‘None’ - This simply means don’t ever Sell Some.
2. Sell Grids. Sell Grids are exactly like purchase grids and feature the same amount of grids. You also have the ability to ‘Stack Grid Sells’, which basically means if a bar moves multiple grids, it will stack the amount % wise you will sell, rather than just selling the default amount. Sell Grids use a DCA logic but for selling, which we deem may help adjust risk/reward ratio for selling, especially if there is slow but consistent bullish movement. It causes these grids to constantly push up and therefore when the close is greater than them, accrue more profit.
3. Take Profit. Take profit occurs when the close first goes above the Take Profit location (Teal Line) and then Closes below it. When Take Profit occurs, ALL POSITIONS WILL BE SOLD. What may happen is the price enters the Sell Grid, doesn’t go all the way to the top ‘Exiting it’ and then crashes back down and closes below the Take Profit. Take Profit is a strong location which generally represents a strong profit location, and that a strong momentum has changed which may cause the price to revert back to the buy grid zone.
Keep in mind, if you have (by default) ‘Only Sell If Profit’ toggled, all sell locations will only create sell orders when it is profitable to do so. Just cause it may be a good time to sell, doesn’t mean based on your DCA it is. In our opinion, only selling when it is profitable to do so is a key part of the DCA purchase strategy.
You likewise have the ability to ‘Only Buy If Lower than DCA’, which is likewise by default. These two help keep the Yin and Yang by balancing each other out where you’re only purchasing and selling when it makes logical sense too, even if that involves ignoring a signal and waiting for a better opportunity.
Tutorial:
Like most of our Strategies, we try to capitalize on lower Time Frames, generally the 15 minutes so we may find optimal entry and exit locations while still maintaining a strong correlation to trend patterns.
First off, let’s discuss examples of how this Strategy works prior to applying Machine Learning (enabled by default).
In this example above we have disabled the showing of ‘Potential Buy and Sell Signals’ so as to declutter the example. In here you can see where actual trades had gone through for both buying and selling and get an idea of how the strategy works. We also have disabled Machine Learning for this example so you can see the hard lines created by the Donchian Channel. You can also see how the Basis line ‘white line’ may act as a good location to ‘Sell Some’ and that it moves quite irregularly compared to the Donchian Channel. This is due to the fact that it is based on two custom Bollinger Bands to create the basis line.
Here we zoomed out even further and moved back a bit to where there were dense clusters of buy and sell orders. Sometimes when the price is rather volatile you’ll see it ‘Ping Pong’ back and forth between the buy and sell zones quite quickly. This may be very good for your trades and profit as a whole, especially if ‘Only Buy If Lower Than DCA’ and ‘Only Sell If Profit’ are both enabled; as these toggles will ensure you are:
Always lowering your Average when buying
Always making profit when selling
By default 8% commission is added to the Strategy as well, to simulate the cost effects of if these trades were taking place on an actual exchange.
In this example we also turned on the visuals for our ‘Purchase More’ (orange line) and ‘Take Profit’ (teal line) locations. These are crucial locations. The Purchase More makes purchases when the bottom of the grid has been moved (may dictate strong price movement has occurred and may be potential for correction). Our Take Profit may help secure profit when a momentum change is happening and all of the Sell Grids weren’t able to be used.
In the example above we’ve enabled Buy and Sell Signals so that you can see where the Take Profit and Purchase More signals have occurred. The white circle demonstrates that not all of the Position Size was sold within the Sell Grids, and therefore it was ALL CLOSED when the price closed below the Take Profit Line (Teal).
Then, when the bottom of the Donchian Channel was pushed further down due to the close (within the yellow circle), a Purchase More Signal was triggered.
When the close keeps pushing the bottom of the Buy Grid lower, it can cause multiple Purchase More Signals to occur. This is normal and also a crucial part of this strategy to help lower your DCA. Please note, the Purchase More won’t trigger a Buy if the Close is greater than the DCA and you have ‘Only Purchase If Lower Than DCA’ activated.
By turning on Machine Learning (default settings) the Buy and Sell Grid Zones are smoothed out more. It may cause it to look quite a bit different. Machine Learning although it looks much worse, may help increase the profit this Strategy can produce. Previous results DO NOT mean future results, but in this example, prior to turning on Machine Learning it had produced 37% Profit in ~5 months and with Machine Learning activated it is now up to 57% Profit in ~5 months.
Machine Learning causes the Strategy to focus less on Grids and more on Purchase More when it comes to getting its entries. However, if you likewise attempt to focus on Purchase More within non Machine Learning, the locations are different and therefore the results may not be as profitable.
PLEASE NOTE:
By default this strategy uses 1,000,000 as its initial capital. The amount it purchases in its Settings is relevant to this Initial capital. Considering this is a DCA Strategy, we only want to ‘Micro’ Buy and ‘Micro’ Sell whenever conditions are met.
Therefore, if you increase the Initial Capital, you’ll likewise want to increase the Purchase Amounts within the Settings and Vice Versa. For instance, if you wish to set the Initial Capital to 10,000, you should likewise can the amounts in the Settings to 1% of what they are to account for this.
We may change the Purchase Amounts to be based on %’s in a later update if it is requested.
We will conclude this Tutorial here, hopefully you can see how a DCA Grid Purchase Model applied to Machine Learning Donchian Channels may be useful for making strategic purchases in low and high zones.
Settings:
Display Data:
Show Potential Buy Locations: These locations are where 'Potentially' orders can be placed. Placement of orders is dependant on if you have 'Only Buy If Lower Than DCA' toggled and the Price is lower than DCA. It also is effected by if you actually have any money left to purchase with; you can't buy if you have no money left!
Show Potential Sell Locations: These locations are where 'Potentially' orders will be sold. If 'Only Sell If Profit' is toggled, the sell will only happen if you'll make profit from it!
Show Grid Locations: Displaying won't affect your trades but it can be useful to see where trades will be placed, as well as which have gone through and which are left to be purchased. Max 100 Grids, but visuals will only be shown if its 20 or less.
Purchase Settings:
Only Buy if its lower than DCA: Generally speaking, we want to lower our Average, and therefore it makes sense to only buy when the close is lower than our current DCA and a Purchase Condition is met.
Compound Purchases: Compounding Purchases means reinvesting profit back into your trades right away. It drastically increases profits, but it also increases risk too. It will adjust your Purchase Amounts for the Purchase Type you have set at the same % rate of strategy initial_capital to the amounts you have set.
Adjust Purchase Amount Ratio to Maintain Risk level: By adjusting purchase levels we generally help maintain a safe risk level. Basically we generally want to reserve X amount of % for each purchase type being used and relocate money when there is too much in one type. This helps balance out purchase amounts and ensure the types selected have a correct ratio to ensure they can place the right amount of orders.
Stack Grid Buys: Stacking Buy Grids is when the Close crosses multiple Buy Grids within the same bar. Should we still only purchase the value of 1 Buy Grid OR stack the grid buys based on how many buy grids it went through.
Purchase Type: Where do you want to make Purchases? We recommend lowering your risk by combining All purchase types, but you may also customize your trading strategy however you wish.
Strong Buy Purchase Amount In USDT: How much do you want to purchase when the 'Strong Buy' signal appears? This signal only occurs after it has at least entered the Buy Zone and there have been other verifications saying it's now a good time to buy. Our Strong Buy Signal is a very strong indicator that a large price movement towards the Sell Zone will likely occur. It almost always results in it leaving the Buy Zone and usually will go to at least the White Basis line where you can 'Sell Some'.
Buy More Purchase Amount In USDT: How much should you purchase when the 'Purchase More' signal appears? This 'Purchase More' signal occurs when the lowest level of the Buy Zone moves lower. This is a great time to buy as you're buying the dip and generally there is a correction that will allow you to 'Sell Some' for some profit.
Amount of Grid Buy and Sells: How many Grid Purchases do you want to make? We recommend having it at the max of 10, as it will essentially get you a better Average Purchase Price, but you may adjust it to whatever you wish. This amount also only matters if your Purchase Type above incorporates Grid Purchases. Max 100 Grids, but visuals will only be shown if it's 20 or less.
Each Grid Purchase Amount In USDT: How much should you purchase after closing under a grid location? Keep in mind, if you have 10 grids and it goes through each, it will be this amount * 10. Grid purchasing is a great way to get a good entry, lower risk and also lower your average.
Middle Of Zone Purchase Amount In USDT: The Middle Of Zone is the strongest grid location within the Buy Zone. This is why we have a unique Purchase Amount for this Grid specifically. Please note you need to have 'Middle of Zone is a Grid' enabled for this Purchase Amount to be used.
Sell:
Only Sell if its Profit: There is a chance that during a dump, all your grid buys when through, and a few Purchase More Signals have appeared. You likely got a good entry. A Strong Buy may also appear before it starts to pump to the Sell Zone. The issue that may occur is your Average Purchase Price is greater than the 'Sell Some' price and/or the Grids in the Sell Zone and/or the Strong Sell Signal. When this happens, you can either take a loss and sell it, or you can hold on to it and wait for more purchase signals to therefore lower your average more so you can take profit at the next sell location. Please backtest this yourself within our YinYang Purchase Strategy on the pair and timeframe you are wanting to trade on. Please also note, that previous results will not always reflect future results. Please assess the risk yourself. Don't trade what you can't afford to lose. Sometimes it is better to strategically take a loss and continue on making profit than to stay in a bad trade for a long period of time.
Stack Grid Sells: Stacking Sell Grids is when the Close crosses multiple Sell Grids within the same bar. Should we still only sell the value of 1 Sell Grid OR stack the grid sells based on how many sell grids it went through.
Stop Loss Type: This is when the Close has pushed the Bottom of the Buy Grid More. Do we Stop Loss or Purchase More?? By default we recommend you stay true to the DCA part of this strategy by Purchasing More, but this is up to you.
Sell Some At: Where if selected should we 'Sell Some', this may be an important way to sell a little bit at a good time before the price may correct. Also, we don't want to sell too much incase it doesn't correct though, so its a 'Sell Some' location. Basis Line refers to our Moving Basis Line created from 2 Bollinger Bands and Percent refers to a Percent difference between the Lower Inner and Upper Inner bands.
Sell Some At Percent Amount: This refers to how much % between the Lower Inner and Upper Inner bands we should well at if we chose to 'Sell Some'.
Sell Some Min %: This refers to the Minimum amount between the Lower Inner band and Close that qualifies a 'Sell Some'. This acts as a failsafe so we don't 'Sell Some' for too little.
Sell % At Strong Sell Signal: How much do we sell at the 'Strong Sell' Signal? It may act as a strong location to sell, but likewise Grid Sells could be better.
Grid and Donchian Settings:
Donchian Channel Length: How far back are we looking back to determine our Donchian Channel.
Extra Outer Buy Width %: How much extra should we push the Outer Buy (Low) Width by?
Extra Inner Buy Width %: How much extra should we push the Inner Buy (Low) Width by?
Extra Inner Sell Width %: How much extra should we push the Inner Sell (High) Width by?
Extra Outer Sell Width %: How much extra should we push the Outer Sell (High) Width by?
Machine Learning:
Rationalized Source Type: Donchians usually use High/Low. What Source is our Rationalized Source using?
Machine Learning Type: Are we using a Simple ML Average, KNN Mean Average, KNN Exponential Average or None?
Machine Learning Length: How far back is our Machine Learning going to keep data for.
k-Nearest Neighbour (KNN) Length: How many k-Nearest Neighbours will we account for?
Fast ML Data Length: What is our Fast ML Length?? This is used with our Slow Length to create our KNN Distance.
Slow ML Data Length: What is our Slow ML Length?? This is used with our Fast Length to create our KNN Distance.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
Kioseff Trading - AI-Optimized RSIAI-Optimized RSI
Introducing AI-Optimized RSI: a streamlined solution for traders of any skill level seeking to rapidly test and optimize RSI. Capable of analyzing thousands of strategies, this tool cuts through the complexity to identify the most profitable, reliable, or efficient approaches.
Paired with TradingView's native backtesting capabilities, the AI-Optimized RSI learns from historical performance data. Set up is easy for all skill levels, and it makes fine-tuning trading alerts and RSI straightforward.
Features
Purpose : Uncover optimal RSI settings and entry levels with precision. Say goodbye to random guesses and arbitrary indicator use—this tool provides clear direction based on data.
Target Performance : You set the goal, and AI-RSI seeks it out, whether it's maximizing profits, efficient trading, or achieving the highest win rate.
AI-Powered : With intelligent AI recommendations, the tool dynamically fine-tunes your RSI approach, steering you towards ideal strategy performance.
Rapid Testing : Evaluate thousands of RSI strategies.
Dual Direction : Perfect both long and short RSI strategies with equal finesse.
Deep Insights : Access detailed metrics including profit factor, PnL, win rate, trade counts, and more, all within a comprehensive strategy script.
Instant Alerts : Set alerts and trade.
Full Customization : Test and optimize all RSI settings, including cross levels, profit targets and stop losses.
Simulated Execution : Explore the impact of limit orders and other trade types through simulation.
Integrative Capability : Combine your own custom indicators or others from the TradingView community for a personalized optimization experience.
Flexible Timeframes : Set your optimization and backtesting to any date range.
Key Settings
The image above shows explanations for a list of key settings for the optimizer.
Direction : This setting controls trade direction: Long or Short.
Entry Condition : Define RSI entry: Select whether to trigger trades on RSI crossunders or crossovers.
RSI Lengths Range : Choose the range of RSI periods to test and find the best one.The AI will find the best RSI period for you.
RSI Cross Range : Set the range for RSI levels where crosses trigger trade signals. The AI will find the best level for you.
Combinations : Select how many RSI strategies to compare.
Optimization Type : Choose the goal for optimization and the AI: profit, win rate, or efficiency.
Profit Target : Set your profit target with this setting.
Stop Loss : Decide your maximum allowable loss (stop loss) per trade.
Limit Order : Specify whether to include limit orders in the strategy.
Stop Type : Choose your stop strategy: a fixed stop loss or a trailing stop.
How to: Find the best RSI for trading
It's important to remember that merely having the AI-Optimized RSI on your chart doesn't automatically provide you with the best strategy. You need to follow the AI's guidance through an iterative process to discover the optimal RSI settings and strategy.
1.Starting Your Strategy Setup
Begin by deciding your goals for each trade: your profit target and stop loss. You'll also choose how to manage your stops – whether they stay put (fixed) or move with the price (trailing), and whether you want to exit trades at a specific price (limit orders). Keep the initial settings for RSI lengths and cross ranges at their default to give the tool a broad testing field. The AI's guidance will refine these settings to pinpoint the most effective ones through a process of comprehensive testing.
The image above shows our chart prior to any optimization efforts.
Note: the settings shown above in the key settings section will be used to start our demonstration.
2. Follow AI’s suggestions
Optimization Prompt: After loading your strategy, the indicator will prompt you to change the RSI length range and RSI level range to a better performing range.
Continue changing the RSI length range and RSI level range to match the indicator's suggestions until "Best Found" is displayed!
The image above shows results after we applied the tool’s suggestions. New suggestions have appeared, and we will continue to apply them.
Continue to adjust settings as recommended by the optimizer. If no better options are found, the optimizer will suggest increasing the number of combinations. Repeat this process until the optimizer indicates that the optimal setting has been identified.
Success! With the "Best Found" notification, an optimized RSI is now active. The AI will keep refining the strategy based on ongoing performance, ensuring continuous optimization.
AI Mode
AI Mode incorporates Heuristic-Based Adaptive Learning to fine-tune trading strategies in a continuous manner. This feature consists of two main components:
Heuristic-Based Decision Making: The algorithm evaluates multiple RSI-based trading strategies using specific metrics such as Profit and Loss (PNL), Win Rate, and Most Efficient Profit. These metrics act as heuristics to assist the algorithm in identifying suitable strategies for trade execution.
Online Learning: The algorithm updates the performance evaluations of each strategy based on incoming market data. This enables the system to adapt to current market conditions.
Incorporating both heuristic-based decision-making and online learning, this feature aims to provide a framework for trading strategy optimization.
Settings
AI Mode Aggressiveness:
Description: The "AI Mode Aggressiveness" setting allows you to fine-tune the AI's trading behavior. This setting ranges from “Low” to “High”, with “High” indicating a more assertive trading approach.
Functionality: This feature filters trading strategies based on a proprietary evaluation method. A higher setting narrows down the strategies that the AI will consider, leaning towards more aggressive trading. Conversely, a lower setting allows for a more conservative approach by broadening the pool of potential strategies.
Adaptive Learning Aggressiveness:
Description: When Adaptive Learning is enabled, the "Adaptive Learning Aggressiveness" setting controls how dynamically the AI adapts to market conditions using selected performance metrics.
Functionality: This setting impacts the AI's responsiveness to shifts in strategy performance. By adjusting this setting, you can control how quickly the AI moves away from strategies that may have been historically successful but are currently underperforming, towards strategies that are showing current promise.
Optimization
Trading system optimization is immensely advantageous when executed with prudence.
Technical-oriented, mechanical trading systems work when a valid correlation is methodical to the extent that an objective, precisely-defined ruleset can consistently exploit it. If no such correlation exists, or a technical-oriented system is erroneously designed to exploit an illusory correlation (absent predictive utility), the trading system will fail.
Evaluate results practically and test parameters rigorously after discovery. Simply mining the best-performing parameters and immediately trading them is unlikely a winning strategy. Put as much effort into testing strong-performing parameters and building an accompanying system as you would any other trading strategy. Automated optimization involves curve fitting - it's the responsibility of the trader to validate a replicable sequence or correlation and the trading system that exploits it.
Kioseff Trading - AI-Optimized Supertrend
AI-Optimized Supertrend
Introducing AI-Optimized Supertrend: a streamlined solution for traders of any skill level seeking to rapidly test and optimize Supertrend. Capable of analyzing thousands of strategies, this tool cuts through the complexity to identify the most profitable, reliable, or efficient approaches.
Paired with TradingView's native backtesting capabilities, the AI-Optimized Supertrend learns from historical performance data. Set up is easy for all skill levels, and it makes fine-tuning trading alerts and Supertrend straightforward.
Features
Rapid Supertrend Strategy Testing : Quickly evaluate thousands of Supertrend strategies to find the most effective ones.
AI-Assisted Optimization : Leverage AI recommendations to fine-tune strategies for superior results.
Multi-Objective Optimization : Prioritize Supertrend based on your preference for the highest win rate, maximum profit, or efficiency.
Comprehensive Analytics : The strategy script provides an array of statistics such as profit factor, PnL, win rate, trade counts, max drawdown, and an equity curve to gauge performance accurately.
Alerts Setup : Conveniently set up alerts to be notified about critical trade signals or changes in performance metrics.
Versatile Stop Strategies : Experiment with profit targets, trailing stops, and fixed stop losses.
Binary Supertrend Exploration : Test binary Supertrend strategies.
Limit Orders : Analyze the impact of limit orders on your trading strategy.
Integration with External Indicators : Enhance strategy refinement by incorporating custom or publicly available indicators from TradingView into the optimization process.
Key Settings
The image above shows explanations for a list of key settings for the optimizer.
Set the Factor Range Limits : The AI suggests optimal upper and lower limits for the Factor range, defining the sensitivity of the Supertrend to price fluctuations. A wider range tests a greater variety, while a narrower range focuses on fine-tuning.
Adjust the ATR Range : Use the AI's recommendations to establish the upper and lower bounds for the Average True Range (ATR), which influences the Supertrend's volatility threshold.
ATR Flip : This option lets you interchange the order of ATR and Factor values to quicky test different sequences, giving you the flexibility to explore various combinations and their impact on the Supertrend indicator's performance.
Strategies Evaluated : Adjust this setting to determine how many Supertrend strategies you want to assess and compare.
Enable AI Mode : Turn this feature on to allow the AI to determine and employ the optimal Supertrend strategy with the desired performance metric, such as the highest win rate or maximum profitability.
Target Metric : Adjust this to direct the AI towards optimizing for maximum profit, top win rates, or the most efficient profits.
AI Mode Aggressiveness : Set how assertively the AI pursues the chosen performance goal, such as highest profit or win rate.
Strategy Direction : Choose to focus the AI's testing and optimization on either long or short Supertrend strategies.
Stop Loss Type : Specify the stop loss approach for optimization—fixed value, a trailing stop, or Supertrend direction changes.
Limit Order : Decide if you want to execute trades using limit orders for setting your profit targets, stop losses, or apply them to both.
Profit Target : Define your desired profit level when using either a fixed stop loss or a trailing stop.
Stop Loss : Define your desired stop loss when using either a fixed stop loss or a trailing stop.
How to: Find the best Supertrend for trading
It's important to remember that merely having the AI-Optimized Supertrend on your chart doesn't automatically provide you with the best strategy. You need to follow the AI's guidance through an iterative process to discover the optimal Supertrend settings and strategy.
Optimizing Supertrend involves adjusting two key parameters: the Factor and the Average True Range (ATR). These parameters significantly influence the Supertrend indicator's sensitivity and responsiveness to price movements.
Factor : This parameter multiplies the ATR to determine the distance of the Supertrend line from the price. Higher values will create a wider band, potentially leading to fewer trade signals, while lower values create a narrower band, which may result in more signals but also more noise.
ATR (Average True Range) : ATR measures market volatility. By using the ATR, the Supertrend adapts to changing market volatility; a higher ATR value means a more volatile market, so the Supertrend adjusts accordingly.
During the optimization process, these parameters are systematically varied to determine the combination that yields the best performance based on predefined criteria such as profitability, win rate, or risk management efficiency. The optimization aims to find the optimal Factor and ATR settings.
1.Starting Your Strategy Setup
Begin by deciding your goals for each trade: your profit target and stop loss, or if all trades exit when Supertrend changes direction. You'll also choose how to manage your stops – whether they stay put (fixed) or move with the price (trailing), and whether you want to exit trades at a specific price (limit orders). Keep the initial settings for Supertrend Factor Range and Supertrend ATR Range at their default to give the tool a broad testing field. The AI's guidance will refine these settings to pinpoint the most effective ones through a process of comprehensive testing.
Demonstration Start: We'll begin with the settings outlined in the key settings section, using Supertrend's direction change to the downside as our exit signal for all trades.
2. Continue applying the AI’s suggestions
Keep updating your optimization settings based on the AI's recommendations. Proceed with this iterative optimization until the "Best Found" message is displayed, signaling that the most effective strategy has been identified.
While following the AI's suggestions, we've been prompted with a new suggestion: increase the
number of strategies evaluated. Keep following the AI's new suggestions to evaluate more strategies. Do this until the "Best Found" message shows up.
Success! We continued to follow the AI’s suggestions until “Best Found” was indicated!
AI Mode
AI Mode incorporates Heuristic-Based Adaptive Learning to fine-tune trading strategies in a continuous manner. This feature consists of two main components:
Heuristic-Based Decision Making: The algorithm evaluates multiple Supertrend-based trading strategies using metrics such as Profit and Loss (PNL), Win Rate, and Most Efficient Profit. These metrics act as heuristics to assist the algorithm in identifying suitable strategies for trade execution.
Online Learning: The algorithm updates the performance evaluations of each strategy based on incoming market data. This enables the system to adapt to current market conditions.
Incorporating both heuristic-based decision-making and online learning, this feature aims to provide a framework for trading strategy optimization.
AI Mode Settings
AI Mode Aggressiveness:
Description: The "AI Mode Aggressiveness" setting allows you to fine-tune the AI's trading behavior. This setting ranges from “Low” to “High”, with “High” indicating a more assertive trading approach.
Functionality: This feature filters trading strategies based on a proprietary evaluation method. A higher setting narrows down the strategies that the AI will consider, leaning towards more aggressive trading. Conversely, a lower setting allows for a more conservative approach by broadening the pool of potential strategies.
Optimization
Trading system optimization is immensely advantageous when executed with prudence.
Technical-oriented, mechanical trading systems work when a valid correlation is methodical to the extent that an objective, precisely-defined ruleset can consistently exploit it. If no such correlation exists, or a technical-oriented system is erroneously designed to exploit an illusory correlation (absent predictive utility), the trading system will fail.
Evaluate results practically and test parameters rigorously after discovery. Simply mining the best-performing parameters and immediately trading them is unlikely a winning strategy. Put as much effort into testing strong-performing parameters and building an accompanying system as you would any other trading strategy. Automated optimization involves curve fitting - it's the responsibility of the trader to validate a replicable sequence or correlation and the trading system that exploits it.
Cava Signals Backtesting/VisualizerPLEASE READ THE DESCRIPTION CAREFULLY
Trying this again, as it seems I keep violating the rules unintentionally. Moderator, please forgive me as I try to make this right.
This backtesting/visualizer script was created for me to get a visual idea of the Cava Signals indicator throughout its development time and continuous optimization.
This script is to be used on the 30-minute timeframe on supported markets, and whether I can only publish strategies on regular candles, the indicator is meant to trigger on heikin ashi candles.I understand backtesting on non-regular candles produces unrealistic results, but I emphasize that this script is more for visualization purposes rather than accurate $ amounts from the trades. The signals are used along with a dedicated bot configuration, so part of the strategy is not managed by the script, but by the bot's config.
Some behind the scenes on what we are looking at:
a combination of ema and sma crosses on different time frames (5m, 15m, 30m, 60m and 90m) - we call this the wave trend
a combination of stochastic rsi on different time frames (10m, 30m)
a combination of schaff trend cycles on different time frames (5m, 20m and 30m)
a combination of money flow index on different time frames (10m and 30m)
volume information for each supported market/pair
and a couple of other info particular to each pair
With the above combination of data points, we try to optimize our strategy for an entry, for dca'ing down in case the coin goes down as well as dca'ing up to maximize profit when a coin is going up, take profit levels when we recognize a good time to do so, and of course, a closing level. I would like to emphasize the *visualization* purpose of this script in recognizing lows, highs, and market structure to identify the important levels to signal - this script is NOT to be used for accurate backtesting, but for an idea of the overall performance of when signals are triggered.
Let me try to explain the workflow and icons you see on the chart:
The colored circles on the bottom of the chart are all buy signals; each color corresponds to a particular buy signal, we have a combination of 9 possible situations that would trigger a buy signal. Some would trigger a buy signal only in combination with other buy signals or other indicators within the script. we also display a green upwards arrow below bars when a buy signal is triggered.
The colored arrows pointing down on the top of the chart are close signals. We have a combination of 5 closing criteria each color corresponds to one, just like the buy signals do. We only close a trade in profit. If not in profit, we will look to DCA down.
DCA signals are shown by the green flag above bars. they are signals to DCA up or down depending on the trade being negative or positive. DCA'ing up or down is also managed by the bot's configuration for limits on when to accept the signal.
Take Profit levels are shown by the green diamond above bars and work in conjunction with the bot's config on when to take the signal if at all and other take profit levels. Usually, when we hit the first take profit level we move our stop loss to entry via the bot's take profit safety feature. You can see this call with the close entry named TPS .
The black bars you may see on the chart is to illustrate when the market is extended based on a particular strategy. During this period we will not trigger a buy signal unless there is a huge spike in positive volume .
The green number below the bars is the total positive delta volume on the buy candles.
On the table on the right upper corner, we show some information on the market and performance of the backtesting - for visualization purposes only!
Currently, the script is tailored to work with the following markets/pairs:
Binance Spot: ADA, ALGO, ATOM, AVAX, BNB, BTC , DOT, ETH, LINK, LUNA, MATIC, SOL, VET, XRP, XTZ
Binance Futures: BTC , ETH, ADA, ALGO, ATOM, BNB, COMP, DOT, ENJ , LINK, OCEAN, OMG, SOL, VET, XMR, XRP, XTZ, AVAX, AAVE, DOGE, LTC, LUNA, MKR , NEAR, ONT, RUNE, SUSHI, LTC, XLM , COMP, ONT, THETA, FTM , EGLD , WAVES, ONE, HTN , CHZ , HOT, MANA, CRV , RVN, BAT, ANKR, 1INCH, ALICE, ATA , AXS , CHR , COTI, NKN , RAY, REN, SRM , SXP , TLM
ByBit Inverse Perpetual: BTCUSD , ETHUSD
ByBit Futures: AAVE, ADA, ALGO, AVAX, AXS , BNB, BTC , DOT, ETH, LINK, LTC, MATIC, SOL, SUSHI, UNI , XEM, XRP, XTZ
The chosen pairs are subject to change based on the best-performing assets we are constantly analyzing.
I hope this helps to understand the script, its purpose and ideas. I hope this satisfies the community rules - it was not my intention to break them - if there's anything on the above or the script that still violates the guidelines, please let me know and accept my apologies in advance.
If anyone would like to know more, let me know in the comment section.
Thank you!
DMI + HMA - No Risk ManagementDMI (Directional Movement Index) and HMA (Hull Moving Average)
The DMI and HMA make a great combination, The DMI will gauge the market direction, while the HMA will add confirmation to the trend strength.
What is the DMI?
The DMI is an indicator that was developed by J. Welles Wilder in 1978. The Indicator was designed to identify in which direction the price is moving. This is done by comparing previous highs and lows and drawing 2 lines.
1. A Positive movement line
2. A Negative movement line
A third line can be added, which would be known as the ADX line or Average Directional Index. This can also be used to gauge the strength in which direction the market is moving.
When the Positive movement line (DI+) is above the Negative movement line (DI-) there is more upward pressure. Ofcourse visa versa, when the DI- is above the DI+ that would indicate more downwards pressure.
Want to know more about HMA? Check out one of our other published scripts
What is this strategy doing?
We are first waiting for the DMI to cross in our favoured direction, after that, we wait for the HMA to signal the entry. Without both conditions being true, no trade will be made.
Long Entries
1. DI+ crosses above DI-
2. HMA line 1 is above HMA line 2
Short Entries
1. DI- Crosses above DI+
2. HMA line 1 is below HMA lilne 2
Its as simple as that.
Conclusion
While this strategy does have its downsides, that can be reduced by adding some risk manegment into the script. In general the trade profitability is above average, And the max drawdown is at a minimum.
The settings have been optimised to suite BTCUSDT PERP markets. Though with small adjustments it can be used on many assets!
Flawless Victory Strategy - 15min BTC Machine Learning StrategyHello everyone, I am a heavy Python programmer bringing machine learning to TradingView. This 15 minute Bitcoin Long strategy was created using a machine learning library and 1 year of historical data in Python. Every parameter is hyper optimized to bring you the most profitable buy and sell signals for Bitcoin on the 15min chart. The historical Bitcoin data was gathered from Binance API, in case you want to know the best exchange to use this long strategy. It is a simple Bollinger Band and RSI strategy with two versions included in the tradingview settings. The first version has a Sharpe Ratio of 7.5 which is amazing, and the second version includes the best stop loss and take profit positions with a Sharpe Ratio of 2.5 . Let me talk a little bit more about how the strategy works. The buy signal is triggered when close price is less than lower Bollinger Band at Std Dev 1, and the RSI is greater than a certain value. The sell signal is triggered when close price is greater than upper Bollinger Band at Std Dev 1, and the RSI is greater than a certain value. What makes this strategy interesting is the parameters the Machine Learning library found when backtesting for the best Sharpe Ratio. I left my computer on for about 28 hours to fully backtest 5000 EPOCHS and get the results. I was able to create a great strategy that might be one of TradingView's best strategies out on the website today. I will continue to apply machine learning to all my strategies from here on forward. Please Let me know if you have any questions or certain strategies you would like me to hyper optimize for you. I'm always willing to create profitable strategies!
P.S. You can always pyramid this strategy for more gains! I just don't add pyramiding when creating my strategies because I want to show you the true win/loss ratio based buying one time and one selling one time. I feel like when creating a strategy that includes pyramiding right off the bat falsifies the win rate. This is my way of being transparent with you all. Have fun trading!
Rsi, Ema , Ma and Bollinger Bands for 1 min BtcusdtThis is for 1 min Btcusdt pair.
I am tring to find a way to catch %1 ups and downs.
Basicly it buys when rsi low and minute candle closes under ema,ma and lower bollinger band,
it sells when candle goes over upper bb,low ma, when rsi high.
It sells when rsi high ,candle closes over upper bb,over low ma and does the opposite when buying.
I know it's crowded but still tring to learn what to do ^^
I welcome any suggestions to improve.
It works better with shorts for now.
Don't buy with this !! You might lose big !
Simple Price Momentum - How To Create A Simple Trading StrategyThis script was built using a logical approach to trading systems. All the details can be found in a step by step guide below. I hope you enjoy it. I am really glad to be part of this community. Thank you all. I hope you not only succeed on your trading career but also enjoy it.
docs.google.com
Channel Break Out Binary StrategyI am learning pine script at the moment and this is my first attempt at creating an expire time based strategy for binary options based on a simple example like the built-in Channel Break Out Strategy.