OPEN-SOURCE SCRIPT

Difference over bars

Description:
One of my followers asked about an indicator that shows the difference between the open and a previous close and didn't find one so I wrote this one. This is similar to a momentum indicator except it offers more flexibility. While the standard momentum indicator calculates a difference between current close and a previous close (sometimes customizable to work on open, high or lows instead of close), this allows to mix and match between open, high, low and close. It also offers multiple kinds of moving averages.

Settings:
  • Current point of reference [this is one of the OHLC values]
  • Previous point of reference [this is one of the OHLC values]
  • Difference over how many bars?


How it works:
The indicator calculates the difference between the current point of reference and a previous (n-bars back) point of reference (where n is given by the "Difference over how many bars?").

How to use it:
  • find historical support lines like the 0.68 line in the cart above where in the past the indicator tends to bounce back; similarly find resistance lines like the -0.75 line in the chart (which servers as a resistance line both for the main indicator line [blue] and its moving average [red])
  • look for convergence between the price and the indicator; for example, if the price is going up and the indicator is going down a change in the price direction may be coming soon
  • look for the indicator crossing its moving average: moving up will signify an up trend and vice-versa
  • since the difference between the open and previous close (which is what the blue line in the chart shows) since to go up to 0.68 (the upper horizontal line) and down to -0.75 (the lower horizontal line) most of the time, one strategy, using options, is to to buy, right before the close of a trading day, a "long iron butterfly": buy-to-open (BTO) both a call and a put at the strike price and sell-to-open (STO) a call at a strike of around $0.68 more and sell to open a put at a strike of around $0.75 less. The STO legs should be for the next expiration and the BTO legs for the next expiration after that. This way the STO will decrease their time value faster than the BTO legs if the price stays flat (which plays to your advantage) and the BTO legs may make profit if the next day it opens away from the price at which the ticker closed the previous day (when the position was opened). The most profit is when it moves right up to one of the STO legs. This position would normally be closed next day at opening. The percentage of profit it makes is low compared to other strategies but also the percentage of the total cost at risk is also low which could potentially allow a trader to increase the lot and thus, in the end, the total profit amount may be comparable to other strategies.


Notes:
  • The indicator in the chart above comes with the standard options. For a more standard momentum indicator set both the current and previous reference point to the same OHLC value (such as "close").
  • The 0.68 and -0.75 levels are for open/close (current/previous point of reference) for ticker INTC. Obviously, other tickers will likely have other levels and you will have to find those yourself. If you use INTC but use other combination of current and previous reference points, they will have different levels as well.

Oscillators

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer