Convert TOS indicator to Tradingview


Category:
0
0

Hi Pete,

Is there a way to convert the TOS indicator – Accumulation/Distribution Buying Pressure into Tradingview?

Here is the code;

declare lower;

def data = if close > close[1] then close – Min(close[1], low) else if close < close[1] then close – Max(close[1], high) else 0;

plot AccDist = TotalSum(data);

AccDist.SetDefaultColor(GetColor(1));

Thanks.

Marked as spam
Posted by (Questions: 5, Answers: 8)
Asked on April 26, 2019 1:36 am
3723 views
0
Private answer

It's already available. I didn't even have to search for it. When I opened the window to add a new indicator to a chart it was the first indicator in the list of built-in studies. See screenshot below.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 26, 2019 12:52 pm
0
Hi Pete, Yes, I saw that but the code for Tradingview is different than that of TOS noted above.  Different indicators. Here is the code you referenced for Tradingview;study(title="Accumulation/Distribution", shorttitle="Accum/Dist", overlay=false)ad = cum(close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume)plot(ad, title = "Accumulation/Distribution", color=olive) Looking to convert the TOS code for Accumulation/Distribution Buying Pressure to Tradingview code.  Thanks.
( at April 26, 2019 5:36 pm)
0
Private answer

Ok, this should do the trick.

It took me a while to find this because you did not use the exact study name as it appears in Thinkorswim. To avoid confusion in the future, please be sure to use the exact name of the study as it appears on Thinkorswim. In this case the study name is: AccumDistBuyPr

IMPORTANT NOTE:

The actual values at the last bar on the chart will vary because this indicator computes the total sum of values for the entire chart. However both indicators will plot the same trend-patterns given equivalent data. On Thinkorswim we can control how many bars are on the chart. For example for a daily chart we can include 1 yr, 2 yr, 3 yr... etc. For each of these time spans the AccumDistBuyPr study will compute different values (but the same trend-patterns). On Trading view this time span is not adjustable.

HEADS UP:

This should give everyone a heads up. The absolute values of this study (whether used on Thinkorswim or TradingView) are useless. This indicator can only be used to determine trend direction.

TradingView Code:

//@version=3
study(title="Accumulation/Distribution Buying Pressure", shorttitle="AccumDistBuyPr", overlay=false)
data = close > close[1] ? close - min(close[1], low) : close < close[1] ? close - max(close[1], high) : 0
plot(cum(data), title="AccumDistBuyPr", color=red)

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 27, 2019 7:59 am
0
Pete, Thank you for your input. Just wondering as I did find this script in another forum, would it help with the number of candles on tradingview? //@version=3 study(title="Amount of bars") plot(n)
( at April 28, 2019 9:48 am)
0
You will need to provide the rest of the code (or a link to the full source code). That single line of code does nothing.
( at April 28, 2019 5:48 pm)
0
Oh sure sorry. Here is the link to the code noted above that I found; https://getsatisfaction.com/tradingview/topics/how-many-bars-does-tradingview-provide-for-5-minute-data-in-backtesting-not-the-chart
( at April 29, 2019 3:29 pm)
0
That post is talking about how to extend the number of bars to some maximum allowable quantity. It does not discuss how to restrict the number candles to a specified quantity. For example it does not explain how to reduce the number of daily bars to 252, which would be 1 year of trading data. Such as we can do on Thinkorswim. In short, this does not provide any solution to the issue I explained in my answer.
( at April 29, 2019 5:12 pm)
0
Pete, thank you for your detailed explanation. I really appreciate your assistance. Thanks.
( at April 30, 2019 12:33 am)