EMAs Daily ResetThis indicator displays 3 EMAs that recalculate every day.
This is useful for intraday trading by removing the bias of the previous day's ema price. This ensures your EMAs stay near the most current price action.
Note: If your length is larger than the number of bars in the day, your EMAs will not have time to properly catch up in the day.
Intraday
Strat Magnitude LinesHave you ever wished you could easily see the daily magnitude line of a Strat Combo while on a smaller timeframe intraday chart? This indicator allows you to do that and much more!
Description
This indicator does two simple things, but it does them very well. The first thing it does is draw a small horizontal line at the magnitude level of a Strat Setup (a potential Strat Combo before the last candle has formed) on the daily chart. This is intended to help the user easy ascertain how much magnitude distance (distance between trigger line and magnitude line) of a potential Strat Combo the night before when the user is searching for trades to play the next trading day. If the last two candles on a daily chart form the first two bars of a Strat Combo, then this indicator display a horizontal line where the ultimate magnitude would be if the next trading day a Strat Combo was formed. This helps the trader gauge whether there is sufficient magnitude that makes it worth it to even consider trading the next day.
The second and most important thing this indicator does is display the daily magnitude line while the user is in a smaller timeframe managing their trade. This helps the user have an easily identifiable line to show where to take full or partial profit at. There is no need to keep track of manually drawn lines or the hassle of letting your charts get cluttered with lines that the user forgot to delete. This indicator finds potential Strat Combos (aka Strat Setups) and dynamically draws horizontal lines for the user and removes them when they are no longer in use. The user can focus on taking profit and making money and leave the hassle to the indicator.
Inputs & Style
All four lines (two daily lines and two intraday lines) can be independently configured. Each lines color, line style, and width can be adjusted. To turn “off” a line change the opacity to 0%.
Automatic daily magnitude line on intraday chart
Market Sessions (including extended hours) by Anche█ MARKET SESSIONS BY ANCHE
this script allows you to define up to 4 different sessions and plot those on your chart. It makes it easy to see when these sessions started and ended and what the price level is when the session opened. It's for example beneficial to see when sessions overlap, because at those times there might be more volume , because more people are active within a market.
█ CONCEPTS
• plotting these sessions onto a chart can help you see overlap of 2 or more sessions. An overlap means more market participants, which can hint to an increase in volume .
• when the indicator shows all historic sessions, you can spot certain trends, for example that an asian market is generally more bearish and EU more bullish , or vice versa.
█ FEATURES
• up to 4 sessions
• customisable session labels
• customisable session times
• extended hours (on/off)
• timezone sync
• show past sessions
█ VISUAL FEATURES
• session plotted by top + bottom line or a box
• show session open
• customisable colors per session
• customisable lines (width/style/color)
• different visual settings for extended hours
• customisable label sizes
Anna-LysaEspecially useful when using it for stocks in intraday screening for daytrading.
This gives you quick information about the volatility at the moment when you look at the stock.
The current range of the last candles (adjustable) is calculated so that you can stop based on the Vola.
In addition, the daily volume and daily range are calculated in the table and what is left of the average.
So that you can adjust your ideas for the movement in order to take profit. No matter what the timeframe, you can see how the volume compares to that of the previous few candles and thus anticipate the most likely breakout.
Then the most relevant day trading levels ( Premarkets, Lastday high/lows and some Ma´s ) are shown so that you can get a very fast overview of the stock at the moment.
All levels and labels and colors are adjustable or hidden in the settings.
WAP Maverick - (Dual EMA Smoothed VWAP) - [mutantdog]Short Version:
This here is my take on the popular VWAP indicator with several novel features including:
Dual EMA smoothing.
Arithmetic and Harmonic Mean plots.
Custom Anchor feat. Intraday Session Sizes.
2 Pairs of Bands.
Side Input for Connection to other Indicator.
This can be used 'out of the box' as a replacement VWAP, benefitting from smoother transitions and easy-to-use custom alerts.
By design however, this is intended to be a highly customisable alternative with many adjustable parameters and a pseudo-modular input system to connect with another indicator. Well suited for the tweakers around here and those who like to get a little more creative.
I made this primarily for crypto although it should work for other markets. Default settings are best suited to 15m timeframe - the anchor of 1 week is ideal for crypto which often follows a cyclical nature from Monday through Sunday. In 15m, the default ema length of 21 means that the wap comes to match a standard vwap towards the end of Monday. If using higher chart timeframes, i recommend decreasing the ema length to closely match this principle (suggested: for 1h chart, try length = 8; for 4h chart, length = 2 or 3 should suffice).
Note: the use of harmonic mean calculations will cause problems on any data source incorporating both positive and negative values, it may also return unusable results on extremely low-value charts (eg: low-sat coins in /btc pairs).
Long version:
The development of this project was one driven more by experimentation than a specific end-goal, however i have tried to fine-tune everything into a coherent usable end-product. With that in mind then, this walkthrough will follow something of a development chronology as i dissect the various functions.
DUAL-EMA SMOOTHING
At its core this is based upon / adapted from the standard vwap indicator provided by TradingView although I have modified and changed most of it. The first mod is the dual ema smoothing. Rather than simply applying an ema to the output of the standard vwap function, instead i have incorporated the ema in a manner analogous to the way smas are used within a standard vwma. Sticking for now with the arithmetic mean, the basic vwap calculation is simply sum(source * volume) / sum(volume) across the anchored period. In this case i have simply applied an ema to each of the numerator and denominator values resulting in ema(sum(source * volume)) / ema(sum(volume)) with the ema length independent of the anchor. This results in smoother (albeit slower) transitions than the aforementioned post-vwap method. Furthermore in the case when anchor period is equal to current timeframe, the result is a basic volume-weighted ema.
The example below shows a standard vwap (1week anchor) in blue, a 21-ema applied to the vwap in purple and a dual-21-ema smoothed wap in gold. Notably both ema types come to effectively resemble the standard vwap after around 24 hours into the new anchor session but how they behave in the meantime is very different. The dual-ema transitions quite gradually while the post-vwap ema immediately sets about trying to catch up. Incidentally. a similar and slower variation of the dual-ema can be achieved with dual-rma although i have not included it in this indicator, attempted analogues using sma or wma were far less useful however.
STANDARD DEVIATION AND BANDS
With this updated calculation, a corresponding update to the standard deviation is also required. The vwap has its own anchored volume-weighted st.dev but this cannot be used in combination with the ema smoothing so instead it has been recalculated appropriately. There are two pairs of bands with separate multipliers (stepped to 0.1x) and in both cases high and low bands can be activated or deactivated individually. An example usage for this would be to create different upper and lower bands for profit and stoploss targets. Alerts can be set easily for different crossing conditions, more on this later.
Alongside the bands, i have also added the option to shift ('Deviate') the entire indicator up or down according to a multiple of the corrected st.dev value. This has many potential uses, for example if we want to bias our analysis in one direction it may be useful to move the wap in the opposite. Or if the asset is trading within a narrow range and we are waiting on a breakout, we could shift to the desired level and set alerts accordingly. The 'Deviate' parameter applies to the entire indicator including the bands which will remain centred on the main WAP.
CUSTOM (W)ANCHOR
Ever thought about using a vwap with anchor periods smaller than a day? Here you can do just that. I've removed the Earnings/Dividends/Splits options from the basic vwap and added an 'Intraday' option instead. When selected, a custom anchor length can be created as a multiple of minutes (default steps of 60 mins but can input any value from 0 - 1440). While this may not seem at first like a useful feature for anyone except hi-speed scalpers, this actually offers more interesting potential than it appears.
When set to 0 minutes the current timeframe is always used, turning this into the basic volume-weighted ema mentioned earlier. When using other low time frames the anchor can act as a pre-ema filter creating a stepped effect akin to an adaptive MA. Used in combination with the bands, the result is a kind of volume-weighted adaptive exponential bollinger band; if such a thing does not already exist then this is where you create it. Alternatively, by combining two instances you may find potential interesting crosses between an intraday wap and a standard timeframe wap. Below is an example set to intraday with 480 mins, 2x st.dev bands and ema length 21. Included for comparison in purple is a standard 21 ema.
I'm sure there are many potential uses to be found here, so be creative and please share anything you come up with in the comments.
ARITHMETIC AND HARMONIC MEAN CALCULATIONS
The standard vwap uses the arithmetic mean in its calculation. Indeed, most mean calculations tend to be arithmetic: sma being the most widely used example. When volume weighting is involved though this can lead to a slight bias in favour of upward moves over downward. While the effect of this is minor, over longer anchor periods it can become increasingly significant. The harmonic mean, on the other hand, has the opposite effect which results in a value that is always lower than the arithmetic mean. By viewing both arithmetic and harmonic waps together, the extent to which they diverge from each other can be used as a visual reference of how much price has changed during the anchored period.
Furthermore, the harmonic mean may actually be the more appropriate one to use during downtrends or bearish periods, in principle at least. Consider that a short trade is functionally the same as a long trade on the inverse of the pair (eg: selling BTC/USD is the same as buying USD/BTC). With the harmonic mean being an inverse of the arithmetic then, it makes sense to use it instead. To illustrate this below is a snapshot of LUNA/USDT on the left with its inverse 1/(LUNA/USDT) = USDT/LUNA on the right. On both charts is a wap with identical settings, note the resistance on the left and its corresponding support on the right. It should be easy from this to see that the lower harmonic wap on the left corresponds to the upper arithmetic wap on the right. Thus, it would appear that the harmonic mean should be used in a downtrend. In principle, at least...
In reality though, it is not quite so black and white. Rarely are these values exact in their predictions and the sort of range one should allow for inaccuracies will likely be greater than the difference between these two means. Furthermore, the ema smoothing has already introduced some lag and thus additional inaccuracies. Nevertheless, the symmetry warrants its inclusion.
SIDE INPUT & ALERTS
Finally we move on to the pseudo-modular component here. While TradingView allows some interoperability between indicators, it is limited to just one connection. Any attempt to use multiple source inputs will remove this functionality completely. The workaround here is to instead use custom 'string' input menus for additional sources, preserving this function in the sole 'source' input. In this case, since the wap itself is dependant only price and volume, i have repurposed the full 'source' into the second 'side' input. This allows for a separate indicator to interact with this one that can be used for triggering alerts. You could even use another instance of this one (there is a hidden wap:mid plot intended for this use which is the midpoint between both means). Note that deleting a connected indicator may result in the deletion of those connected to it.
Preset alertconditions are available for crossings of the side input above and below the main wap, alongside several customisable alerts with corresponding visual markers based upon selectable conditions. Alerts for band crossings apply only to those that are active and only crossings of the type specified within the 'crosses' subsection of the indicator settings. The included options make it easy to create buy alerts specific to certain bands with sell alerts specific to other bands. The chart below shows two instances with differing anchor periods, both are connected with buy and sell alerts enabled for visible bands.
Okay... So that just about covers it here, i think. As mentioned earlier this is the product of various experiments while i have been learning my way around PineScript. Some of those experiments have been branched off from this in order to not over-clutter it with functions. The pseudo-modular design and the 'side' input are the result of an attempt to create a connective framework across various projects. Even on its own though, this should offer plenty of tweaking potential for anyone who likes to venture away from the usual standards, all the while still retaining its core purpose as a traders tool.
Thanks for checking this out. I look forward to any feedback below.
VocsOng Intraday Support ResistanceOverview
This indicator is meant for intraday trading, mainly designed for SPX . The main purpose of this indicator is to mark out the key levels of support and resistance for intraday.
There are 9 main support and resistance that forms this intraday support resistance indicator.
1. Today's Open
Today's open is often a neglected area because by default change percentage is always based on yesterday close. So having a line drawn for today's open is the very starting point.
2. Yesterday Close
3. Yesterday High
4. Yesterday Low
Yesterday Close, High, Low are important intraday trading areas, it is very common that price action resist at this area.
5. Past 4 Days Calculated Estimated High (YesterdayClose + (EstimatedRange/2) :: EstimatedRange = Nearest day x0.4, followed by 0.3, 0.2, 0.1)
6. Past 4 Days Calculated Estimated Low (YesterdayClose - (EstimatedRange/2) :: EstimatedRange = Nearest day x0.4, followed by 0.3, 0.2, 0.1)
This is a calculated estimated high/low range based on past 4 days range. Weighing the nearest day heaviest of 40%, followed by 30%, 20%, 10%.
This calculated high/low area apparently also act as good support and resistance area sometimes.
7. Expected Move High (YesterdayClose + VIX/100 * SquareRoot(1/365))
8. Expected Move Low (YesterdayClose - VIX/100 * SquareRoot(1/365))
This is the formula used to calculate expected move LIVE based on current VIX. This is based from today's open.
9. 1.5% to 2% from SPX Open today
This marks out a zone where SPX is 1.5% to 2% away from today's open. This gives a general guide on a fix percentage change based on today's open.
Statistically, SPX close within 1.5% change from today's open 93.18% of the time in the past 10 years.
How I use them?
First to note, this indicator works best on 1 minute chart. Other timeframe might not be that accurate.
All these are intraday support and resistance. They can be simply use as support and resistance by default.
In addition to that, 7,8,9 are also used as overbought/oversold indicator because they are centered to today's open.
As SPX move towards 7,8,9, it shows how overbought or oversold it is.
I use this indicator with SPX 0 dte options trading.
So as SPX approaches the oversold area, and near any of the support, I will sell a 30 wide put credit spread at 5 delta away or $1 target credit.
This trade entry goes together with a bracket take profit (80%) and stop loss (200%) OCO order.
Initial BalanceThis script calculates and draws the initial balance price levels which can be really interesting for intraday activities.
Note: Obviously, you need to wait for the calculation period to finish in order to see your daily levels
The tool includes the following options
Customization of the session used to calculate the initial balance (default 0930-1030)
Show/Hide the calculation period (as a background color)
Show/Hide extra levels (report the IBH-IBL delta above and under the IB area)
Show/Hide intermediate levels (displays 50% price levels in the IB and extra areas)
Show labels (Display levels names as well as their price on corresponding lines)
Levels names:
- IBH (Initial Balance High)
- IBH (Initial Balance Low)
- IBM (Initial Balance Middle)
- IBH x2
- IBL x2
Default colors are green for high levels, red for low levels, and orange for intermediate levels
Extend levels (extends the current levels to left/right/both/none sides of the chart)
MILK (My Intraday Lazy Kit)I made this script to group information considered useful in forex day trading, of course it can be used on crypto or other markets.
First of all, feel free to suggest any improvement/new feature you would consider interesting for such an use. This is not especially a final version and I'm sure other relevant information can be added in this tool.
Current features are the following
An international clock showing time and session status (open/closed) for 5 different cities. You can modify it in parameters.
Drawings of previous days/weeks open/high/low/close prices, which will be often used as supports and resistances zones.
The Clock shows
City
Time (with a bgcolor corresponding to the "period" of the day (Morning, Afternoon, Evening, Night)
Session status (Cyan when the corresponding session is open, blue when it's closed)
Price levels names are
YTD-H : Yesterday's high
YTD-L : Yesterday's low
YTD-C : Yesterday's close
YTD-O : Yesterday's open
PWH : Previous week high
PWL : Previous week low
PWO : Previous week open
PWC : Previous week close
Levels width and colors can be modified.
You can also enable/disable the clock, and daily or weekly levels in the options panel.
Nothing more to say for now, I mainly integrated information I like to have, but I'll probably add new features in it if I get some.
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)
RVI Relative Volume IntradayRVI Relative Volume Intraday is a simple label next to the last bar that shows the relative volume as a percentage of the ratio of today's volume to the average volume for the same intraday time period of the last five days. Useful for break-out intraday strategies.
Intraday Volume Spikes HeatmapA tool to identify and visualize abnormal volume clusters. Intended for intraday charts with volume data available. Works out of the box without a need for setting up 100500 parameters.
Features:
Customizable table
4 modes
17 color palettes including Viridis, Inferno, Magma and Plasma available
Example: Viridis palette
Example: Inferno palette
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.
Moving Average and PerformanceThis indicator combines several tools that are used daily for analysis:
The performance of the action we are seeing.
The percentage of retracement the stock has made from its all time high.
Possibility of using up to four exponential or simple moving averages in the length we want.
It allows to see or not the levels of four moving averages in daily temporality.
This indicator is unique since it allows you to see in real time the performance of the Stock or ETF that is being analyzed, which allows you to make a timely decision for short, medium or long-term investments.
If you are doing scalping, swing, or intraday trading, you can see the retracement it has made from the ATH (3, 5, 10 or 13%) which can become Supports or Resistances where the price can rebound, Likewise, the levels of the moving averages in 1D temporality can be observed at the same time, which are usually dynamic supports or resistances and it can also be observed in the same temporality of the chart four moving averages that the trader can configure in the length that you deem convenient to improve your analysis and make decisions as quickly as possible.
Este indicador es único ya que permite ver en tiempo real el rendimiento de la Acción o ETF que se está analizando, lo cual permite tomar una decisión oportuna para las inversiones a corto, mediano o largo plazo.
Si se está haciendo trading tipo scalping, swing, o intradía, se puede observar el retroceso que ha hecho desde el ATH (3, 5, 10 o 13%) el cual puede convertirse en Soportes o Resistencias en donde el precio puede hacer rebotes, así mismo se pueden estar observando al mismo tiempo los niveles de las medias móviles en temporalidad de 1D, los cuales usualmente son Soportes o resistencias dinámicas y también se puede observar en la misma temporalidad del gráfico cuatro medias móviles que el trader puede configurar en la longitud que crea conveniente para mejorar su análisis y tomar decisiones lo más rápido posible.
Intraday Trading ZonesThis script can help in intraday trading. It can plot
1. Previous day high, low and close.
2. Intraday Fibonacci levels
3. Big Round Numbers
3. CPR (Central Pivot Range)
4. VWAP
DSKOLI BaseThis helps to determine bullish or bearish trend of any chart on any time-frame and good to have for Intraday watch.
Details -
a. Label-Up/Down shows the recent price movement is getting bullish or bearish from zero/neutral base by comparing to previous few candles.
b. EMA line helps to know the price movement of candles are above or below the EMA and its coloured with red and green which even further helps to determine its existing trend.
c. A plot Trend line which is quite close to candles with red and green line and arrow is calculated from few candles' high and low values with some mathematical formulas which along EMA adds more value for trend identification.
d. Recent High/Low automatically plots support and resistance lines on basis of previous swing high or low. An alert is added for any these levels breakout or breakdown.
Note or Disclaimer:
1. This may be considered only for Watching as Learning and informational purpose.
2. Take advice from financial advisor before entering, holding, converting or exiting from any order or trade.
3. Always keep your acceptable stop-loss in all your transactions while trading or investing.
DSKOLI or TradingView reserves all right and don't hold any responsibilities for any loss/losses as well as accuracy of levels or price movement.
CRYPTOPRODear traders,
Welcome to CRYPTOPRO indicator. Only for crypto markets! This is an invite only script, please PM me to request permission for testing and access.
This indicator is developed as a scalping, intraday or swingtrade strategy.
Been working on indicators for years now, now back to trading again and made the best possible indicator for different timeframes.
The indicator uses market data, multiple timeframe ma/rsi charts and price action for determining a long or short strategy.
The indicator does not repaint!
I have made the indicator as easy as possible to use with added background colors.
How to use:
- Long strategy: when background turns to green after bar closing.
- Short strategy: when background turns to red after bar closing.
Alerts:
- Alerts are included in the indicator and are very simple to use.
- Alert "buy" for long strategy (green background)
- Alert "sell" for short strategy (red background)
- The alerts can also be used for automated trading/bot trading.
Time Frames :
- Can be used for all different timeframes.
Chart candles:
- Indicator is to be used with standard prince candles.
Note:
- Trading and financial markets are always risky and unpredictable.
- All trades made based on this indicator and his results are always your own responsibility.
- As an author i will not be held responsible for any of your trading profit or loss. Always be cautious when trading.
Charts can be applied to all TV supported crypto charts.
If you find the indicator usefull share your support and feedback in the comments.
Any questions PM me for more info.Thank you!
DISCLAIMER:
No sharing, copying, reselling, or any other forms of use are authorized for our scripts / strategy, and the information published with them.
This script / strategy is strictly for individual use.
This is not financial or investment advice. Investments are always made at your own risk and are based on your personal judgement.
NYTRADE is not responsible for any losses you may incur. Please trade wisely.
Wide BarsSimple scripts show the wide range bars within in the look back period, visualizing the bigger momentum.
Added four exponential moving averages which define the trend of the instrument.
Wide range candles in the direction of overall trend on higher timeframes; give confluence of higher participation in the same direction.
Note : Decent volume above the average volume with wide range candle adds more value.
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.