Percent change column for Watchlist

D

docsep

New member
VIP
Hello.

Could someone help me create a percent change column for TOS watchlist with customize-able time frames?

I'm new to writing script and am unable to figure out how to do this.

Thanks,

Shane
 
L

Len20

Member
Hi
Do you mean you just want the % change of the current price compared to a customizable number of bars ago?
 
L

Len20

Member
Try this:
Code:
input barsAgo = 10;

def price = close;
def oldPrice = close[barsAgo];

plot change = round(100 * ((price / oldPrice) - 1), 1);
change.assignValueColor( if change < 0 then color.RED else color.GREEN);

It's important to set the aggregation period up top when you create the watchlist. So in the example above, if you set it to Daily, it would compare the current price to 10 days ago. If you set it to "1 Minute" it would compare the current price to 10 minutes ago
 
G

gooseyCA

New member
Hi @Len20, I would like to display the number of trades for a stock in a column watchlist, do you know if tick_count could work (if so what would be the script)?

Thanks!
 
L

Len20

Member
Sorry gooseyCA, I don't think that's even possible. Not to my knowledge anyways, but I could be wrong
 
V

Vimal Mittal

Member
If I have to see this in one minute daily chart for intraday trading and need to see price change back in 3 minutes candles how the script would be different?

I need to compare price 3 minutes ago in three minute daily chart. will it work?
 
L

Len20

Member
@Vimal Mittal Not sure exactly which you are looking for, but either set it to 1 minute aggregation and use input barsAgo = 3;
or set it to 3 minute aggregation and use input barsAgo = 1;
 
V

Vimal Mittal

Member
I got it. Thanks. If I have to use on 5 minutes chart then what value do I set “input bar ago”?

If I understand correctly, any time frame for intraday 1 min, 3 min or 15 min, “Input bars ago” will remain always 1 bar ago?
I am novice so apologize for this.
Thanks.
 
L

Len20

Member
Well if you just want the close of the last bar for the timeframe aggregation you choose for your watchlist column, then yes it will remain 1 bar ago. Keep in mind that means for a 15 minute bar, it will not be comparing the current price to 15 minutes ago. When the new bar starts, the current price will be compared to 1min ago, then 2 min ago, then 3...... until it hits 15 min ago, then the new bar starts.

The other way, if you want the price 15 minutes ago, but want it to update every minute, you want the aggregation to be 1 minute and make it 15 bars ago.
 

Similar threads

Top