BankNifty 5min Supertrend Based StrategyBankNifty 5min Supertrend Based Strategy, Intraday.
Work Best at 5mint chart on BankNifty.
The strategy is designed to trade using the Supertrend indicator with session-based rules, and risk management. It allows for customization through input variables and aims to provide a clear visual representation of the Supertrend by changing the color .
The script also includes input variables for the trading session and date range, which allows the trader to specify the time period in which they want the strategy to run. The session variable specifies the start and end times of the trading session, which in this case is set to the Indian trading session from 9:15 am to 3:10 pm.
The strategy starts by defining input variables such as the session time, start and end date for the backtesting, the length of the ATR, and the Supertrend factor. It also includes options for delay at session start and stop loss points and trail percentage .
The code then checks if the current time is within the specified session and date range . If it is, the Supertrend and its direction are calculated using the defined input variables. The strategy then waits for N numbers of candles (defined by the User) to form at the start of every session i.e. 09:15 AM before entering a trade.
The entry and exit conditions for long and short trades are defined based on the change in the Supertrend direction and the number of candles formed at the session start i.e. 09:15 AM . After that, it takes entry and exit for long and short trades on the change in the Supertrend direction . Stop-loss and trailing stop-loss are also defined based on the input variables.
Stop-loss (Defined by the user) is fixed points either below or above the Entry Price for Long and Short entries.
The Supertrend plot is displayed with changing colors depending on the direction. Finally, the strategy closes all trades at the end of the session if there are any open trades.
Overall, this strategy aims to trade with the Supertrend indicator using session-based rules and risk management.
However, as with any trading strategy, it is important to thoroughly test it before using it in live trading .
Intraday
NIFTY 50 5mint StrategyThis is an intraday strategy for NIFTY50 Based First candle High and Low breakout.
The strategy takes user inputs for the start and end dates, start and end months, and start and end years, which define the time range to trade. The user can also specify the maximum number of trades to take during the time range and the length of the Exponential Moving Average ( EMA ) used in the strategy
In this strategy, the First candle's high and low are calculated and used as entry and exit points for trades. If the close price breaks above the First candle's high, a buy signal is generated. Conversely, if the close price breaks below the First candle's low, a sell signal is generated.
The strategy uses the Exponential Moving Average ( EMA ) as a filter to close entered positions either long or short, EMA also acts Target. If the close price falls below the EMA, a long position is closed, and if the close price rises above the EMA, a short position is closed or the PreviousCandleClose is above the First candle's high a short position is closed, When the PreviousCandleClose is below the First candle's low a long position is closed, First candle's high act as Stoploss
The strategy limits the number of trades taken within the specified time range, and if the time range is exceeded, all positions are closed.
Finally, the strategy plots the First candle's high and low, EMAs on the chart for visual reference.
Default settings work best with the 5mint candle, you may tweak settings according to your needs.
backtesting helps in interpreting how the trading strategy would have behaved in the past, and forward testing (paper trading) informs the traders how it would perform now.
M0PB (Momentum Pullback)Long/short strategy that identifies extreme readings on the rsi as a *momentum signal*, unlike most RSI strategies the script will look to buy or sell the first pullback in the direction of the extreme RSI reading.
Enters positions on the first pullback to the 5ema(low)/ 5ema(high) and exits at rolling 12 bar high/ low. The rolling high/ low feature means that if the price enters into a prolonged consolidation the profit target will begin to reduce with each new bar. The best trades tend to work within 2-6 bars.
Built for use on 5 min intervals on FX, Indexes, and Crypto. Lower than 5 minute time frames tend to be noisier and mean more commissions and a higher risk of slippage so the suggested timeframe is 5 mins.
Hard stop is X ATR (users can experiment with this) from the position entry price. This can be adjusted in user inputs.
There is a lot of slack left in entries and exits but the overall strategy is fairly robust across timeframes and markets and has between 60%-70% win rate with larger winners.
Signals that occur from economic news volatility are best avoided.
CONSOLIDATION BAND BREAKOUT [5MIN TF]CONSOLIDTION BREAKOUT STRATEGY for 5 minute Time-Frame , that has the time condition adjustable for Indian Markets.
// ══════════════════════════════════════════════════════════════════════════ //
Unlike the Free Scripts - Risk Management , Position Sizing , Partial Exit etc. are also included .
Message to know more about the strategy.
// ══════════════════════════════════════════════════════════════════════════ //
The Timing can be changed to fit other markets, scroll down to "TIME CONDITION" to know more.
The commission is also included in the strategy .
The basic idea is when ,
1) Price crosses above upper Level ,indicated by Red Line, is a Long condition .
2) Price crosses below lower Level ,indicated by Green Line , is a Short condition .
3) Candle close crosses above ema1 , is a part of the Long condition .
4) Candle close crosses below ema1 , is a part of the Short condition .
5) Allowed hours specifies the trade entry timing.
6) ATR STOP is the stop-loss value on chart , can be adjusted in INPUTS.
7) Target 1 is the 1st target value on chart , can be adjusted in INPUTS.
8) RISK is Maximum Risk per trade for the intraday trade can be changed .
9) Total Capital used can be adjusted under INPUTS.
10) ATR TRAIL is used for trailing after entry, as mentioned in the inputs below.
11) Check trades under the list of trades .
12) Trade only in liquid stocks .
13) Risk only 1-5% of total capital.
14) Inputs can be changed for better back-test results, but also manually check the trades before setting alerts
15) SQUARE OFF TIME - As you change the time frame , also change the square-off time to that candle's closing time.
Eg: For 3min Time-frame , Hour = 2Hrs | Minute = 57min
16) Strategy stops for the day if you have a loss .
*The input values and the results are mentioned under "BACKTEST RESULTS" below*
// ══════════════════════════════ //
// ————————> RISK MANAGEMENT <——————— //
// ══════════════════════════════ //
Risk management is done based on max loss per trade and can be adjusted in the INPUTS.
// ═══════════════════════════ //
// ————————> POSITION SIZE <——————— //
// ═══════════════════════════ //
Quantity of each trade is different based on the loss
// ═════════════════════════ //
// ————————> PROPERTIES <——————— //
// ═════════════════════════ //
COMMISSION , SLIPPAGE ,RECALCULATE is already mentioned .
COMMISSION can be charges , based on the broker charges.
// ═══════════════════════════════//
// ————————> TIME CONDITION <————————— //
// ═══════════════════════════════//
The time can be changed in the INPUT.
The Indian Markets open at 9:15am and closes at 3:30pm.
The 'Allowed hours' under Inputs specifies the time at which Entries should happen .
"Close All" function closes all the trades before 3pm , at the open of the next candle.
To change the time to close all trades , check INPUT.
All open trades get closed at 3pm , because some brokers don't allow you to place fresh intraday orders after 3pm .
// ═══════════════════════════════════════════════ //
// ————————> BACKTEST RESULTS ( 123 CLOSED TRADES )<————————— //
// ═══════════════════════════════════════════════ //
INPUTS can be changed for better Back-Test results.
The strategy applied to NSE:TCS (5 min Time-Frame and with a capital of 1,00,000 ) gives us 77% profitability , as shown below
It was tested for a period a 1 year with a Profit Factor of 2.143 ,net Profit of 10,886 Rs .
The Initial Capital and Risk can be increased for better results.
The graph has a Linear Curve with Consistent Profits.
The INPUTS are as follows,
1) LENGTH ——————————————> 79
2) MUT_STDEV ————————————> 2.3
3) ALLOWED HRS ———————————> 9:25 TO 14:30
4) ATR STOP ——————————————> 2.2
5) RISK ——————————————————> 400
6) ATR TRAIL ———————————————> 2.6
7) TARGET 1 ————————————————> 2.1
8) MAX POSITION VALUE ——————————> 1,00,000
8) MAX DRAWDOWN —————————————> 2,000
8) SQUARE-OFF ————————————————> 14:55
NSE:TCS
Apply it to your charts Now !!
Send us a message to know more about this strategy
Thank You ☺ NSE:TCS
Consolidation Breakout [Indian Market Timing]OK let's get started ,
A Day Trading (Intraday) Consolidation Breakout Indication Strategy that explains time condition for Indian Markets .
The commission is also included in the strategy .
The basic idea is ,
1) Price crosses above upper band , indicated by a color change (green) is the Long condition .
2) Price crosses below lower band , indicated by a color change (red) is the Short condition .
3) ATR is used for trailing after entry
// ═══════════════════════════════//
// ————————> TIME CONDITION <————————— //
// ═══════════════════════════════//
The Indian Markets open at 9:15am and closes at 3:30pm.
The time_condition specifies the time at which Entries should happen .
"Close All" function closes all the trades at 2:57pm.
All open trades get closed at 2:57pm , because some brokers dont allow you to place fresh intraday orders after 3pm.
NSE:NIFTY1!
// ═══════════════════════════════════════════════ //
// ————————> BACKTEST RESULTS ( 114 CLOSED TRADES )<————————— //
// ═══════════════════════════════════════════════ //
LENGTH , MULT (factor) and ATR can be changed for better backtest results.
The strategy applied to NIFTY (3 min Time-Frame and contract size 5) gives us 60% profitability , as shown below
It was tested for a period a 8 months with a Profit Factor of 2.2 , avg Trade of 6000Rs profit and Sharpe Ratio : 0.67
The graph has a Linear Curve with consistent profits.
NSE:NIFTY1!
Save it favorites.
Apply it to your charts Now !!
Thank me later ;)
LudovicaLudovica is a trend following strategy that works on intraday timeframes (15 minutes).
The stop loss is decided based on the last price movement, take profits are projected through a Fibonacci extension. Two different extensions are calculated, based on a filter that affects the last price movement it is chosen which one to use for take profits.
Money management is fixed fractional: regardless of the distance between entry point and stop loss, the risk on capital for each trade is decided by the user in the strategy inputs. Take profits from 1 to 4 plan to exit with 15% of the initial size, TPs from 5 to 8 plan to exit with 10% of initial size.
There is a trailing stop system to reduce the drawdown of the strategy (note that stop loss moves as the trade develops).
Take profits are limit orders, stops (loss or trailing) occur at candlestick close (set alerts on the strategy).
Optimized strategies selectable from input panel:
-ETHUSDTPERP 15 min
-CRVUSDTPERP 15 min v1
-CRVUSDTPERP 15 min v2
-SNXUSDTPERP 15 min
Other pairs in development and soon available.
This strategy is in beta stage.
MACD Willy StrategyThis strategy is mainly developed for scalping / intraday trading. It could potentially be used to identify entry/exit signals for short term options trading. It performs decently well on popular stocks when used on time frames between 5 min to 15 min using regular session bar data. It combines 3 popular indicators, EMA, MACD, and William %range, to generate both long and short signals.
EMA:
Default is 200 EMA line.
MACD:
Default is 12/26 lengths for fast/slow signal inputs.
William %R - Smoothed (Published):
This is a custom indicator that generates two moving average lines from the original William %R line.
How it works:
Entry conditions:
1. Long/short entries when bar closes above/below EMA line
2. Long/short entries when MACD line is above/below signal line (histogram > 0 for long, < 0 for short)
3. Long/short entries when William %R fast MA line is above/below slow MA line
Exit conditions:
1. Exit long when MACD line is below signal line, vise versa for exit short
2. Exit long when William %R fast MA line is below slow MA line, vise versa for exit short
3. Exit long when William %R fast MA line must in below the overbought (-20) limit, exit short when above the oversold (-80) limit.
***Note that parameters are NOT optimized for any particular stocks / instruments.
Enjoy~~!!
[VJ]First Candle StrategyHello Traders, this is a simple intraday strategy involving the first candle of the day with an additional twist to the traditional style . You can modify the time of candle on the stock and see what are your best picks. Comment below if you found something with good returns
Strategy: Observe the first candle of the day within any time frame. 15m works best. If the first candle is RED ,then go for buy side for the rest of the day. You could square off at close of session or have a fixed take profit and stop loss. This is a contrarian indicator where people just use this as their first entry for the day. The same holds good when a Green candle is seen you go short side.
There is stop loss and take profit that can be used to optimise your trade
The template also includes daily square off based on your time.
Tendency EMA + RSI [Alorse]A very simple and highly effective strategy LONG & SHORT that combines only 2 indicators:
RSI
3 Moving Average Exponential (EMA)
LONG Entry conditions are:
EMA 20 cross over EMA 10
EMA 10 is above EMA 100
LONG Exit conditions are:
RSI greater than 70
Or when X number of candles have passed and the trade is in profit. (Check Settings)
SHORT Entry conditions are:
EMA 20 cross under EMA 10
EMA 10 is below EMA 100
SHORT Exit conditions are:
RSI is less than 30
Or when X number of candles have passed and the trade is in profit. (Check Settings)
Webhook Starter Kit [HullBuster]
Introduction
This is an open source strategy which provides a framework for webhook enabled projects. It is designed to work out-of-the-box on any instrument triggering on an intraday bar interval. This is a full featured script with an emphasis on actual trading at a brokerage through the TradingView alert mechanism and without requiring browser plugins.
The source code is written in a self documenting style with clearly defined sections. The sections “communicate” with each other through state variables making it easy for the strategy to evolve and improve. This is an excellent place for Pine Language beginners to start their strategy building journey. The script exhibits many Pine Language features which will certainly ad power to your script building abilities.
This script employs a basic trend follow strategy utilizing a forward pyramiding technique. Trend detection is implemented through the use of two higher time frame series. The market entry setup is a Simple Moving Average crossover. Positions exit by passing through conditional take profit logic. The script creates ten indicators including a Zscore oscillator to measure support and resistance levels. The indicator parameters are exposed through 47 strategy inputs segregated into seven sections. All of the inputs are equipped with detailed tool tips to help you get started.
To improve the transition from simulation to execution, strategy.entry and strategy.exit calls show enhanced message text with embedded keywords that are combined with the TradingView placeholders at alert time. Thereby, enabling a single JSON message to generate multiple execution events. This is genius stuff from the Pine Language development team. Really excellent work!
This document provides a sample alert message that can be applied to this script with relatively little modification. Without altering the code, the strategy inputs can alter the behavior to generate thousands of orders or simply a few dozen. It can be applied to crypto, stocks or forex instruments. A good way to look at this script is as a webhook lab that can aid in the development of your own endpoint processor, impress your co-workers and have hours of fun.
By no means is a webhook required or even necessary to benefit from this script. The setups, exits, trend detection, pyramids and DCA algorithms can be easily replaced with more sophisticated versions. The modular design of the script logic allows you to incrementally learn and advance this script into a functional trading system that you can be proud of.
Design
This is a trend following strategy that enters long above the trend line and short below. There are five trend lines that are visible by default but can be turned off in Section 7. Identified, in frequency order, as follows:
1. - EMA in the chart time frame. Intended to track price pressure. Configured in Section 3.
2. - ALMA in the higher time frame specified in Section 2 Signal Line Period.
3. - Linear Regression in the higher time frame specified in Section 2 Signal Line Period.
4. - Linear Regression in the higher time frame specified in Section 2 Signal Line Period.
5. - DEMA in the higher time frame specified in Section 2 Trend Line Period.
The Blue, Green and Orange lines are signal lines are on the same time frame. The time frame selected should be at least five times greater than the chart time frame. The Purple line represents the trend line for which prices above the line suggest a rising market and prices below a falling market. The time frame selected for the trend should be at least five times greater than the signal lines.
Three oscillators are created as follows:
1. Stochastic - In the chart time frame. Used to enter forward pyramids.
2. Stochastic - In the Trend period. Used to detect exit conditions.
3. Zscore - In the Signal period. Used to detect exit conditions.
The Stochastics are configured identically other than the time frame. The period is set in Section 2.
Two Simple Moving Averages provide the trade entry conditions in the form of a crossover. Crossing up is a long entry and down is a short. This is in fact the same setup you get when you select a basic strategy from the Pine editor. The crossovers are configured in Section 3. You can see where the crosses are occurring by enabling Show Entry Regions in Section 7.
The script has the capacity for pyramids and DCA. Forward pyramids are enabled by setting the Pyramid properties tab with a non zero value. In this case add on trades will enter the market on dips above the position open price. This process will continue until the trade exits. Downward pyramids are available in Crypto and Range mode only. In this case add on trades are placed below the entry price in the drawdown space until the stop is hit. To enable downward pyramids set the Pyramid Minimum Span In Section 1 to a non zero value.
This implementation of Dollar Cost Averaging (DCA) triggers off consecutive losses. Each loss in a run increments a sequence number. The position size is increased as a multiple of this sequence. When the position eventually closes at a profit the sequence is reset. DCA is enabled by setting the Maximum DCA Increments In Section 1 to a non zero value.
It should be noted that the pyramid and DCA features are implemented using a rudimentary design and as such do not perform with the precision of my invite only scripts. They are intended as a feature to stress test your webhook endpoint. As is, you will need to buttress the logic for it to be part of an automated trading system. It is for this reason that I did not apply a Martingale algorithm to this pyramid implementation. But, hey, it’s an open source script so there is plenty of room for learning and your own experimentation.
How does it work
The overall behavior of the script is governed by the Trading Mode selection in Section 1. It is the very first input so you should think about what behavior you intend for this strategy at the onset of the configuration. As previously discussed, this script is designed to be a trend follower. The trend being defined as where the purple line is predominately heading. In BiDir mode, SMA crossovers above the purple line will open long positions and crosses below the line will open short. If pyramiding is enabled add on trades will accumulate on dips above the entry price. The value applied to the Minimum Profit input in Section 1 establishes the threshold for a profitable exit. This is not a hard number exit. The conditional exit logic must be satisfied in order to permit the trade to close. This is where the effort put into the indicator calibration is realized. There are four ways the trade can exit at a profit:
1. Natural exit. When the blue line crosses the green line the trade will close. For a long position the blue line must cross under the green line (downward). For a short the blue must cross over the green (upward).
2. Alma / Linear Regression event. The distance the blue line is from the green and the relative speed the cross is experiencing determines this event. The activation thresholds are set in Section 6 and relies on the period and length set in Section 2. A long position will exit on an upward thrust which exceeds the activation threshold. A short will exit on a downward thrust.
3. Exponential event. The distance the yellow line is from the blue and the relative speed the cross is experiencing determines this event. The activation thresholds are set in Section 3 and relies on the period and length set in the same section.
4. Stochastic event. The purple line stochastic is used to measure overbought and over sold levels with regard to position exits. Signal line positions combined with a reading over 80 signals a long profit exit. Similarly, readings below 20 signal a short profit exit.
Another, optional, way to exit a position is by Bale Out. You can enable this feature in Section 1. This is a handy way to reduce the risk when carrying a large pyramid stack. Instead of waiting for the entire position to recover we exit early (bale out) as soon as the profit value has doubled.
There are lots of ways to implement a bale out but the method I used here provides a succinct example. Feel free to improve on it if you like. To see where the Bale Outs occur, enable Show Bale Outs in Section 7. Red labels are rendered below each exit point on the chart.
There are seven selectable Trading Modes available from the drop down in Section 1:
1. Long - Uses the strategy.risk.allow_entry_in to execute long only trades. You will still see shorts on the chart.
2. Short - Uses the strategy.risk.allow_entry_in to execute short only trades. You will still see long trades on the chart.
3. BiDir - This mode is for margin trading with a stop. If a long position was initiated above the trend line and the price has now fallen below the trend, the position will be reversed after the stop is hit. Forward pyramiding is available in this mode if you set the Pyramiding value in the Properties tab. DCA can also be activated.
4. Flip Flop - This is a bidirectional trading mode that automatically reverses on a trend line crossover. This is distinctively different from BiDir since you will get a reversal even without a stop which is advantageous in non-margin trading.
5. Crypto - This mode is for crypto trading where you are buying the coins outright. In this case you likely want to accumulate coins on a crash. Especially, when all the news outlets are talking about the end of Bitcoin and you see nice deep valleys on the chart. Certainly, under these conditions, the market will be well below the purple line. No margin so you can’t go short. Downward pyramids are enabled for Crypto mode when two conditions are met. First the Pyramiding value in the Properties tab must be non zero. Second the Pyramid Minimum Span in Section 1 must be non zero.
6. Range - This is a counter trend trading mode. Longs are entered below the purple trend line and shorts above. Useful when you want to test your webhook in a market where the trend line is bisecting the signal line series. Remember that this strategy is a trend follower. It’s going to get chopped out in a range bound market. By turning on the Range mode you will at least see profitable trades while stuck in the range. However, when the market eventually picks a direction, this mode will sustain losses. This range trading mode is a rudimentary implementation that will need a lot of improvement if you want to create a reliable switch hitter (trend/range combo).
7. No Trade. Useful when setting up the trend lines and the entry and exit is not important.
Once in the trade, long or short, the script tests the exit condition on every bar. If not a profitable exit then it checks if a pyramid is required. As mentioned earlier, the entry setups are quite primitive. Although they can easily be replaced by more sophisticated algorithms, what I really wanted to show is the diminished role of the position entry in the overall life of the trade. Professional traders spend much more time on the management of the trade beyond the market entry. While your trade entry is important, you can get in almost anywhere and still land a profitable exit.
If DCA is enabled, the size of the position will increase in response to consecutive losses. The number of times the position can increase is limited by the number set in Maximum DCA Increments of Section 1. Once the position breaks the losing streak the trade size will return the default quantity set in the Properties tab. It should be noted that the Initial Capital amount set in the Properties tab does not affect the simulation in the same way as a real account. In reality, running out of money will certainly halt trading. In fact, your account would be frozen long before the last penny was committed to a trade. On the other hand, TradingView will keep running the simulation until the current bar even if your funds have been technically depleted.
Entry and exit use the strategy.entry and strategy.exit calls respectfully. The alert_message parameter has special keywords that the endpoint expects to properly calculate position size and message sequence. The alert message will embed these keywords in the JSON object through the {{strategy.order.alert_message}} placeholder. You should use whatever keywords are expected from the endpoint you intend to webhook in to.
Webhook Integration
The TradingView alerts dialog provides a way to connect your script to an external system which could actually execute your trade. This is a fantastic feature that enables you to separate the data feed and technical analysis from the execution and reporting systems. Using this feature it is possible to create a fully automated trading system entirely on the cloud. Of course, there is some work to get it all going in a reliable fashion. Being a strategy type script place holders such as {{strategy.position_size}} can be embedded in the alert message text. There are more than 10 variables which can write internal script values into the message for delivery to the specified endpoint.
Entry and exit use the strategy.entry and strategy.exit calls respectfully. The alert_message parameter has special keywords that my endpoint expects to properly calculate position size and message sequence. The alert message will embed these keywords in the JSON object through the {{strategy.order.alert_message}} placeholder. You should use whatever keywords are expected from the endpoint you intend to webhook in to.
Here is an excerpt of the fields I use in my webhook signal:
"broker_id": "kraken",
"account_id": "XXX XXXX XXXX XXXX",
"symbol_id": "XMRUSD",
"action": "{{strategy.order.action}}",
"strategy": "{{strategy.order.id}}",
"lots": "{{strategy.order.contracts}}",
"price": "{{strategy.order.price}}",
"comment": "{{strategy.order.alert_message}}",
"timestamp": "{{time}}"
Though TradingView does a great job in dispatching your alert this feature does come with a few idiosyncrasies. Namely, a single transaction call in your script may cause multiple transmissions to the endpoint. If you are using placeholders each message describes part of the transaction sequence. A good example is closing a pyramid stack. Although the script makes a single strategy.close() call, the endpoint actually receives a close message for each pyramid trade. The broker, on the other hand, only requires a single close. The incongruity of this situation is exacerbated by the possibility of messages being received out of sequence. Depending on the type of order designated in the message, a close or a reversal. This could have a disastrous effect on your live account. This broker simulator has no idea what is actually going on at your real account. Its just doing the job of running the simulation and sending out the computed results. If your TradingView simulation falls out of alignment with the actual trading account lots of really bad things could happen. Like your script thinks your are currently long but the account is actually short. Reversals from this point forward will always be wrong with no one the wiser. Human intervention will be required to restore congruence. But how does anyone find out this is occurring? In closed systems engineering this is known as entropy. In practice your webhook logic should be robust enough to detect these conditions. Be generous with the placeholder usage and give the webhook code plenty of information to compare states. Both issuer and receiver. Don’t blindly commit incoming signals without verifying system integrity.
Setup
The following steps provide a very brief set of instructions that will get you started on your first configuration. After you’ve gone through the process a couple of times, you won’t need these anymore. It’s really a simple script after all. I have several example configurations that I used to create the performance charts shown. I can share them with you if you like. Of course, if you’ve modified the code then these steps are probably obsolete.
There are 47 inputs divided into seven sections. For the most part, the configuration process is designed to flow from top to bottom. Handy, tool tips are available on every field to help get you through the initial setup.
Step 1. Input the Base Currency and Order Size in the Properties tab. Set the Pyramiding value to zero.
Step 2. Select the Trading Mode you intend to test with from the drop down in Section 1. I usually select No Trade until I’ve setup all of the trend lines, profit and stop levels.
Step 3. Put in your Minimum Profit and Stop Loss in the first section. This is in pips or currency basis points (chart right side scale). Remember that the profit is taken as a conditional exit not a fixed limit. The actual profit taken will almost always be greater than the amount specified. The stop loss, on the other hand, is indeed a hard number which is executed by the TradingView broker simulator when the threshold is breached.
Step 4. Apply the appropriate value to the Tick Scalar field in Section 1. This value is used to remove the pipette from the price. You can enable the Summary Report in Section 7 to see the TradingView minimum tick size of the current chart.
Step 5. Apply the appropriate Price Normalizer value in Section 1. This value is used to normalize the instrument price for differential calculations. Basically, we want to increase the magnitude to significant digits to make the numbers more meaningful in comparisons. Though I have used many normalization techniques, I have always found this method to provide a simple and lightweight solution for less demanding applications. Most of the time the default value will be sufficient. The Tick Scalar and Price Normalizer value work together within a single calculation so changing either will affect all delta result values.
Step 6. Turn on the trend line plots in Section 7. Then configure Section 2. Try to get the plots to show you what’s really happening not what you want to happen. The most important is the purple trend line. Select an interval and length that seem to identify where prices tend to go during non-consolidation periods. Remember that a natural exit is when the blue crosses the green line.
Step 7. Enable Show Event Regions in Section 7. Then adjust Section 6. Blue background fills are spikes and red fills are plunging prices. These measurements should be hard to come by so you should see relatively few fills on the chart if you’ve set this up as intended. Section 6 includes the Zscore oscillator the state of which combines with the signal lines to detect statistically significant price movement. The Zscore is a zero based calculation with positive and negative magnitude readings. You want to input a reasonably large number slightly below the maximum amplitude seen on the chart. Both rise and fall inputs are entered as a positive real number. You can easily use my code to create a separate indicator if you want to see it in action. The default value is sufficient for most configurations.
Step 8. Turn off Show Event Regions and enable Show Entry Regions in Section 7. Then adjust Section 3. This section contains two parts. The entry setup crossovers and EMA events. Adjust the crossovers first. That is the Fast Cross Length and Slow Cross Length. The frequency of your trades will be shown as blue and red fills. There should be a lot. Then turn off Show Event Regions and enable Display EMA Peaks. Adjust all the fields that have the word EMA. This is actually the yellow line on the chart. The blue and red fills should show much less than the crossovers but more than event fills shown in Step 7.
Step 9. Change the Trading Mode to BiDir if you selected No Trades previously. Look on the chart and see where the trades are occurring. Make adjustments to the Minimum Profit and Stop Offset in Section 1 if necessary. Wider profits and stops reduce the trade frequency.
Step 10. Go to Section 4 and 5 and make fine tuning adjustments to the long and short side.
Example Settings
To reproduce the performance shown on the chart please use the following configuration: (Bitcoin on the Kraken exchange)
1. Select XBTUSD Kraken as the chart symbol.
2. On the properties tab set the Order Size to: 0.01 Bitcoin
3. On the properties tab set the Pyramiding to: 12
4. In Section 1: Select “Crypto” for the Trading Model
5. In Section 1: Input 2000 for the Minimum Profit
6. In Section 1: Input 0 for the Stop Offset (No Stop)
7. In Section 1: Input 10 for the Tick Scalar
8. In Section 1: Input 1000 for the Price Normalizer
9. In Section 1: Input 2000 for the Pyramid Minimum Span
10. In Section 1: Check mark the Position Bale Out
11. In Section 2: Input 60 for the Signal Line Period
12. In Section 2: Input 1440 for the Trend Line Period
13. In Section 2: Input 5 for the Fast Alma Length
14. In Section 2: Input 22 for the Fast LinReg Length
15. In Section 2: Input 100 for the Slow LinReg Length
16. In Section 2: Input 90 for the Trend Line Length
17. In Section 2: Input 14 Stochastic Length
18. In Section 3: Input 9 Fast Cross Length
19. In Section 3: Input 24 Slow Cross Length
20. In Section 3: Input 8 Fast EMA Length
21. In Section 3: Input 10 Fast EMA Rise NetChg
22. In Section 3: Input 1 Fast EMA Rise ROC
23. In Section 3: Input 10 Fast EMA Fall NetChg
24. In Section 3: Input 1 Fast EMA Fall ROC
25. In Section 4: Check mark the Long Natural Exit
26. In Section 4: Check mark the Long Signal Exit
27. In Section 4: Check mark the Long Price Event Exit
28. In Section 4: Check mark the Long Stochastic Exit
29. In Section 5: Check mark the Short Natural Exit
30. In Section 5: Check mark the Short Signal Exit
31. In Section 5: Check mark the Short Price Event Exit
32. In Section 5: Check mark the Short Stochastic Exit
33. In Section 6: Input 120 Rise Event NetChg
34. In Section 6: Input 1 Rise Event ROC
35. In Section 6: Input 5 Min Above Zero ZScore
36. In Section 6: Input 120 Fall Event NetChg
37. In Section 6: Input 1 Fall Event ROC
38. In Section 6: Input 5 Min Below Zero ZScore
In this configuration we are trading in long only mode and have enabled downward pyramiding. The purple trend line is based on the day (1440) period. The length is set at 90 days so it’s going to take a while for the trend line to alter course should this symbol decide to node dive for a prolonged amount of time. Your trades will still go long under those circumstances. Since downward accumulation is enabled, your position size will grow on the way down.
The performance example is Bitcoin so we assume the trader is buying coins outright. That being the case we don’t need a stop since we will never receive a margin call. New buy signals will be generated when the price exceeds the magnitude and speed defined by the Event Net Change and Rate of Change.
Feel free to PM me with any questions related to this script. Thank you and happy trading!
CFTC RULE 4.41
These results are based on simulated or hypothetical performance results that have certain inherent limitations. Unlike the results shown in an actual performance record, these results do not represent actual trading. Also, because these trades have not actually been executed, these results may have under-or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated or hypothetical trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to these being shown.
[VJ]Phoenix Force of PSAR +MACD +RSIThis is a simple intraday strategy for working on Stocks or commodities based out on PSAR, MACD , RSI and chop index . You can modify the start time and end time based on your timezones. Session value should be from market start to the time you want to square-off
Important: The end time should be at least 2 minutes before the intraday square-off time set by your broker
Comment below if you get good returns
Strategy: Entry Exits using PSAR and momentum and trend using MACD and RSI. A chop index is used as filtering
Indicators used :
Parabolic SAR is a technical indicator that is used to determine the price direction of stocks and it also draws attention to the traders when the price is changing
PSAR helps you:
Identify when a certain price trend is going to change direction
Indicate the most effective level at which to enter into the trade
Indicate the most effective exit point for the trade
Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a security's price. ... Traders may buy the security when the MACD crosses above its signal line and sell—or short—the security when the MACD crosses below the signal line
RSI is intended to chart the current and historical strength or weakness of a stock or market based on the closing prices of a recent trading period.
Buying/Selling
When trading with the parabolic SAR, you would buy a market when the dots move below the current asset price and are green in colour. Alternatively, you would sell a market when the dots move above the current asset price and are red in colour. We use MACD , RSI to ensure that a right trade is picked when PSAR gives an indication. CI is used to stay away from the range bound market as much as possible.
Usage & Best setting :
Choose a good volatile stock and a time frame - 5m.
MA length : 200
RSI threshold : 50
MACD: 12,26,9
There is stop loss and take profit that can be used to optimise your trade
The template also includes daily square off based on your time.
[VJ]Thor for MFIThis is a simple intraday strategy for working on Stocks or commodities . You can modify the start time and end time based on your timezones. Session value should be from market start to the time you want to square-off
Important: The end time should be at least 2 minutes before the intraday square-off time set by your broker
Comment below if you get good returns
Strategy:
Indicators used :
Moving average (MA) is a widely used technical indicator that smooths out price trends by filtering out the “noise” from random short-term price fluctuations. Here moving averages are used to identify trend direction and to determine support and resistance levels. Overbought and oversold regions are also taken into consideration
The Money Flow Index ( MFI ) is a momentum indicator that measures the flow of money into and out of a security over a specified period of time. It is related to the Relative Strength Index ( RSI ) but incorporates volume , whereas the RSI only considers price. The MFI is calculated by accumulating positive and negative Money Flow values (see Money Flow ), then creating a Money Ratio. The Money Ratio is then normalized into the MFI oscillator form.
Using the combination of Overbought and Oversold values and varying MFI and using the MA filter to ensure the direction , we can buy/sell when conditions are met
Buying with MFI
1. MFI drops below 20 and enters inside oversold zone.
2. MFI bounces back above 20.
3. MFI pulls back but remains above 20.
4. A MFI break out above its previous high is a good buy signal.
Selling with MFI
1. MFI rises above 80 and enters inside overbought zone.
2. MFI drops back below 80.
3. MFI rises slightly but remains below 80.
4. MFI drops lower than its previous low is a signal to short sell or profit booking
Usage & Best setting :
Choose a good volatile stock and a time frame - 5m.
MFI factor : 3
Moving Average : 80
Overbought & Oversold - can be varied as per user
There is stop loss and take profit that can be used to optimise your trade
The template also includes daily square off based on your time.
[VJ]War Machine PAT IntraThis is a simple intraday strategy for working on Stocks . You can modify the values on the stock and see what are your best picks. Comment below if you found something with good returns
Strategy:
Indicators used :
The Choppiness Index is designed to determine whether the market is choppy or trading sideways, or not choppy and trading within a trend in either direction. Using a scale from 1 - 100, the market is considered to be choppy as values near 100 (over 61.80) and trending when values are lower than 38.20)
The Money Flow Index (MFI) is a momentum indicator that measures the flow of money into and out of a security over a specified period of time. It is related to the Relative Strength Index (RSI) but incorporates volume, whereas the RSI only considers price. The MFI is calculated by accumulating positive and negative Money Flow values (see Money Flow), then creating a Money Ratio. The Money Ratio is then normalized into the MFI oscillator form.
Using the combination of CI (trend factor as constant) and varying MFI, we can buy/sell when conditions are met
Buying with MFI
1. MFI drops below 20 and enters inside oversold zone.
2. MFI bounces back above 20.
3. MFI pulls back but remains above 20.
4. A MFI break out above its previous high is a good buy signal.
Selling with MFI
1. MFI rises above 80 and enters inside overbought zone.
2. MFI drops back below 80.
3. MFI rises slightly but remains below 80.
4. MFI drops lower than its previous low is a signal to short sell or profit booking
Usage & Best setting :
Choose a good volatile stock and a time frame - 5m.
Trending factor : 50
Overbought & Oversold - can be varied as per user
There is stop loss and take profit that can be used to optimise your trade
The template also includes daily square off based on your time.
Multi-Market Swing Trader Webhook Ready [HullBuster]
Introduction
This is an all symbol swing trading strategy intended for webhook integration to live accounts. This script employs an adjustable bandwidth ping pong algorithm which can be run in long only, short only or bidirectional modes. Additionally, this script provides advanced features such as pyramiding and DCA. It has been in development for nearly three years and exposes over 90 inputs to accommodate varying risk reward ratios. Equipped with a proper configuration it is suitable for professional traders seeking quality trades from a cloud based platform. This is my most advanced Pine Script to date which combines my RangeV3 and TrendV2 scripts. Using this combination it tries to bridge the gap between range bound and trending markets. I have put a lot of time into creating a system that could transition by itself so as to require less human intervention and thus be able to withstand long periods in full automation mode.
As a Pine strategy, hypothetical performance can be easily back-tested. Allowing you to Iron out the configuration of your target instrument. Now with recent advancements from the Pine development team this same script can be connected to a webhook through the alert mechanism. The requirement of a separate study script has been completely removed. This really makes things a lot easier to get your trading system up and running. I would like to also mention that TradingView has made significant advancements to the back-end over the last year. Notably, compile times are much faster now permitting more complex algorithms to be implemented. Thank you TradingView!
I used QuantConnect as my role model and strived to produce a base script which could compete with higher end cloud based platforms while being attractive to similarly experienced traders. The versatility of the Pine Language combined with the greater selection of end point execution systems provides a powerful alternative to other cloud based platforms. At the very least, with the features available today, a modular trading system for everyday use is a reality. I hope you'll agree.
This is a swing trading strategy so the behavior of this script is to buy on weakness and sell on strength. In trading parlance this is referred to as Support and Resistance Trading. Support being the point at which prices stop falling and start rising. Resistance being the point at which prices stop rising and fall. The chart real estate between these two points being defined as the range. This script seeks to implement strategies to profit from placing trades within this region. Short positions at resistance and long positions at support. Just to be clear, the range as well as trends are merely illusions as the chart only receives prices. However, this script attempts to calculate pivot points from the price stream. Rising pivots are shorts and falling pivots are longs. I refer to pivots as a vertex in this script which adds structural components to the chart formation (point, sides and a base). When trading in “Ping Pong” mode long and short positions are interleaved continuously as long as there exists a detectable vertex.
This is a non-hedging script so those of us subject to NFA FIFO Rule 2-43(b) should be generally safe to webhook into signals emitted from this script. However, as covered later in this document, there are some technical limitations to this statement. I have tested this script on various instruments for over two years and have configurations for forex, crypto and stocks. This script along with my TrendV2 script are my daily trading vehicles as a webhook into my forex and crypto accounts. This script employs various high risk features that could wipe out your account if not used judiciously. You should absolutely not use this script if you are a beginner or looking for a get-rich-quick strategy. Also please see my CFTC RULE 4.41 disclosure statement at the end of the document. Really!
Does this script repaint? The short answer is yes, it does, despite my best efforts to the contrary. EMAs are central to my strategy and TradingView calculates from the beginning of the series so there is just no getting around this. However, Pine is improving everyday and I am hopeful that this issue will be address from an architectural level at some point in the future. I have programmed my webhook to compensate for this occurrence so, in the mean time, this my recommended way to handle it (at the endpoint and before the broker).
Design
This strategy uses a ping pong algorithm of my own design. Basically, trades bounce off each other along the price stream. Trades are produced as a series of reversals. The point at which a trade reverses is a pivot calculation. A measurement is made between the recent valley to peak which results in a standard deviation value. This value is an input to implied probability calculation.Yes, the same implied probability used in sports betting. Odds are then calculated to determine the likelihood of price action continuing or retracing to the pivot. Based on where the account is at alert time, the action could be an entry, take profit or pyramid signal. In this design, trades must occur in alternating sequence. A long followed by a short then another long followed by a short and so on. In range bound price action trades appear along the outer bands of the channel in the aforementioned sequence. Shorts on the top and longs at the bottom. Generally speaking, the widths of the trading bands can be adjusted using the vertex dynamics in Section 2. There are a dozen inputs in this section used to describe the trading range. It is not a simple adjustment. If pyramids are enabled the strategy overrides the ping pong reversal pattern and begins an accumulation sequence. In this case you will see a series of same direction trades.
This script uses twelve indicators on a single time frame. The original trading algorithms are a port from a C++ program on proprietary trading platform. I’ve converted some of the statistical functions to use standard indicators available on TradingView. The setups make heavy use of the Hull Moving Average in conjunction with EMAs that form the Bill Williams Alligator as described in his book “New Trading Dimensions” Chapter 3. Lag between the Hull and the EMAs play a key role in identifying the pivot points. I really like the Hull Moving Average. I use it in all my systems, including 3 other platforms. It’s is an excellent leading indicator and a relatively light calculation.
The trend detection algorithms rely on several factors:
1. Smoothed EMAs in a Willams Alligator pattern.
2. Number of pivots encountered in a particular direction.
3. Which side debt is being incurred.
4. Settings in Section 4 and 5 (long and short)
The strategy uses these factors to determine the probability of prices continuing in the most recent direction. My TrendV2 script uses a higher time frame to determine trend direction. I can’t use that method in this script without exceeding various TradingView limitations on code size. However, the higher time frame is the best way to know which trend is worth pursuing or better to bet against.
The entire script is around 2400 lines of Pine code which pushes the limits of what can be created on this platform given the TradingView maximums for: local scopes, run-time duration and compile time. The module has been through numerous refactoring passes and makes extensive use of ternary statements. As such, It takes a full minute to compile after adding it to a chart. Please wait for the hovering dots to disappear before attempting to bring up the input dialog box. Scrolling the chart quickly may bring up an hour glass.
Regardless of the market conditions: range or trend. The behavior of the script is governed entirely by the 91 inputs. Depending on the settings, bar interval and symbol, you can configure a system to trade in small ranges producing a thousand or more trades. If you prefer wider ranges with fewer trades then the vertex detection settings in Section 2 should employ stiffer values. To make the script more of a trend follower, adjustments are available in Section 4 and 5 (long and short respectively). Overall this script is a range trader and the setups want to get in that way. It cannot be made into a full blown trend trading system. My TrendV2 is equipped for that purpose. Conversely, this script cannot be effectively deployed as a scalper either. The vertex calculation require too much data for high frequency trading. That doesn’t work well for retail customers anyway. The script is designed to function in bar intervals between 5 minutes and 4 hours. However, larger intervals require more backtest data in order to create reliable configurations. TradingView paid plans (Pro) only provide 10K bars which may not be sufficient. Please keep that in mind.
The transition from swing trader to trend follower typically happens after a stop is hit. That means that your account experiences a loss first and usually with a pyramid stack so the loss could be significant. Even then the script continues to alternate trades long and short. The difference is that the strategy tries to be more long on rising prices and more short on falling prices as opposed to simply counter trend trading. Otherwise, a continuous period of rising prices results in a distinctly short pyramid stack. This is much different than my TrendV2 script which stays long on peaks and short on valleys. Basically, the plan is to be profitable in range bound markets and just lose less when a trend comes along. How well this actually plays out will depend largely on the choices made in the sectioned input parameters.
Sections
The input dialog for this script contains 91 inputs separated into six sections.
Section 1: Global settings for the strategy including calculation model, trading direction, exit levels, pyramid and DCA settings. This is where you specify your minimum profit and stop levels. You should setup your Properties tab inputs before working on any of the sections. It’s really important to get the Base Currency right before doing any work on the strategy inputs. It is important to understand that the “Minimum Profit” and “Limit Offset” are conditional exits. To exit at a profit, the specified value must be exceeded during positive price pressure. On the other hand, the “Stop Offset” is a hard limit.
Section 2: Vertex dynamics. The script is equipped with four types of pivot point indicators. Histogram, candle, fractal and transform. Despite how the chart visuals may seem. The chart only receives prices. It’s up to the strategy to interpret patterns from the number stream. The quality of the feed and the symbol’s bar characteristics vary greatly from instrument to instrument. Each indicator uses a fundamentally different pattern recognition algorithm. Use trial and error to determine the best fit for your configuration. After selecting an indicator type, there are eight analog fields that must be configured for that particular indicator. This is the hardest part of the configuration process. The values applied to these fields determine how the range will be measured. They have a big effect on the number of trades your system will generate. To see the vertices click on the “Show Markers” check box in this section. Red markers are long positions and blue markers are short. This will give you an idea of where trades will be placed in natural order.
Section 3: Event thresholds. Price spikes are used to enter and exit trades. The magnitude which define these spikes are configured here. The rise and fall events are primarily for pyramid placement. The rise and fall limits determine the exit threshold for the conditional “Limit Offset” field found in Section 1. These fields should be adjusted one at a time. Use a zero value to disengage every one but the one you are working on. Use the fill colors found in Section 6 to get a visual on the values applied to these fields. To make it harder for pyramids to enter stiffen the Event values. This is more of a hack as the formal pyramid parameters are in Section 1.
Section 4 and 5: Long and short settings. These are mirror opposite settings with all opposing fields having the same meaning. Its really easy to introduce data mining bias into your configuration through these fields. You must combat against this tendency by trying to keep your settings as uniform as possible. Wildly different parameters for long and short means you have probably fitted the chart. There are nine analog and thirteen Boolean fields per trade direction. This section is all about how the trades themselves will be placed along the range defined in Section 2. Generally speaking, more restrictive settings will result in less trades but higher quality. Remember that this strategy will enter long on falling prices and short on rising prices. So getting in the trade too early leads to a draw-down. However, this could be what you want if pyramiding is enabled. I, personally, have found that the best configurations come from slightly skewing one side. I just accept that the other side will be sub-par.
Section 6: Chart rendering. This section contains one analog and four Boolean fields. More or less a diagnostic tool. Of particular interest is the “Symbol Debt Sequence” field. This field contains a whole number which paints regions that have sustained a run of bad trades equal or greater than specified value. It is useful when DCA is enabled. In this script Dollar Cost Averaging on new positions continues only until the symbol debt is recouped. To get a better understanding on how this works put a number in this field and activate DCA. You should notice how the trade size increases in the colored regions. The “Summary Report” checkbox displays a blue information box at the live end of the chart. It exposes several metrics which you may find useful if manually trading this strategy from audible alerts or text messages.
Pyramids
This script features a downward pyramiding strategy which increases your position size on losing trades. On purely margin trades, this feature can be used to, hypothetically, increase the profit factor of positions (not individual trades). On long only markets, such as crypto, you can use this feature to accumulate coins at depressed prices. The way it works is the stop offset, applied in the Section 1 inputs, determines the maximum risk you intend to bear. Additional trades will be placed at pivot points calculated all the way down to the stop price. The size of each add on trade is increased by a multiple of its interval. The maximum number of intervals is limited by the “Pyramiding” field in the properties tab. The rate at which pyramid positions are created can be adjusted in Section 1. To see the pyramids click on the “Mark Pyramid Levels” check box in the same section. Blue triangles are painted below trades other than the primary.
Unlike traditional Martingale strategies, the result of your trade is not dependent on the profit or loss from the last trade. The position must recover the R1 point in order to close. Alternatively, you can set a “Pyramid Bale Out Offset” in Section 1 which will terminate the trade early. However, the bale out must coincide with a pivot point and result in a profitable exit in order to actually close the trade. Should the market price exceed the stop offset set in Section 1, the full value of the position, multiplied by the accepted leverage, will be realized as a loss to the trading account. A series of such losses will certainly wipe out your account.
Pyramiding is an advanced feature intended for professional traders with well funded accounts and an appropriate mindset. The availability of this feature is not intended to endorse or promote my use of it. Use at your own risk (peril).
DCA
In addition to pyramiding this script employs DCA which enables users to experiment with loss recovery techniques. This is another advanced feature which can increase the order size on new trades in response to stopped out or winning streak trades. The script keeps track of debt incurred from losing trades. When the debt is recovered the order size returns to the base amount specified in the properties tab. The inputs for this feature are found in section 3 and include a limiter to prevent your account from depleting capital during runaway markets. The main difference between DCA and pyramids is that this implementation of DCA applies to new trades while pyramids affect open positions. DCA is a popular feature in crypto trading but can leave you with large “bags” if your not careful. In other markets, especially margin trading, you’ll need a well funded account and much experience.
To be sure pyramiding and dollar cost averaging is as close to gambling as you can get in respectable trading exchanges. However, if you are looking to compete in a spot trading contest or just want to add excitement to your trading life style those features could find a place in your strategies. Although your backtest may show spectacular gains don’t expect your live trading account to do the same. Every backtest has some measure of data mining bias. Please remember that.
Webhook Integration
The TradingView alerts dialog provides a way to connect your script to an external system which could actually execute your trade. This is a fantastic feature that enables you to separate the data feed and technical analysis from the execution and reporting systems. Using this feature it is possible to create a fully automated trading system entirely on the cloud. Of course, there is some work to get it all going in a reliable fashion. To that end this script has several things going for it. First off, it is a strategy type script. That means that the strategy place holders such as {{strategy.position_size}} can be embedded in the alert message text. There are more than 10 variables which can write internal script values into the message for delivery to the specified endpoint. Additionally, my scripts output the current win streak and debt loss counts in the {{strategy.order.alert_message}} field. Depending on the condition, this script will output other useful values in the JSON “comment” field of the alert message. Here is an excerpt of the fields I use in my webhook signal:
"broker_id": "kraken",
"account_id": "XXX XXXX XXXX XXXX",
"symbol_id": "XMRUSD",
"action": "{{strategy.order.action}}",
"strategy": "{{strategy.order.id}}",
"lots": "{{strategy.order.contracts}}",
"price": "{{strategy.order.price}}",
"comment": "{{strategy.order.alert_message}}",
"timestamp": "{{time}}"
Though TradingView does a great job in dispatching your alert this feature does come with a few idiosyncrasies. Namely, a single transaction call in your script may cause multiple transmissions to the endpoint. If you are using placeholders each message describes part of the transaction sequence. A good example is closing a pyramid stack. Although the script makes a single strategy.close() call, the endpoint actually receives a close message for each pyramid trade. The broker, on the other hand, only requires a single close. The incongruity of this situation is exacerbated by the possibility of messages being received out of sequence. Depending on the type of order designated in the message, a close or a reversal. This could have a disastrous effect on your live account. This broker simulator has no idea what is actually going on at your real account. Its just doing the job of running the simulation and sending out the computed results. If your TradingView simulation falls out of alignment with the actual trading account lots of really bad things could happen. Like your script thinks your are currently long but the account is actually short. Reversals from this point forward will always be wrong with no one the wiser. Human intervention will be required to restore congruence. But how does anyone find out this is occurring? In closed systems engineering this is known as entropy. In practice your webhook logic should be robust enough to detect these conditions. Be generous with the placeholder usage and give the webhook code plenty of information to compare states. Both issuer and receiver. Don’t blindly commit incoming signals without verifying system integrity.
Operation
This is a swing trading strategy so the fundamental behavior of this script is to buy on weakness and sell on strength. As such trade orders are placed in a counter direction to price pressure. What you will see on the chart is a short position on peaks and a long position on valleys. This is slightly misleading since a range as well as a trend are best recognized, in hindsight, after the patterns occur on the chart. In the middle of a trade, one never knows how deep valleys will drop or how high peaks will rise. For certain, long trades will continue to trigger as the market prices fall and short trades on rising prices. This means that the maximum efficiency of this strategy is achieved in choppy markets where the price doesn’t extend very far from its adjacent pivot point. Conversely, this strategy will be the least efficient when market conditions exhibit long continuous single direction price pressure. Especially, when measured in weeks. Translation, the trend is not your friend with this strategy. Internally, the script attempts to recognize prolonged price pressure and changes tactics accordingly. However, at best, the goal is to weather the trend until the range bound market returns. At worst, trend detection fails and pyramid trades continue to be placed until the limit specified in the Properties tab is reached. In all likelihood this could trigger a margin call and if it hits the stop it could wipe out your account.
This script has been in beta test four times since inception. During all that time no one has been successful in creating a configuration from scratch. Most people give up after an hour or so. To be perfectly honest, the configuration process is a bear. I know that but there is no way, currently, to create libraries in Pine. There is also no way specify input parameters other than the flattened out 2-D inputs dialog. And the publish rules clearly state that script variations addressing markets or symbols (suites) are not permitted. I suppose the problem is systemic to be-all-end-all solutions like my script is trying to be. I needed a cloud strategy for all the symbols that I trade and since Pine does not support library modules, include files or inter process communication this script and its unruly inputs are my weapon of choice in the war against the market forces. It takes me about six hours to configure a new symbol. Also not all the symbols I configure are equally successful. I should mention that I have a facsimile of this strategy written in another platform which allows me to run a backtest on 10 years of historical data. The results provide me a sanity check on the inputs I select on this platform.
My personal configurations use a 10 minute bar interval on forex instruments and 15 minutes on crypto. I try to align my TradingView scripts to employ standard intervals available from the broker so that I can backtest longer durations than those available on TradingView. For example, Bitcoin at 15 minute bars is downloadable from several sources. I really like the 10 minute bar. It provides lots of detectable patterns and is easy to store many years in an SQL database.
The following steps provide a very brief set of instructions that will get you started but will most certainly not produce the best backtest. A trading system that you are willing to risk your hard earned capital will require a well crafted configuration that involves time, expertise and clearly defined goals. As previously mentioned, I have several example configurations that I use for my own trading that I can share with you if you like. To get hands on experience in setting up your own symbol from scratch please follow the steps below.
Step 1. Setup the Base currency and order size in the properties tab.
Step 2. Select the calculation presets in the Instrument Type field.
Step 3. Select “No Trade” in the Trading Mode field
Step 4. Select the Histogram indicator from Section 2. You will be experimenting with different ones so it doesn’t matter which one you try first.
Step 5. Turn on Show Markers in Section 2.
Step 6. Go to the chart and checkout where the markers show up. Blue is up and red is down. Long trades show up along the red markers and short trades on the blue.
Step 7. Make adjustments to “Base To Vertex” and “Vertex To Base” net change and ROC in Section 2. Use these fields to move the markers to where you want trades to be.
Step 8. Try a different indicator from Section 2 and repeat Step 7 until you find the best match for this instrument on this interval. This step is complete when the Vertex settings and indicator combination produce the most favorable results.
Step 9. Go to Section 4 and enable “Apply Red Base To Base Margin”.
Step 10. Go to Section 5 and enable “Apply Blue Base To Base Margin”.
Step 11. Go to Section 2 and adjust “Minimum Base To Base Blue” and “Minimum Base To Base Red”. Observe the chart and note where the markers move relative to each other. Markers further apart will produce less trades but will reduce cutoffs in “Ping Pong” mode.
Step 12. Turn off Show Markers in Section 2.
Step 13. Put in your Minimum Profit and Stop Loss in the first section. This is in pips or currency basis points (chart right side scale). Percentage is not currently supported. Note that the profit is taken as a conditional exit on a market order not a fixed limit. The actual profit taken will almost always be greater than the amount specified. The stop loss, on the other hand, is indeed a hard number which is executed by the TradingView broker simulator when the threshold is breached.
Step 14. Return to step 3 and select a Trading Mode (Long, Short, BiDir, Ping Pong). If you are planning to trade bidirectionally its best to configure long first then short. Combine them with “BiDir” or “Ping Pong” after setting up both sides of the trade individually. The difference between “BiDir” and “Ping Pong” is that “Ping Pong” uses position reversal and can cut off opposing trades less than the specified minimum profit. As a result “Ping Pong” mode produces the greatest number of trades.
Step 15. Take a look at the chart. Trades should be showing along the markers plotted earlier.
Step 16. Make adjustments to the Vertex fields in Section 2 until the TradingView performance report is showing a profit. This includes the “Minimum Base To Base” fields. If a profit cannot be achieved move on to Step 17.
Step 17. Improve the backtest profitability by adjusting the “Entry Net Change” and “Entry ROC” in Section 4 and 5.
Step 18. Enable the “Mandatory Snap” checkbox in Section 4 and 5 and adjust the “Snap Candle Delta” and “Snap Fractal Delta” in Section 2. This should reduce some chop producing unprofitable reversals.
Step 19. Increase the distance between opposing trades by adding an “Interleave Delta” in Sections 4 and 5. This is a floating point value which starts at 0.01 and typically does not exceed 2.0.
Step 20. Increase the distance between opposing trades even further by adding a “Decay Minimum Span” in Sections 4 and 5. This is an absolute value specified in the symbol’s quote currency (right side scale of the chart). This value is similar to the minimum profit and stop loss fields in Section 1.
Step 21. The “Buy Composite Strength” input works in tandem with “Long Decay Minimum Span” in Section 4. Try enabling and see if it improves the performance. This field is only relevant when there is a value in “Long Decay Minimum Span”.
Step 22. The “Sell Composite Weakness” input works in tandem with “Short Decay Minimum Span” in Section 5. Try enabling and see if it improves the performance. This field is only relevant when there is a value in “Short Decay Minimum Span”.
Step 23. Improve the backtest profitability by adjusting the “Adherence Delta” in Section 4 and 5. This field requires the “Adhere to Rising Trend” checkbox to be enabled.
Step 24. At this point your strategy should be more or less working. Experiment with the remaining check boxes in Section 4 and 5. Keep the ones which seem to improve the performance.
Step 25. Examine the chart and see that trades are being placed in accordance with your desired trading goals. This is an important step. If your desired model requires multiple trades per day then you should be seeing hundreds of trades on the chart. Alternatively, you may be looking to trade fewer steep peaks and deep valleys in which case you should see trades at major turning points. Don’t simply settle for what the backtest serves you. Work your configuration until the system aligns with your desired model. Try changing indicators and even intervals if you cannot reach your simulation goals. Generally speaking, the histogram and Candle indicators produce the most trades. The Fractal indicator captures the tallest peaks and valleys. The Transform indicator is the most reliable but doesn’t well work on all instruments.
Example Settings
To reproduce the performance shown on the chart please use the following configuration:
1. Select XBTUSD Kraken as the chart symbol.
2. On the properties tab set the Order Size to: 0.01 Bitcoin
3. On the properties tab set the Pyramiding to: 10
4. In Section 1: Select “Forex” for the Instrument Type
5. In Section 1: Select “Ping Pong” for the Trading Mode
6. In Section 1: Input 1200 for the Minimum Profit
7. In Section 1: Input 15000 for the Stop Offset
8. In Section 1: Input 1200 for the Pyramid Minimum Span
9. In Section 1: Check mark the Ultra Wide Pyramids
10. In Section 2: Check mark the Use Transform Indicator
So to be clear, I used a base position size of one - one hundredth of a Bitcoin and allow the script to add up to 10 downward pyramids. The example back-test did hit eight downward pyramids. That means the account would have to be able to withstand a base position size (0.01) times 28. The resulting position size is 0.28 of a Bitcoin. If the price of Bitcoin is 35K then the draw down amount (not including broker fees) would be $9800 dollars. Since I have a premium subscription my backtest chart includes 20K historical bars. That's roughly six months of data. As of today, pro accounts only get 10K bars so the performance cannot be exactly matched with such a difference in historical data. Please keep that in mind.
There are, of course, various ways to reduce the risk incurred from accumulating pyramids. You can increase the “Pyramid Minimum Span” input found in Section 2 which increases the space between each pyramid trade. Also you can set a “Pyramid Bale Out Offset” in the same input section. This lets you out of the trade faster on position recovery. For example: Set a value of 8000 into this input and the number of trades increase to 178 from 157. Since the positions didn’t go full term, more trades were created at less profit each. The total brute force approach would be to simply limit the number of pyramids in the Properties tab.
It should be noted that since this is crypto, accumulating on the long side may be what you want. If you are not trading on margin and thus outright buying coins on the Kraken exchange you likely are interested in increasing your Bitcoin position at depressed prices. This is a popular feature on some of the other crypto trading packages like CryptoHopper and Profit Trailer. Click on Enable TV Long Only Rule in Section 1. This switches the signal emitter to long only. However, you may still see short trades on the chart. They are treated as a close instead of a reversal.
Feel free to PM me with any questions related to this script. Thank you and happy trading!
CFTC RULE 4.41
These results are based on simulated or hypothetical performance results that have certain inherent limitations. Unlike the results shown in an actual performance record, these results do not represent actual trading. Also, because these trades have not actually been executed, these results may have under-or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated or hypothetical trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to these being shown.
Nifty's IndicatorThis Indicator is only for Indian market and works only on 'Nifty' and 'Banknifty'. Please don't use it in any other stock/indices.
Use it in only in 3m and 1m timeframe. No other timeframe is to be used.
This indicator gives only sell signals on intraday basis.
When you apply this indicator on charts then you will see 2 things ploted there.
1. Barcolor
2. Background color
Barcolor :
We have use unique trend analysing tool in this indicator, which identifies price is in Uptrend or Downtrend. If price is in uptrend
then candle color will become GREEN and it will remain green until price comes in downtrend. In downtrend candle color becomes RED.
Background color :
We have observed that price behaves a certain way when it is in downtrend. So we try to catch that behaviour of Nifty and Banknifty .
And when ever we observe that behaviour, a red color background is formed in background. This red color background indicates user that
price may fall now.
HOW TO USE :
ENTRY => You should trade only on 3m timeframe. When you see a RED COLOR candle inside RED ZONE then take a SELL trade. That means red background
is indicating that price may fall and red color bar also indicating the same. And your entry should be in between 09:15-10:30 and 12:30-14:55.
This is the time slot when price is volatile.
EXIT => You exit when red zone ends or the trading day ends.
BACKTESTING :
Based on these entry and exit conditions , we have backtested this strategy ( taking only 1 share when sell signal comes ). You can see down arrow on
chart when sell signals comes and uparrow when we exit from trade.
Supertrend - IntradaySupertrend Intraday Strategy
Basic supertrend strategy purpose built for intraday trading. Users can define intraday session during which the strategy will run.
Position is reversed when signal changes by using double quantity. Once the intraday session is over & if the position is open; it is squared off.
Parameters:
Intraday Session - Defines the duration for which the strategy should execute.
Multiplier
ATR Period
Moving Average - IntradayMoving Average Intraday Strategy
Basic moving average strategy purpose built for intraday trading. It uses two simple moving averages & takes a positions on crossover.
Position is reversed when signal changes by using double quantity. Once the intraday session is over & if the position is open; it is squared off.
Users can define intraday session during which the strategy will run.
Parameters:
Intraday Session - Defines the duration for which the strategy should execute.
Short Term Moving Average Period
Long Term Moving Average Period
Simple Moving Average CrossoverThis strategy uses two moving averages of 21 and 8 to generate buy or sell signal.
This is for purely intraday trades and best use in 15 min time frame
This strategy uses angle/slope of ma to filter out period of sideways movement and only generate signals when the stock starts trending in one direction
How to use this
1) Buy when the buy is generated
2) Sell when the sell is generated
Properties you can tweak to adjust this strategy to your needs are
1) angle -> Adjust this properties to define how much slope would be considered to generate the signals, higher the values lesser the trades generated.
2) atr period-> this is to adjust the atr period
3) ma source -> close is considered as source , you can use open or high or low
ak commodity gold,silver intradayHi friends this is Ak commodity gold , silver INTRADAY
It analyse price action when price makes higher high or higher low and it scalps and take profit ..It scalp on 1 min time frame..its occur in moment of time so for that algo trading require..it automatically take profit and stoploss and close trade near session end.it close all trade at 11pm..before commodity session close.. u can also change time for close trade...it automatically calculate previous candles high and low and when it breaks it generate buy and sell signal and take profit and loss
it is not holly grill strategy..it has drawdown...so before use be cauction..it calculates previous more than 200 candles high and low and than generate buy and sell signal.. its main advantage is it close all trade near session end so its more help full for intraday trader for backtesting..
if u want to use my strategy pls personal msg me
ak crude oil intradayHi friends this is Ak CRUDEOIL INTRADAY
It calculate rsi over bought and over sell from different period and generate buy and sell signale
It analyse price action when price makes higher high or higher low and it scalps and take profit ..It scalp on 1 min time frame..its occur in moment of time so for that algo trading require..it automatically take profit and stoploss and close trade near session end.it close all trade at 11pm..before commodity session close.. u can also change time for close trade...it automatically calculate previous candles high and low and when it breaks it generate buy and sell signal and take profit and loss
if u want to use this strategy pls personal message me
Ak for Banknifty intradayHi friends this is Ak for Banknifty Intraday
It analyse price action when price makes higher high or higher low and it scalps and take profit ..its occur in moment of time so for that algo trading require..it automatically take profit and stoploss and close trade near session end. u can also change time for close trade...it automatically calculate previous candles high and low and when it breaks it generate buy and sell signal...
intraday scalper with stopHi friends....publishing intraday scalper which shows the movement of price over time and how strong those movements are/will be, regardless of the direction the price moves, up, or down. Indicator specifically useful, as it helps traders and analysts spot points where the market can and will reverse by providing signals long (buy) and short (sell). Show the relative strength of price movements but leave out the directionality of the price movements, best utilized in combination with other technical indicators – such as trend lines and moving averages – which show price trends and directions. Having an alert feature to make aware market players from signals provided by the indicator.
u can start and close your trades at your define period. Use full for stockmarkets, mcx and forex because all movement occur in new York session....u can set your time to start trading and also for closing. you can also hold position if u want...by changing just close hours at 24..this way u can hold your trade untill next buy/sell signal come..
hope it will help intraday traders
and best of luck to all..
****you can use it any stocks ,forex and crypto**********
some tips for new traders to become sucessful trader
1: always follow risk management...
2: every stock/ forex / crypto has it own cycle.. So pls dont jump from one stock / forex pair to another when u hear some stock / crypto has
made new high or low... Bcs after that consolidation period starts.. During consolidation we can not make more profit as in trending market.. So be patient when u had made some position or tarde in one stock/ pair...
3 : we dont require to trade in every stocks / forex/crypto.. Just one stock and pair trading daily make u profitable beyond ur expection.. Bcs
trading in one stock / forex pair.. make u very comfortable and u may always know its movement... And u also trade in every cycle of this
stock/ pair.. So u also trdae its trend days which made highest profit. We dont know when is trend of any stock... Compare with it
business... Trading is business not one day rich game... Its business... It takes time and u have to do same thing agian and again to become
sucessfull trader for this u can use tradingview alerts. .for that u dont need to seat infrot of ur terminal screen.. u can also do algo trading
by using tradingview alerts
4 : By following risk management and incerase lot size as profit increased... This is the key 🔑 of sucess in stocks / forex / crypto market.
I thinks this tips may help new trader. U can modified according to ur trading style..
You can personal message me if u want to use this strategy
Swing Algo For Allhi friends....publishing Swing Algo For All .. which shows the movement of price over time and how strong those movements are/will be, regardless of the direction the price moves, up, or down. Indicator specifically useful, as it helps traders and analysts spot points where the market can and will reverse by providing signals long (buy) and short (sell). Show the relative strength of price movements but leave out the directionality of the price movements, best utilized in combination with other technical indicators – such as trend lines and moving averages – which show price trends and directions. Having an alert feature to make aware market players from signals provided by the strategy.
There are mainly 3 tyes of swing traders
1 intraday swing trader
2 weekly positional swing trader
3 monthly/yearly positional swing trader
This strategy solves problem of all the type of swing trader. you have to just select type of swing which u want to trade suppose u chose intraday swing it automatically calculate intraday swing high and low and shows buy and sell sign according to it...if it shows buy signal than in lower part it shows plotted line when this line break it automatically generate sell signal and vice versa for sell signal.
same for weekly , monthly and yearly
u can use it in any time frame bcs swing structure are same in any time frame
*********************************************************************************************************
*************** And also use for any stocks, forex and crypto*****************
screenshot on Banknifty weekly swing
some tips for new traders to become successful trader
1: always follow risk management...
2: every stock/ forex / crypto has it own cycle.. So pls dont jump from one stock / forex pair to another when u hear some stock / crypto has
made new high or low... Bcs after that consolidation period starts.. During consolidation we can not make more profit as in trending market.. So be patient when u had made some position or tarde in one stock/ pair...
3 : we dont require to trade in every stocks / forex/crypto.. Just one stock and pair trading daily make u profitable beyond ur expection.. Bcs
trading in one stock / forex pair.. make u very comfortable and u may always know its movement... And u also trade in every cycle of this
stock/ pair.. So u also trdae its trend days which made highest profit. We dont know when is trend of any stock... Compare with it
business... Trading is business not one day rich game... Its business... It takes time and u have to do same thing agian and again to become
sucessfull trader for this u can use tradingview alerts. .for that u dont need to seat infrot of ur terminal screen.. u can also do algo trading
by using tradingview alerts
4 : By following risk management and incerase lot size as profit increased... This is the key 🔑 of sucess in stocks / forex / crypto market.
I thinks this tips may help new trader. U can modified according to ur trading style..
You can personal message me if u want to use this strategy
u can personal message me if u want to use it..