Periodic EllipsesThe following script periodically plot ellipses to the chart, where the maximum height of the ellipses is determined by the price high of the user-selected time frame while the price low determines the minimum height of the ellipses.
The selected time frame affects the frequency at which the ellipses are plotted, for example, a selected time frame of 1 week will plot an ellipse every week
Note that time frames that are close to the one used in the main chart can return noncircular shapes
Here the main time frame is 15 minutes, while the time frame in the script is 1 hour.
By default the script uses future data, and as such repaint which makes it only useful in offline (non-real time) situations, you can make the script use only past data by deselecting the "repaint" option.
Interpretation And Construction
In terms of usages and interpretation ellipses are similar to bands indicators, as such we can use ellipses in a breakout methodology, where a closing price crossing over the upper bound indicating an uptrend and a closing price crossing under the lower bound indicating a downtrend.
By default, the color of the plots are based on a gradient determined by the position of the closing price relative to the ellipse, with a closing price closer to the upper bound of the ellipse returning a blue color and a closing price closer to the lower bound returning a red color, the intermediate color is violet. When repainting mode is deactivated a blue color indicates an up-trend, while a red color indicates a down-trend, violet colors on the other hand indicate a ranging market.
The ellipses can also determine possible retracements, as such the upper bound of the ellipse can act as a support in an uptrend while the lower bound can act as a resistance in a downtrend.
Construction
Peoples might be interested in the construction of ellipses, this task is not complicated. We can construct circular shapes by using the equation of a semi-circle described as follows:
C = √(1 - x*x)
with 1 ≥ x ≥ -1 , values of x greater than 1 or lower than -1 will return na . In the script, the variable basis creates a line starting at -1 and ending at 1, we then only need to apply the previous equation to this line to have a semi-circle. This semi-circle is in a range of (0,1), so we need to rescale it in a useful range, let's define the highest high of the selected time frame as H and the lowest low as L , the upper and lower bound of the ellipse are calculated as follows:
upper = avg(H,L) + C*(H - avg(H,L))
lower = avg(H,L) - C*(avg(H,L) - L)
Summary
A script plotting ellipses has been proposed, we have seen that the signals that can be generated are similar to the one generated by band indicators, note however that the script has not been made to be a serious indicator, it would be more advisable to use regular band indicators instead.
Thx to @freds_view for the question.
Repaint
RSI Call-outs [BigBitsIO]This is a simple RSI indicator that overlays the current chart to show labels for specified oversold and overbought areas defined with inputs.
It will delete any labels of the same kind within the last 3 candles so you don't see as many labels as you would otherwise.
Red labels with white text represent overbought RSI levels as defined by the user.
Green labels with black test represent oversold RSI levels as defined by the user.
This RSI overlay help easily call-out overbought and oversold candles on a chart without sacrificing screen space for a traditional RSI indicator that is not overlayed on the chart.
How to avoid repainting when NOT using security()Even when your code does not use security() calls, repainting dynamics still come into play in the realtime bar. Script coders and users must understand them and, if they choose to avoid repainting, need to know how to do so. This script demonstrates three methods to avoid repainting when NOT using the security() function.
Note that repainting dynamics when not using security() usually only come into play in the realtime bar, as historical data is fixed and thus cannot cause repainting, except in situations related to stock splits or dividend adjustments.
For those who don’t want to read
Configure your alerts to trigger “Once Per Bar Close” and you’re done.
For those who want to understand
Put this indicator on a 1 minute or seconds chart with a live symbol. As price changes you will see four of this script’s MAs (all except the two orange ones) move in the realtime bar. You are seeing repainting in action. When the current realtime bar closes and becomes a historical bar, the lines on the historical bars will no longer move, as the bar’s OHLC values are fixed. Note that you may need to refresh your chart to see the correct historical OHLC values, as exchange feeds sometimes produce very slight variations between the end values of the realtime bar and those of the same bar once it becomes a historical bar.
Some traders do not use signals generated by a script but simply want to avoid seeing the lines plotted by their scripts move during the realtime bar. They are concerned with repainting of the lines .
Other traders use their scripts to evaluate conditions, which they use to either plot markers on the chart, trigger alerts, or both. They may not care about the script’s plotted lines repainting, but do not want their markers to appear/disappear on the chart, nor their alerts to trigger for a condition that becomes true during the realtime bar but is no longer true once it closes. Those traders are more concerned with repainting of signals .
For each of the three methods shown in this script’s code, comments explain if its lines, markers and alerts will repaint or not. Through the Settings/Inputs you will be able to control plotting of lines and markers corresponding to each method, as well as experiment with the option, for method 2, of disabling only the lines plotting in the realtime bar while still allowing the markers and alerts to be generated.
An unavoidable fact is that non-repainting lines, markers or alerts are always late compared to repainting ones. The good news is that how late they are will in many cases be insignificant, so that the added reliability of the information they provide will largely offset the disadvantages of waiting.
Method 1 illustrates the usual way of going about things in a script. Its gray lines and markers will always repaint but repainting of the alerts the marker conditions generate can be avoided by configuring alerts to trigger “Once Per Bar Close”. Because this gray marker repaints, you will occasionally see it appear/disappear during the realtime bar when the gray MAs cross/un-cross.
Method 2 plots the same MAs as method 1, but in green. The difference is that it delays its marker condition by one bar to ensure it does not repaint. Its lines will normally repaint but its markers will not, as they pop up after the condition has been confirmed on the bar preceding the realtime bar. Its markers appear at the beginning of the realtime bar and will never disappear. When using this method alerts can be configured to trigger “Once Per Bar” so they fire the moment the marker appears on the chart at the beginning of the realtime bar. Note that the delay incurred between methods 1 and 2 is merely the instant between the close of a realtime bar and the beginning of the next one—a delay measured in milliseconds. Method 2 also allows its lines to be hidden in the realtime bar with the corresponding option in the script’s Settings/Inputs . This will be useful to those wishing to eliminate unreliable lines from the realtime bar. Commented lines in method 2 provide for a 2b option, which is to delay the calculation of the MAs rather than the cross condition. It has the obvious inconvenient of plotting delayed MAs, but may come in handy in some situations.
Method 3 is not the best solution when using MAs because it uses the open of bars rather than their close to calculate the MAs. While this provides a way of avoiding repainting, it is not ideal in the case of MA calcs but may come in handy in other cases. The orange lines and markers of method 3 will not repaint because the value of open cannot change in the realtime bar. Because its markers do not repaint, alerts may be configured using “Once Per Bar”.
Spend some time playing with the different options and looking at how this indicator’s lines plot and behave when you refresh you chart. We hope everything you need to understand and prevent repainting when not using security() is there.
Look first. Then leap.
Zero Phase Filtering [Repaint] - ExperimentalImportant !
The indicator is for experimental purpose only, it must not be used as a decisional tool but only as a visual one (like Zig-Zag, Fractal etc). The information this indicator display is uncertain and subject to drastic changes over time. If you have further question feel free to pm me.
Introduction
Most of the filters you will find are causal, this mean that they depend on present and past input values, this explain the lag they produce. Non causal filters however will use future input values. A well know way to get a zero-phase filter is by using the forward backward method, but this is not possible in pinescript as i recall. So we have to use some kind of function that will display future values, this is possible using the security function in version 2 or the one in version 3 using barmerge.lookahead_on .
The Use Of A Repainting Indicator
Its always better to filter data in order to have a clearer view of what is happening, this can be useful when doing some forecasting or doing less formal kind of analysis. However since it repaint you cant use it as a signal provider or use signals of other indicators using this filter as source.
For example if you want to forecast a smooth indicator, the forecast of this indicator under normal circumstances could still have lag associated with it, so you would have to react before your forecast, this wont happen if you apply this filter as your indicator source.
The Filter
We smooth with a simple moving average the price provided by the security function twice, length control the smoothing level. Since security depend on the time frame you are in you must select your time frame in the indicator parameter selection window.
Filtering using 45 minutes time frame close price in a 5 minutes chart, we fix this by selecting our time frame.
Consider the fact that the input of the indicator is just periodic price, so sometimes the lag can sometimes be less or more than 0 and the estimation not centered.
The indicator can work on time frames up to 1h, after that the filter have some lag, i tried fixing this and i ended up having data errors.
Applying our filter as source for the rsi oscillator.
Conclusion
It is possible to have a kind of zero-phase filters, but it would be better if pinescript could support backward indexing thus making us able to do forward backward filtering.
Since noise can affect our analysis, applying smoothing without having to use offset in plot can be considered useful.
ZigZag Repaint Examplesimple example showing how to use na to create straight lines that "repaint" as the latest bars update.
Upper Timeframe - Repaint FixThis script is a proof of concept and one possible solution for how to deal with upper timeframe repainting issues. It works for Strategies only .
Strategies that utilize data from upper timeframes can still be subject to repainting issues when forward testing. Users can copy the code and use a similar solution in your own scripts.
For full code commentary, explanations and examples visit the backtest-rookies (.com) website.
14/28 Day SMA Divergence and RSI - No RepaintIf you are interested in purchasing my algorithmic trading bot that receives Tradingview indicator alerts via email and then executes them in Bittrex, please visit my product page here: ilikestocks.com Additionally, I would love to create video/blog guides on creating Tradingview scripts or strategies. If you are a knowledgeable in finance or other related fields and would like to be featured on my page, please contact me at tanner@ilikestocks.com.
No crossovers were used in this script, and this is likely the reason for the no repaint(Correct me if wrong).
This strategy script uses a 14-day SMA signal line, a 28-day SMA and RSI. The strategy works by determining whether the (14-day SMA is above the 28-day SMA and the RSI levels are overbought(below 30)) or RSI is very overbought(below 13 or so). Once either of these conditions have been met, a long position is opened.
The initial long position must be partially closed by the take profit first and then the final close is executed if the 14-day signal SMA is below the 28-day SMA; you may also exclusively use take profit to close positions.
The green plotted spikes are the initial long position conditions. The orange plotted spikes are take profit signals once a long position is opened. The red plotted spikes are plotted when the SMA 14-day is below the 28-day SMA.
Please do leave constructive criticism or comments below because it helps me better create scripts!
GMAE Original (By Kevin Manrrique)This script is called GMAE Original by me (Kevin Manrrique). I'm publishing this to the public because we are all traders and we need to support each other as a TVcommunity. This is something I built for fun. This script uses a series of EMA's. NO REPAINT, NO LAGGING! It works better for short-term trends as you can see. Please leave the copyright on the script at all times even if you rebuild it. If you need any help or have questions please inbox me privately. If you interested in joining up and building an indicator or strategy please inbox me as well. Thank you and I hope you enjoy this script as much as I do.
Remember there are no holy grails. The only holy grail there is are indicators built together to stop faulty signals and be as accurate as possible and this is one of them.
Sincerely,
Kevin Manrrique
Daily Close Comparison Strategy (by ChartArt via sirolf2009)Comparing daily close prices as a strategy.
This strategy is equal to the very popular "ANN Strategy" coded by sirolf2009(1) which calculates the percentage difference of the daily close price, but this bar-bone version works completely without his Artificial Neural Network (ANN) part.
Main difference besides stripping out the ANN is that my version uses close prices instead of OHLC4 prices, because they perform better in backtesting. And the default threshold is set to 0 to keep it simple instead of 0.0014 with a larger step value of 0.001 instead of 0.0001. Just like the ANN strategy this strategy goes long if the close of the current day is larger than the close price of the last day. If the inverse logic is true, the strategy goes short (last close larger current close). (2)
This basic strategy does not have any stop loss or take profit money management logic. And I repeat, the credit for the fundamental code idea goes to sirolf2009.
(2) Because the multi-time-frame close of the current day is future data, meaning not available in live-trading (also described as repainting), is the reason why this strategy and the original "ANN Strategy" coded by sirolf2009 perform so excellent in backtesting.
All trading involves high risk; past performance is not necessarily indicative of future results. Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated 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 those shown.
(1) You can get the original code by sirolf2009 including the ANN as indicator here:
(1) and this is sirolf2009's very popular strategy version of his ANN: