somewhat "fluid" TimeStamp?

MBF

Active member
2019 Donor
Hi everyone! Need a bit of help with this script
https://usethinkscript.com/threads/finding-the-slope-of-macd-line.5118/#post-52331

I am trying to modify it, if anyone might have some free time.
1. Is there a way for there to be a somewhat "fluid" TimeStamp? What I mean is in this line:
AddChartBubble(secondsFromTime(0001) > 0, sline, if slowlineslope == 1 then "slowline - Slope Up"else "slowline - Slope Down", if Slowlineslope ==1 then Color.Green else Color.red);
a. its this line here, (secondsFromTime(0001) > 0, that I am having trouble with. If possible I would want it to be constant or closest to it. Maybe a 1 minute bar by bar? I hope I am explaining this correctly.
I will place the script in its entirety below here:
declare lower;
input price = close;
input Fastline_price = close;
input FastLine_Average_Type = AverageType.SIMPLE;
input Slowline_price = close;
input Slowline_average_type = AverageType.SIMPLE;

def Fastline = Average(price, 3) - Average(price, 10);
def Slowline = Average(Fastline, 16);
plot Fline = Average(price, 3) - Average(price, 10);
plot Sline = Average(Fastline, 16);

def fastlineSlope = if Fline > Fline[1] then 1 else 0 ;
def SlowlineSlope = if Sline > Sline[1] then 1 else 0 ;

plot UPS = if Sline > Sline[1] then 1 else 0;
plot DownS = if Sline < Sline [1] then 0 else 1;

AddChartBubble(SecondsFromTime(0001) >= 0, Sline, if SlowlineSlope == 1 then "Slowline - Slope UP" else "Slowline - Slope DOWN", if SlowlineSlope == 1 then Color.GREEN else Color.RED);

Thank you for taking a peek!
 
Last edited by a moderator:
Solution
input over_bought = 80;
input over_sold = 20;
Okay, I figured some things out on the script.
Now I am making a Watchlist column and the KPeriod stays green all the time. Any ideas on what I am doing wrong?


Watchlist Column- KPeriod Slope;

input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;

def stoch = StochasticFull(over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, slowing_period = slowing_period, averageType = averageType).FullK;
def StoK = reference StochasticFull.FullK;
def StoD = reference StochasticFull.FullD;

def KSlope = if StoK > StoK[1] then 1 else 0;
def DSlope = if StoD > StoD[1] then 1 else 0;

plot UpK = if StoK > StoK[1] then 1 else 0;
#plot...
Hi everyone! Need a bit of help with this script
https://usethinkscript.com/threads/finding-the-slope-of-macd-line.5118/#post-52331

I am trying to modify it, if anyone might have some free time.
1. Is there a way for there to be a somewhat "fluid" TimeStamp? What I mean is in this line:
AddChartBubble(secondsFromTime(0001) > 0, sline, if slowlineslope == 1 then "slowline - Slope Up"else "slowline - Slope Down", if Slowlineslope ==1 then Color.Green else Color.red);
a. its this line here, (secondsFromTime(0001) > 0, that I am having trouble with. If possible I would want it to be constant or closest to it. Maybe a 1 minute bar by bar? I hope I am explaining this correctly.
I will place the script in its entirety below here:
declare lower;
input price = close;
input Fastline_price = close;
input FastLine_Average_Type = AverageType.SIMPLE;
input Slowline_price = close;
input Slowline_average_type = AverageType.SIMPLE;

def Fastline = Average(price, 3) - Average(price, 10);
def Slowline = Average(Fastline, 16);
plot Fline = Average(price, 3) - Average(price, 10);
plot Sline = Average(Fastline, 16);

def fastlineSlope = if Fline > Fline[1] then 1 else 0 ;
def SlowlineSlope = if Sline > Sline[1] then 1 else 0 ;

plot UPS = if Sline > Sline[1] then 1 else 0;
plot DownS = if Sline < Sline [1] then 0 else 1;

AddChartBubble(SecondsFromTime(0001) >= 0, Sline, if SlowlineSlope == 1 then "Slowline - Slope UP" else "Slowline - Slope DOWN", if SlowlineSlope == 1 then Color.GREEN else Color.RED);

Thank you for taking a peek!

sorry, i have no idea what you are asking for. fluid, constant,... don't mean anything..

it seems to draw 3 lines, and a bubble on every bar, following one of the lines.

instead of trying to describe programing changes, just tell us what you want to see. tell us,
.. what does the study do.
.. what don't you like.
.. what do you want changed.


here is a test code that you can add to the end of the study ( or use by itself). you will see that the condition is always true,
so when you use that in a bubble, a bubble is drawn on every bar.

Code:
addchartbubble(1,20,
(SecondsFromTime(0001) >= 0)
, color.yellow, no);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

sorry, i have no idea what you are asking for. fluid, constant,... don't mean anything..

it seems to draw 3 lines, and a bubble on every bar, following one of the lines.

instead of trying to describe programing changes, just tell us what you want to see. tell us,
.. what does the study do.
.. what don't you like.
.. what do you want changed.


here is a test code that you can add to the end of the study ( or use by itself). you will see that the condition is always true,
so when you use that in a bubble, a bubble is drawn on every bar.

Code:
addchartbubble(1,20,
(SecondsFromTime(0001) >= 0)
, color.yellow, no);
Thank you. I want the slope to stay green or red for each bar on a one minute for a higher TF. It is 2 indicators overlaid on top of each other. StochRSI and LBR_3/10 with JUST the slow line of that indicator. I want to know if the StochRSI K AND D are sloped up and if the LBR_3/10 Slow is sloped up.
I will turn that into a watchlist column.
I have a test code for it but the script is off for some reason.
 
input over_bought = 80;
input over_sold = 20;
Okay, I figured some things out on the script.
Now I am making a Watchlist column and the KPeriod stays green all the time. Any ideas on what I am doing wrong?


Watchlist Column- KPeriod Slope;

input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;

def stoch = StochasticFull(over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, slowing_period = slowing_period, averageType = averageType).FullK;
def StoK = reference StochasticFull.FullK;
def StoD = reference StochasticFull.FullD;

def KSlope = if StoK > StoK[1] then 1 else 0;
def DSlope = if StoD > StoD[1] then 1 else 0;

plot UpK = if StoK > StoK[1] then 1 else 0;
#plot DU = if Dslope > DSlope[1] then 1 else 0;

AssignBackgroundColor (if 1 then Color.Green else Color.Red);
 
input over_bought = 80;
input over_sold = 20;
Okay, I figured some things out on the script.
Now I am making a Watchlist column and the KPeriod stays green all the time. Any ideas on what I am doing wrong?


Watchlist Column- KPeriod Slope;

input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;

def stoch = StochasticFull(over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, slowing_period = slowing_period, averageType = averageType).FullK;
def StoK = reference StochasticFull.FullK;
def StoD = reference StochasticFull.FullD;

def KSlope = if StoK > StoK[1] then 1 else 0;
def DSlope = if StoD > StoD[1] then 1 else 0;

plot UpK = if StoK > StoK[1] then 1 else 0;
#plot DU = if Dslope > DSlope[1] then 1 else 0;

AssignBackgroundColor (if 1 then Color.Green else Color.Red);

Change to this:

Ruby:
AssignBackgroundColor (if UpK == 1 then Color.GREEN else Color.RED);
 
  • Thumbs Up
Reactions: MBF
Solution
Thread starter Similar threads Forum Replies Date
L Timestamp "study" Questions 4
T How to add timestamp in scan results for when scan condition was met? Questions 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
255 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top