Kahlman HullMA / WT Cross StrategyA strategy created using Hull Moving Average and WT Cross .
Hull Moving Average turns green and WT Cross crossover this is a long. Otherwise short.
Stop Loss and Take Profit settings are available. You can set it to the level you want or turn it off.
According to my measurements, it shows the best performance in the 4-hour period. But you can find the best settings that are correct from the Strategy settings.
Moving Averages
Top 40 High Low Strategy for SPY, 5minThis strategy is developed based on my High Low Index SPY Top 40 indicator
Notes:
- this strategy is only developed for SPY on the 5 min chart . It seems to work with QQQ as well, but it isn't optimized for it
- P/L shown is based on 10 SPY option contracts, call or put, with strike price closest to the entry SPY price and expiry of 0 to 1 day. This includes commissions (can be changed). This is only an estimate calculated using an arbitrary multiplier factor, this can be changed in the setting
- P/L is based on $5000 initial capital
- Works with both regular / extended trading session turned on/off. However, max drawdown is 1/2 with extended trading session ON
- there is still a bug that doesn't allow alert to be created due to calculation error, will update once fixed
This strategy combines signals from the following indicators to determine entry signals:
- High Low Index SPY Top 40
- MACD
- Linear Regression Slope
Entry signal is triggered when:
- High Low Index line crosses the EMA line
- MACD trending in the same direction
- Linear Regression slope is accelerating above a threshold in the same direction, indicating a strong trend
Profit target(PT) and stop loss(SL) are determined using ATR value, with 2:1 Reward to Risk ratio as default.
Exit signal may be triggered prior to PT or SL trigger when:
- High Low Index SPY Top 40 shows a reversal after overbought or oversold conditions (optional)
- Opposite entry signal is triggered
There are a number of optional settings:
- Turn on/off "option trading", P/L will be calculated using share price only without multiplication factor for trading option contracts
- # of options per trade, default to 10
- Reinvest with profit made
- Trade with trailing SL after PT hit
- Take profit early based on Top 40 overbought/oversold
- Trade 0/1 day expiry. This will signal exit by the end of the day on Mon/Wed/Fri, and only exits 1/2 of positions (if in profit) on Tues/Thurs
- Can reduce the SL level without impacting PT
- No entry between 10:05 - 10:20 (don't ask me why, but statistically it performs better)
Consider donating me some of your profit if you make $$$ hahaha~ ;)
Enjoy~~
rsisma imkind dailyrsi 14
sma 8
time fram : weekly and daily
rsi 14
sma 8
time fram : weekly and daily
rsi 14
sma 8
time fram : weekly and daily
rsi 14
sma 8
time fram : weekly and daily
EMA StratIf previous day close above EMA, enter long at open the following day. Exit long position if prices close below EMA.
EDMA Scalping Strategy (Exponentially Deviating Moving Average)This strategy uses crossover of Exponentially Deviating Moving Average (MZ EDMA ) along with Exponential Moving Average for trades entry/exits. Exponentially Deviating Moving Average (MZ EDMA ) is derived from Exponential Moving Average to predict better exit in top reversal case.
EDMA Philosophy
EDMA is calculated in following steps:
In first step, Exponentially expanding moving line is calculated with same code as of EMA but with different smoothness (1 instead of 2).
In 2nd step, Exponentially contracting moving line is calculated using 1st calculated line as source input and also using same code as of EMA but with different smoothness (1 instead of 2).
In 3rd step, Hull Moving Average with 2/3 of EDMA length is calculated using final line as source input. This final HMA will be equal to Exponentially Deviating Moving Average.
EDMA Defaults
Currently default EDMA and EMA length is set to 20 period which I've found better for higher timeframes but this can be adjusted according to user's timeframe. I would soon add Multi Timeframe option in script too. Chikou filter's period is set to 25.
Additional Features
EMA Band: EMA band is shown on chart to better visualize EMA cross with EDMA .
Dynamic Coloring: Chikou Filter library is used for derivation of dynamic coloring of EDMA and its band.
Trade Confirmation with Chikou Filter: Trend filteration from Chikou filter library is used as an option to enhance trades signals accuracy.
Strategy Default Test Settings
For backtesting purpose, following settings are used:
Initial capital=10000 USD
Default quantity value = 5 % of total capital
Commission value = 0.1 %
Pyramiding isn't included.
Backtesting data never assures that the same results would occur in future and also above settings use very less of total portfolio for trades, which in a way results less maximum drawdown along with less total profit on initial capital too. For example, increasing default quantity value will definity increase maximum drawdown value. The other way is also to use fix contracts in backtesting but it all depends on users general practice. Best option is to explore backtesting results with manually modified settings on different charts, before trusting them for other uses in future.
Usage and In-Detail Backtesting
This strategy has built-in option to enable trade confirmations with Chikou filter which will reduce the total number of trades increasing profit factor.
Symmetrically Weighted Moving Average (SWMA) on input source, may risk repainting in real-time data. Better option is to run a trade on bar close or simply left this optin unchecked.
I've set Chikou filter unchecked to increase number of trades (greater than 100) on higher timeframe (12H) and this can be changed according to your precision requirement and timeframe.
Timeframes lower than 4H usually have more noise. So its better to use higher EDMA and EMA length on lower timeframes which will decrease total number of offsetting trades increasing average total number of bars within a single trade.
Original "Exponentially Deviating Moving Average (MZ EDMA )" Indicator can be found here.
Trend Follower Strategy v2 [divonn1994]The Trend Follower Strategy that I made classifies red and green candles into tiny, small, and big sizes and will send buy or sell signals depending on if the candle is classified as "big" so you get into and out of a position when there is a big candle. Out during a big green candle to take profit. Out during a big red candle in case the market is turning down. It also won't enter a position unless there is positive EMA momentum.
For the chart there is a Buy and a Sell signal. Buy = 1, Sell = 0, and when the value crosses above or below 0.5 it will trigger a long position or close the long position. The graph isn't necessary to the strategy, but can help with visualizing the trade patterns in the past if you like.
This strategy works best so far with these coins at time of posting (March 4th, 2022):
KCSUSDT (621x profit), HTUSDT (45x profit), LUNAUSDT (45x profit), BNBBTC (1553x profit), ETHBTC (219x profit), KCSBTC (1222x profit), LUNABTC (83x profit), FTMBTC (52x profit).
It can work with other pairings, but I personally like these pairings best. I didn't test it with coins outside of the top 100 coins by market cap. Use it however you want.
Works best on 1 Day charts.
The strategy would rather be in the market than out. It gets out when it see's a red flag, but can immediately go back in in the next bar if the red flags are all gone. So it makes a lot of trades.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Update: This is the same strategy I uploaded before but I made the code Open for anyone to check it out and so it has a similar description as the previous version. Let me know what you think. I'd remove the old version if I could, but I guess it's site policy to not be able to remove scripts that have been uploaded.
DayTradingFutures Cross-StrategyOVERVIEW
This indicator was designed to help beginners use a cross over strategy that can be used for entries, exits and to for trend direction.
█ COMPONENTS
Here is a brief overview of the indicator:
Weighted Moving Averages
I find that by using a weighted moving average ( WMA ) to show a crossover, is very close to using a MACD signal line cross or using a RSI signal crossing over the 50/Mid Line. In my main strategy, I use the 5period (fast) and with the crossing of the 20period (slow) WMA for entries and the 50period WMA to show the short term trend. Please note, that I use the 50 period for day trading, if you are using a swing trade or plan on holding positions long term, a higher period may be preferred . All of the moving averages are customizable by color, length, and timeframe. **I feel comfortable trading this strategy at the 5min,10min, and 15min charts.
1 — 5 WMA- this is the white moving average closest to price and is the first part of our small cloud.
2 — 20 WMA - this is the yellow moving average and is the second part of or small cloud.
3 — 50 WMA - this is the directional trend.
Moving Average Clouds
The cloud (which is optional) appears when the trader should be looking to go Long or Sell Short. The dividing line is when both the 5 and 20 periods are over the 50 period.
Trade Management
This is a tool to help with setting your stop loss, break even, and target levels. Currently you can set these based on the current ATR ( Average True Range ).
The “Buy” and “Sell” signals are the ATR indicator based on your risk tolerance (fully customizable). Different ticker symbols will require different ATR values, please back test! When applying your stop loss, drag the stop line to small arrow of the signal callout.
Trading Session
The indicator was designed for beginners to trade during the New York Session (08:30 – 16:00 CST). However, the indicator will ONLY show signals AFTER opening and BEFORE close (09:00 – 14:30 CST). The reason for this is that there is greater volatility during the open and I do not recommend to be in a trade at the end of the session.
Buy and Sell Alerts
Alerts can also be set, when an entry can be made. This prevents a person from having to watch the charts for an extended period of time.
Faults of this strategy:
Time of RANGES/CONSOLIDATION periods and EXTREME VOLITITY KILLs this strategy!! Do not trade this strategy during these periods!!
Disclaimer:
NO strategy is 100% effective! I am not responsible for any loss trades or malfunctions of this code. I recommend to paper trade any new strategy before trading with real money! I am not a financial advisor, trading can be very risky!
Zlema Strateg Long 5mJust putting this out there.
I created this Strategy based on Everget Zlema.
Opens long trade when Zlema changes color.
It is profitable as it is, but just putting it out to the community to see if someone else has ideas to make it better.
How to make this strategy better?
1. FInd a way to filter ranging bad trades.
2. Trades would be more profitable if entry point had an entry on the candle the zlema changes color.
3. I had to put TP 5 limit, but the optimal would be when the zlema changes color back to red (if ranging trades can we filtered that is).
In any case, just putting it out there, hope it is useful for someone, and I am open to suggestions.
Follow the Crypto ShortsThis script allows to test the impact of variations in the number of BTCUSD Shorts Positions on its price. In particular, it compares the number of short positions with its moving average to decide if shorts are being liquidated. In case the number of short positions crosses below its moving average, it will generate a Long Position, which will be closed if shorts crosses above its moving average.
Mayer Multiple StrategyCreated by Trace Mayer, the Mayer Multiple is calculated dividing the current price of Bitcoin by its 200-day moving average. This simple script allows to backtest strategies based on Mayer Multiple levels, which can be easily adjusted. It can be tested on any chart and any timeframe.
ddosok10 1min start(1볼추 매매법) 1분봉 볼밴 +3% 매매 체크 (유튜버 리또속10)
+거미줄 200틱마다 걸어놓기(익절+3 지정)
상단 볼밴 찍고 중앙선 터치 후
캔들 종가가 중앙선 아래에 있을때
숏 진입 후 하단 볼밴 터치할때쯤 익절(+3% 지정)
(허리에 들어가 무릎에 팔기)
하단 볼밴 찍고 중앙선 터치 후
캔들 종가가 중앙선 위에 있을때
롱 진입 후 상단 볼밴 터치할때쯤 익절(+3% 지정)
(허리에 들어가 가슴에 팔기)
* 포지션 동시 2개들어가서 하나 익절 하나 들고가기도 가능
BEAM DCA Strategy MonthlyThis strategy is based on BEAM bands for BTC. The space between the original BEAM bands is broken up into 10 bands representing levels of risk for investing fresh capital.
The strategy will buy bitcoin when the price is in the bottom 5 bands, increasing the amount investmented as the price approaches the 1400 D SMA.
The strategy will limit sell bitcoin when the price is in the top 5 bands, increasing the amount sold as the price approaches the upper BEAM band.
Best used on Daily timeframe and on a chart with history of price data, i.e. INDEX:BTCUSD or BITSTAMP:BTCUSD
To use the strategy:
Set start date
Set day of month to invest
Set the maximum amount to be invested on any given month
Toggle buy/sell orders
Observe the backtest
You can see how the strategy backtests via the information boxes in the bottom right.
There is also functionality to adjust the bands for diminishing returns. Note, this should be used with great skepticism, as the adjustments were made by simple function fitting and not rigorous statistical processes.
That about sums it up! As you can see, even with just a small amount of capital invested at regular intervals can lead to huge realised gains using this version of BEAM bands!
Combo 2/20 EMA & Adaptive Price Zone This is combo strategies for get a cumulative signal.
First strategy
This indicator plots 2/20 exponential moving average. For the Mov
Avg X 2/20 Indicator, the EMA bar will be painted when the Alert criteria is met.
Second strategy
The adaptive price zone (APZ) is a volatility-based technical indicator that helps investors
identify possible market turning points, which can be especially useful in a sideways-moving
market. It was created by technical analyst Lee Leibfarth in the article “Identify the
Turning Point: Trading With An Adaptive Price Zone,” which appeared in the September 2006 issue
of the journal Technical Analysis of Stocks and Commodities.
This indicator attempts to signal significant price movements by using a set of bands based on
short-term, double-smoothed exponential moving averages that lag only slightly behind price changes.
It can help short-term investors and day traders profit in volatile markets by signaling price
reversal points, which can indicate potentially lucrative times to buy or sell. The APZ can be
implemented as part of an automated trading system and can be applied to the charts of all tradeable assets.
WARNING:
- For purpose educate only
- This script to change bars colors.
Template Trailing Strategy (Backtester)💭 Overview
💢 What is the "Template Trailing Strategy” ❓
The "Template Trailing Strategy" (TTS) is a back-tester orchestration framework. It supercharges the implementation-test-evaluation lifecycle of new trading strategies, by making it possible to plug in your own trading idea.
While TTS offers a vast number of configuration settings, it primarily allows the trader to:
Test and evaluate your own trading logic that is described in terms of entry, exit, and cancellation conditions.
Define the entry and exit order types as well as their target prices when the limit, stop, or stop-limit order types are used.
Utilize a variety of options regarding the placement of the stop-loss and take-profit target(s) prices and support for well-known techniques like moving to breakeven and trailing.
Provide well-known quantity calculation methods to properly handle risk management and easily evaluate trading strategies and compare them.
Alert on each trading event or any related change through a robust and fully customizable messaging system.
All the above, build a robust tool that, once learned, significant and repetitive work that strategy developers often implement individually on every strategy script is eliminated. Taking advantage of TradingView’s built-in backtesting engine the evaluation of the trading ideas feels natural.
By utilizing the TTS one can easily swap “trading logic” by testing, evaluating, and comparing each trading idea and/or individual component of a strategy.
Finally, TTS, through its per-event alert management (and debugging) system, provides a fully automated solution that supports automated trading with real brokers via webhooks.
NOTE: The “Template Trailing Strategy” does not dictate the way you can combine different (types of) indicators or how you should combine them. Thus, it should not be confused as a “Trading System”, because it gives its user full flexibility on that end (for better or worse).
💢 What is a “Signal Indicator” ❓
“Signal Indicator” (SI) is an indicator that can output a “signal” that follows a specific convention so that the “Template Trailing Strategy” can “understand” and execute the orders accordingly. The SI realizes the core trading logic signaling to the TTS when to enter, exit, or cancel an order. A SI instructs the TTS “when” to enter or exit, and the TTS determines “how” to enter and exit the position once the Signal Indicator generates a signal.
A very simple example of a Signal Indicator might be a 200-day Simple Moving Average Signal. When the price of the security closes above the 200-day SMA, a SI would provide TTS with a “long entry signal”. Once TTS receives the “long entry signal”, the TTS will open a long position and send an alert or automated trade message via webhook to a broker, based on the Entry settings defined in TTS. If the TTS Entry settings specify a “Market” order type, then the open long position will be executed by TTS immediately. But if the TTS Entry settings specify a “Stop” order type with a 1% Stop Distance, then when the price of the security rises by 1% after the “long entry signal” occurs, the TTS will open a long position and the Long Entry alert or webhook to the broker will be sent.
🤔 How to Guide
💢 How to connect a “signal” from a “Signal Indicator” ❓
The “Template Trailing Strategy” was designed to receive external signals from a “Signal Indicator”. In this way, a “new trading idea” can be developed, configured, and evaluated separately from the TTS. Similarly, the SI can be held constant, and the trading mechanics can change in the TTS settings and back-tested to answer questions such as, “Am I better with a different stop loss placement method, what if I used a limit order instead of a stop order to enter, what if I used 25% margin instead of trading spot market?”
To make that possible by connecting an external signal indicator to TTS, you should:
Add in the same chart, the “Signal Indicator” of your choice (e.g. “Two MA Signal Indicator” , “Click Signal Indicator” , “Signal Adapter” , “Signal Composer” ) and the “Template Trailing Strategy”.
Go to the “Settings/Inputs” tab in the “🛠️ STRATEGY” group of the TTS and change the "𝐃𝐞𝐚𝐥 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐬 𝐌𝐨𝐝𝐞" to “🔨External”
Go to the “🔨 STRATEGY – EXTERNAL” group settings of the TTS and change the “🔌𝐒𝐢𝐠𝐧𝐚𝐥 🛈➡” to the output signal of the “Signal Indicator” you want to connect. The selected combo box option should look like “:🔌Signal to TTS” where should correspond to the short title of your “Signal Indicator”
💢 How to create a Custom Trading logic ❓
The “Template Trailing Strategy” provides two ways to plug in your custom trading logic. Both of them have their advantages and disadvantages.
✍️ Develop your own Customized “Signal Indicator” 💥
The first approach is meant to be used for relatively more complex trading logic. The advantages of this approach are the full control and customization you have over the trading logic and the relatively simple configuration setup by having two scripts only. The downsides are that you have to have some experience with pinescript or you are willing to learn and experiment. You should also know the exact formula for every indicator you will use since you have to write it by yourself. Copy-pasting from existing open-source indicators will get you started quite fast though.
The idea here is either to create a new indicator script from scratch or to copy an existing non-signal indicator and make it a “Signal Indicator”. To create a new script, press the “Pine Editor” button below the chart to open the “Pine Editor” and then press the “Open” button to open the drop-down menu with the templates. Select the “New Indicator” option. Add it to your chart to copy an existing indicator and press the source code {} button. Its source code will be shown in the “Pine Editor” with a warning on top stating that this is a read-only script. Press the “create a working copy”. Now you can give a descriptive title and a short title to your script, and you can work on (or copy-paste) the (other) indicators of your interest. Having all the information needed to make your decision the only thing you should do is define a DealConditions object and plot it like this:
import jason5480/tts_convention/4 as conv
// Calculate the start, end, cancel start, cancel end conditions
dealConditions = conv.DealConditions.new(
startLongDeal = ,
startShortDeal = ,
endLongDeal = ,
endShortDeal = ,
cnlStartLongDeal = ,
cnlStartShortDeal = ,
cnlEndLongDeal = ,
cnlEndShortDeal = )
// Use this signal in scripts like "Template Trailing Strategy" and "Signal Composer" that can use its value
// Emit the current signal value according to the "two channels mod div" convention
plot(series = conv.getSignal(dealConditions), title = '🔌Signal to TTS', color = color.olive, display = display.data_window + display.status_line, precision = 0)
You should write your deal conditions appropriately based on your trading logic and put them in the code section shown above by replacing the “…” part after “=”. You can omit the conditions that are not relevant to your logic. For example, if you use only market orders for entering and exiting your positions the cnlStartLongDeal, cnlStartShortDeal, cnlEndLongDeal, and cnlEndShortDeal are irrelevant to your case and can be safely omitted from the DealConditions object. After successfully compiling your new custom SI script add it to the same chart with the TTS by pressing the “Add to chart” button. If all goes well, you will be able to connect your “signal” to the TTS as described in the “How to connect a “signal” from a “Signal Indicator”?” guide.
🧩 Adapt and Combine existing non-signal indicators 💥
The second approach is meant to be used for relatively simple trading logic. The advantages of this approach are the lack of pine script and coding experience needed and the fact that it can be used with closed-source indicators as long as the decision-making part is displayed as a line in the chart. The drawback is that you have to have a subscription that supports the “indicator on indicator” feature so you can connect the output of one indicator as an input to another indicator. Please check if your plan supports that feature here
To plug in your own logic that way you have to add your indicator(s) of preference in the chart and then add the “Signal Adapter” script in the same chart as well. This script is a “Signal Indicator” that can be used as a proxy to define your custom logic in the CONDITIONS group of the “Settings/Inputs” tab after defining your inputs from your preferred indicators in the VARIABLES group. Then a “signal” will be produced, if your logic is simple enough it can be directly connected to the TTS that is also added to the same chart for execution. Check the “How to connect a “signal” from a “Signal Indicator”?” in the “🤔 How to Guide“ for more information.
If your logic is slightly more complicated, you can add a second “Signal Adapter” in your chart. Then you should add the “Signal Composer” in the same chart, go to the SIGNALS group of the “Settings/Inputs” tab, and connect the “signals” from the “Signal Adapters”. “Signal Composer” is also a SI so its composed “signal” can be connected to the TTS the same way it is described in the “How to connect a “signal” from a “Signal Indicator”?” guide.
At this point, due to the composability of the framework, you can add an arbitrary number (bounded by your subscription of course) of “Signal Adapters” and “Signal Composers” before connecting the final “signal” to the TTS.
💢 How to set up ⏰Alerts ❓
The “Template Trailing Strategy” provides a fully customizable per-even alert mechanism. This means that you may have an entirely different message for entering and exiting into a position, hitting a stop-loss or a take-profit target, changing trailing targets, etc. There are no restrictions, and this gives you great flexibility.
First of all, you have to enable the alerts of the events that interest you. Go to the “🔔 ALERT MESSAGES” module of the TTS settings and check the “Enable…” checkbox of the events you are interested in. For each specific event, you will find a text area where you can type the exact message you want to receive when the event occurs. What’s more, there are placeholders you can use that will be replaced by the TTS with the actual values before the message is sent. The placeholder categories are the following and the placeholder names are self-explanatory.
Chart info: {{ticker}}, {{base_currency}}, {{quote_currency}}
Quantities and percentages: {{base_quantity}}, {{quote_quantity}}, {{quote_quantity_perc}},
{{take_profit_base_quantity}}, {{remaining_quantity_perc}}, {{remaining_base_quantity}}, {{risk_perc}}
Target prices: {{stop_loss_price}}, {{entry_price}}, {{entry+_price}}, {{entry-_price}},
{{exit_price}}, {{exit+_price}}, {{exit-_price}}, {{take_profit_price_1}},
{{take_profit_price_2}}, {{take_profit_price_3}}, {{take_profit_price_4}}, {{take_profit_price_5}}
❗ To get the message on the other side you have to set a strategy alert as described here and use the {{strategy.order.alert_message}} placeholder as text in the “Message Box” that contains the message that came from the TTS.
💢 How to execute my orders in a broker ❓
To execute your orders in a broker that supports webhook integration, you should enable the appropriate alerts in the “Template Trailing Strategy” first (see the “How to set up Alerts?” guide above). Then you should go to the “Create Alert/Notifications” tab check the “Webhook URL” and paste the URL provided by your broker. You have to read the documentation of your broker for more information on what messages are expected.
Keep in mind that some brokers have deep integration with TradingView so a per-event alert approach might be overkill.
📑 Definitions
This section tries to give some definitions in terms that appear in the “Settings/Inputs" tab of the “Template Trailing Strategy”
💢 What is Trailing ❓
Trailing is a technique where a price target follows another “barrier” price (usually high or low) by trying to keep a maximum distance from the “barrier” when it moves in only one direction (up or down). When the “barrier” moves in the other direction the price target will not change. There are as many types of trailing as price targets, which means that there are entry trailing, exit trailing, stop-loss trailing, and take-profit trailing techniques.
💢 What is a Moonbag ❓
A Moonbag in a trade is the quantity of the position that is reserved and will not be exited even if all take-profit targets defined in the strategy are hit, the quantity will be exited only if the stop-loss is hit or a close signal is received. This makes the stop-loss trailing technique in a trend-following strategy a good candidate to take advantage of a Moonbag.
💢 What is Distance ❓
Distance is the difference between two prices.
💢 What is Bias ❓
Bias is a psychological phenomenon where you make decisions based on market sentiment. For example, when you want to enter a long position you have a long bias, and when you want to exit from the long position you have a short bias. It is the other way around for the short position.
💢 What is the Margin Distance of a price target ❓
The Margin Distance of a price target is the distance that the target will deviate from its initial price. The direction of this deviation depends on the bias of the market. For example, suppose you are in a long position, and you set a take-profit target to the local high (HHLL). In that case, adding a margin of five ticks will place your take-profit target 5 ticks below this local high because you have a short bias when exiting a long position. When the bias is long the margin will be added resulting in a higher target price and when you have a short bias the margin will be subtracted.
⚙️ Settings
In the “Settings/Inputs” tab of the “Template Trailing Strategy”, you can find all the customizable settings that are provided by the framework. The variety of those settings is vast; hence we will only scratch the surface here. However, for every setting, there is an information icon 🛈 where you can learn more if you mouse over it. The “Settings/Inputs” tab is divided into ten main groups. Each one of them is responsible for one module of the framework. Every setting is part of a group that is named after the module it represents. So, to spot the module of a setting find the title that appears above it comes with an emoji and uppercase letters. Some settings might have the same name but belong to different modules e.g. “Distance Method”. Some settings are indented, which means that are closely related to the non-indented setting above. Usually, intended settings provide further configuration for one or more options of the non-intended setting. The groups that correspond to each module of the framework are the following:
📆 FILTERS
In this module time filters are implemented. You can define a DateTime window for your strategy to run. You can also specify a session by selecting the days of the week and the time range you want to operate.
🛠️ STRATEGY
This module contains the "𝐃𝐞𝐚𝐥 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐬 𝐌𝐨𝐝𝐞" that defines if the “Template Trailing Strategy” will operate using the Internal or the External (“Signal Indicator”) conditions. Some general settings can be applied regardless of the mode.
🔨 STRATEGY – EXTERNAL
This sub-module makes the connection between the external signal of the “Signal Indicator” and the “Template Trailing Strategy”. It takes effect only if the "𝐃𝐞𝐚𝐥 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐬 𝐌𝐨𝐝𝐞" is set to “🔨External”.
🔧 STRATEGY – INTERNAL
This sub-module defines the internal strategy logic and it's used as an example to demonstrate this framework. It should produce the same results as if the “Two MA Signal Indicator” was used as a “signal” in external mode. It takes effect only if the "𝐃𝐞𝐚𝐥 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐬 𝐌𝐨𝐝𝐞" is set to “🔧Internal”.
🎢 VOLATILITY
This module defines the volatility parameters that are used in various other settings like average true range and standard deviation. It also makes it clear whether their values are updated during a trade (DYNAMIC) or not (STATIC).
🔷 ENTRY
This module defines how the start deal conditions will be executed by defining the order type of your entry and all necessary parameters to execute them.
🎯 TAKE PROFIT
This module defines the take-profit targets placement logic. The number of the take-profit targets to use, their distance from the entry price, and the distance from each other are only some of the features that can be configured.
🛑 STOP LOSS
This module defines the stop-loss target placement logic. The distance from the entry price, move to break even, and start trailing after a take-profit target is hit are only some of the features that can be configured.
🟪 EXIT
This module defines how the end deal conditions will be executed by defining the order type of your exit and all necessary parameters to execute them.
💰 QUANTITY/RISK MANAGEMENT
This module defines the method that calculates the amount of money you will put into each trade. Also, the percentage of the Moonbag quantity can be configured.
📊 ANALYTICS
This module can visualize some extra analytics of the strategy in the chart and calculate some metrics to measure the overall performance.
🔔 ALERT MESSAGES
This module defines all the messages that can be emitted per event during the strategy execution.
😲 Caveats
💢 Does “Template Trailing Strategy” has a repainting behavior ❓
The answer is that the “Template Trailing Strategy” does not repaint as long as the “Signal Indicator” that is connected also does not repaint. If you developed your own SI make sure that you understand and know how to prevent this behavior. The publication by @PineCoders here will give you a good idea on how to avoid most of the repainting cases.
⚠️There is an exception though, when the “Enable Trail⚠️💹” checkbox is checked, the Take Profit trailing feature is enabled, and a tick-based approach is used, meaning that after a while, when the TradingView discards all the real-time data, assumptions will be made by the backtesting engine that will cause a form of repainting. To avoid making false assumptions please disable this feature in the early stages and evaluate its usefulness in your strategy later on, after first confirming the success of the logic without this feature. In this case, consider turning on the bar magnifier feature. This way you will get more accurate backtest results when the Take Profit trailing feature is enabled.
💢 Can “Template Trailing Strategy” satisfy all my trading strategies ❓
While this framework can satisfy quite a large number of trading strategies there are cases where it cannot do so. For example, if you have a custom logic for your stop-loss or take-profit placement, or if you want to dollar cost average, then it might be better to start a new strategy script from scratch.
⚠️ It is not recommended to copy the official TTS code and start developing unless you are a pine wizard! Even in that case, there is a stiff learning curve that might not be worth your time. Last, you must consider that I do not offer support for customized versions of the TTS script and if something goes wrong in the process you are all alone.
🤗 Thanks
Special thanks to @upslidedown and @metadimensional, who regularly gave feedback all those years and helped me to shape the framework as it is today! Thanks to @EltAlt, @PlusUltraTrading, and everyone else who contributed by either filing a “defect report” or asking questions that helped me to understand what improvements were necessary.
Enjoy!
Jason
Trailing SellThis script demonstrates how to do trailing sell. With this approach, given an exit signal, instead of selling directly, you just follow the price upwards (for long positions) and you sell when the price decreases by a small percentage. The order will be executed when the next bar is closed. This approach may increase the profits (slightly) in some strategies! This script can be used as a template for your own strategy. Be aware that the simulated data may produce unrealistic results.
Long Term Heat/Volatility - Accumulation/Distribution v1This is a strategy specifically made for 1D BTC/USD with the aim of capturing cycle tops and bottoms. It's mainly based on two indicators: 21d average of ATR (volatility) and (BTC.price - 180d sma)/BTC.price (heat). The strategy only signals buys or sells after occurrences of high volatility, followed by extremely high or low heat values. It's optimized for utilizing accumulation and distribution at lower and higher prices respectively with respect to last 14 days. 2nd version will include dynamic dollar cost averaging during the accumulation and distribution periods.
Heikin Ashi EMA v5 no repaint This script was inspired by the "Heikin/Kaufman Strategy" from marco valente built on v2.
The script was rebuilt on the v5 and most importantly removed the repaint function that was driving surrealistic backtesting inflated numbers.
This script is now fully functional and not repainting - At the time of testing worked efficiently 90% WR and 2x profit factor on CFD WTI OIL with a 15m time frame indexed on forex.com price.
You should utilize this script with caution, especially on high volatility cycles you can try plotting against a volatility relative index or stop.
I also strongly recommend understanding the fundamentals of WTI OIL to balance the indications of the strategy with fundamentals.
Thanks to Clovis Warlop and Nilesh Sharma for their contribution.
Cheers,
Gustavo Bramao
STR:EMA Oscilator [Azzrael]Strategy based on EMA and EMA Oscilator
(EMA - close) + Std Dev + Factor = detecting oversell/overbuy
Long only!
Pyramiding - sometimes, depends on ...
There're 2 enter strategies in one script:
1 - Classic, buy on entering to OverSell zone (more profitable ~> 70%)
2 - Crazy, buy on entering to OverBuy zone (catching trend and pyramiding, more net profit)
Exit - crossing zero of (EMA - close)
sma RSI & sudden buy and sell Strategy v1This strategy uses mostly three things:-
1. average RSI (sma rsi over a period)
2. sudden buy and sudden sell (usually to infer the change in trend or direction)
3. various EMAs ( used as a filter)
I mostly build it to work on a 3min crypto chart but it should work on any timeframe or any symbol.
Settings - Length -RSI length (hardly needed to be changed but sometimes it doubles the net profit)(+/-2)
instant length - a sudden increase or decrease in the price calculated by the length of RSI (+/-10)
Bars - No of candles to verify before starting /closing the strategy (+/-20)
Lookbackno2 - another variable to verify ema opening/closing (hardly needed to change)
emas - values of different EMAs (you can change if you want but I don't recommend it though)
over40 and over60 - the value of overbuying and overselling(+/-10)
In future, I will probably add ADX or use machine learning to filter out results
It works well considering 0.05% commission per entry and exit (total of 1% per trade)
you can message me for any query or suggestions.
Mix1 : Ema Cross + Trend Channel [Gu5] - BacktestBacktest of the indicator "Mix1: Ema Cross + Trend Channel "
Trend indicator, by the crossing of moving averages
SMA200 with a channel as a filter confirms the trend.
The crossing of two moving averages, give alert only in trend.
Stochastic & MAThis trading system comes from the experience of having a "fast" signal for entry at low prices (such as the stoscastic) and then "following" the stock with a "slower" indicator such as the exponential moving average. Both the input and output signals are filtered.
The use of the trading system only carries out long operations and has been tested on shares and ETFs, including indices, on daily bases (End Of Day).
ENTRY CONDITION: when stochastic's k is higher than d (on the default value of 21 periods) we enter the lower part of the oversold, to which we apply a filter or the confirmation that the closing of the day of the crossing is higher than that of the n -th previous bar (the 2nd previous bar recommended).
Other default settings are k = 6 and d = 4; the oversold level is also customizable (recommended = 25).
EXIT CONDITIONS: once the entry has "gone well", we follow the upward trend of the stock not with a stochastic oscillator - which tends to exit too soon, especially in case of strong trends - but with a simple moving average exponential (by default at 38 periods). Also in this case a filter is added, that is, k must be> to a filter threshold (recommended = 65) which is used to distinguish the decline between a "physiological" tracking. "(k drops" slowly "together with the approach of prices to the moving average) from a more" violent "tracking (prices are below the moving average and k consequently fall" suddenly ", in a few bars).
MONEY MANAGEMENT: 13% stop loss inserted (the physiological level of tracking of the shares is generally max 8-12% so we also consider a 1% margin due to trading). For more volatile stocks, the level can be extended to 20%.
LEVERAGE: the default value is equal to 1, but it is advisable, for simulations on shares, to use higher levers (x2, x3, ...) if you trade the relative CFD or on the index in case of buying and selling of Leveraged ETFs (e.g. LEVMIB which is 2x leveraged ETFs on Italian index).
R3 ETF StrategyThis strategy is a modification of the “R3 Strategy” from the book "High Probability ETF Trading" by Larry Connors and Cesar Alvarez. This RSI strategy is for a 1-day time-frame and has these 3 simple rules:
Criteria:
The price must be above the 200 day moving average.
The 2-period (day) RSI drops 3 days in a row.
The 2-period RSI must have been below 60 3 days ago and below 10 today.
Entry and Exit:
If the 3 rules above are true, then buy on the close of the current day.
Exit on the day's close when the RSI crosses above 70.
How it works :
The Strategy will buy when the buy conditions above are true. The strategy will sell when the RSI crosses above 70. The RSI period/length, and RSI entry/exit criteria thresholds have all been coded to be adjustable with inputs.
Plots :
Blue line = 200 Day EMA (Used as Entry Criteria)
Disclaimer: Open-source scripts I publish in the community are largely meant to spark ideas that can be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
3 Candle Strike StretegyMainly developed for AMEX:SPY trading on 1 min chart. But feel free to try on other tickers.
Basic idea of this strategy is to look for 3 candle reversal pattern within trending market structure. The 3 candle reversal pattern consist of 3 consecutive bullish or bearish candles,
followed by an engulfing candle in the opposite direction. This pattern usually signals a reversal of short term trend. This strategy also uses multiple moving averages to filter long or short
entries. ie. if the 21 smoothed moving average is above the 50, only look for long (bullish) entries, and vise versa. There is option change these moving average periods to suit your needs.
I also choose to use Linear Regression to determine whether the market is ranging or trending. It seems the 3 candle pattern is more successful under trending market. Hence I use it as a filter.
There is also an option to combine this strategy with moving average crossovers. The idea is to look for 3 candle pattern right after a fast moving average crosses over a slow moving average.
By default , 21 and 50 smoothed moving averages are used. This gives additional entry opportunities and also provides better results.
This strategy aims for 1:3 risk to reward ratio. Stop losses are calculated using the closest low or high values for long or short entries, respectively, with an offset using a percentage of
the daily ATR value. This allows some price fluctuation without being stopped out prematurely. Price target is calculated by multiplying the difference between the entry price and the stop loss
by a factor of 3. When price target is reach, this strategy will set stop loss at the price target and wait for exit condition to maximize potential profit.
This strategy will exit an order if an opposing 3 candle pattern is detected, this could happen before stop loss or price target is reached, and may also happen after price target is reached.
*Note that this strategy is designed for same day SPY option scalping. I haven't determined an easy way to calculate the # of contracts to represent the equivalent option values. Plus the option
prices varies greatly depending on which strike and expiry that may suits your trading style. Therefore, please be mindful of the net profit shown. By default, each entry is approximately equal
to buying 10 of same day or 1 day expiry call or puts at strike $1 - $2 OTM. This strategy will close all open trades at 3:45pm EST on Mon, Wed, and Fri.
**Note that this strategy also takes into account of extended market data.
***Note pyramiding is set to 2 by default, so it allows for multiple entries on the way towards price target.
Remember that market conditions are always changing. This strategy was only able to be back-tested using 1 month of data. This strategy may not work the next month. Please keep that in mind.
Also, I take no credit for any of the indicators used as part of this strategy.
Enjoy~