Is there any way to create/get/plot the prime function/formula?

Solution
Okay if we get into specifics, I would like to plot only the prime numbers of the number of times my float rotation indicator rotates.
When I give an input to the float, sometimes the input is small enough to plot many float rotations throughout the intraday.
For example if I used the float input as 10million, today BRQS rotated 19 times.
This data produces too many points for me to look at and I wish to only plot the prime number of times the float rotates.


Code:
input Float = 10000000;
input showfnodes = yes;
input showlabel = no;
def today= getday()>=getlastday();
def Todayv = volume(period="DAY");
def V = if Todayv then volume(period = getaggregationPeriod()) else double.NaN;
def DVol = if today then DVol[1] + V else 0;
def nodes...

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

plot them in what way?
Price level sort of like fibonnaci... but it doesn't matter. I basically need the function, if someone knows how to turn it into script, then I can plot it myself.
I think it cant be done manually and TOS need to add it as a math function.
 
Price level sort of like fibonnaci... but it doesn't matter. I basically need the function, if someone knows how to turn it into script, then I can plot it myself.
I think it cant be done manually and TOS need to add it as a math function.

How many primes are we talking about? There are only 168 between 1 and 1000, so it may be easier just to individually define and plot them. Perhaps with a little more definition as to how you want to use them, I might be able to put something together for you.
 
Okay if we get into specifics, I would like to plot only the prime numbers of the number of times my float rotation indicator rotates.
When I give an input to the float, sometimes the input is small enough to plot many float rotations throughout the intraday.
For example if I used the float input as 10million, today BRQS rotated 19 times.
This data produces too many points for me to look at and I wish to only plot the prime number of times the float rotates.


Code:
input Float = 10000000;
input showfnodes = yes;
input showlabel = no;
def today= getday()>=getlastday();
def Todayv = volume(period="DAY");
def V = if Todayv then volume(period = getaggregationPeriod()) else double.NaN;
def DVol = if today then DVol[1] + V else 0;
def nodes = (DVol) % Float;

AddLabel (if showlabel and getAggregationPeriod()<=AggregationPeriod.hour then 1 else 0, "FloatRT: " + Round(Todayv/Float, 1), if Todayv < Float then Color.white else Color.orange);

AddVerticalLine(if getAggregationPeriod()<=AggregationPeriod.ten_MIN and showfnodes then nodes < nodes[1] else 0, Concat(Round(DVol / Float, 0),"") , Color.white, Curve.SHORT_DASH);
Before:
dBgt1Qg.png


AFTER:
yudQbEo.png


I need to edit the condition for AddVerticalLine where nodes < nodes[1] else 0, Concat(Round(DVol / Float, 0) is only plotting the prime numbers of rotation. Don't know how this can be done.

How many primes are we talking about? There are only 168 between 1 and 1000, so it may be easier just to individually define and plot them. Perhaps with a little more definition as to how you want to use them, I might be able to put something together for you.
Actually come to think of it, how would you only addvertical lines of select numbers of the rotation ?
 
Last edited by a moderator:
Okay if we get into specifics, I would like to plot only the prime numbers of the number of times my float rotation indicator rotates.
When I give an input to the float, sometimes the input is small enough to plot many float rotations throughout the intraday.
For example if I used the float input as 10million, today BRQS rotated 19 times.
This data produces too many points for me to look at and I wish to only plot the prime number of times the float rotates.


Code:
input Float = 10000000;
input showfnodes = yes;
input showlabel = no;
def today= getday()>=getlastday();
def Todayv = volume(period="DAY");
def V = if Todayv then volume(period = getaggregationPeriod()) else double.NaN;
def DVol = if today then DVol[1] + V else 0;
def nodes = (DVol) % Float;

AddLabel (if showlabel and getAggregationPeriod()<=AggregationPeriod.hour then 1 else 0, "FloatRT: " + Round(Todayv/Float, 1), if Todayv < Float then Color.white else Color.orange);

AddVerticalLine(if getAggregationPeriod()<=AggregationPeriod.ten_MIN and showfnodes then nodes < nodes[1] else 0, Concat(Round(DVol / Float, 0),"") , Color.white, Curve.SHORT_DASH);
Before:
dBgt1Qg.png


AFTER:
yudQbEo.png


I need to edit the condition for AddVerticalLine where nodes < nodes[1] else 0, Concat(Round(DVol / Float, 0) is only plotting the prime numbers of rotation. Don't know how this can be done.


Actually come to think of it, how would you only addvertical lines of select numbers of the rotation ?


if you want prime numbers, then search for prime number formulas.
then you might find sites like this.
https://zaron3.medium.com/simple-formula-for-prime-numbers-fe72c268c81d


to compare a variable against several constants, you can use if then.
add this to your study in post 5.

Code:
def z = (DVol) % Float;
def isprime;
if z == 3 or z == 5 or z == 7 or z == 11 then {
 isprime = 1;
else if z == 13 or z == 17 or z == 19 or z == 23 then {
 isprime = 1;
} else {
isprime = 0;
}
addverticalline( isprime, z, color.cyan);


if you have just a few stocks to look at, this might help. add this to the beginning of your study. put the data in once, then pick the stocks in a watchlist. change the code to be what you want for defaults.

Code:
input sym1 = "SPY";
input s1_float = 0;

input sym2 = "C";
input s2_float = 0;

input sym3 = "F";
input s3_float = 0;

input sym4 = "T";
input s4_float = 0;

input sym5 = "V";
input s5_float = 0;

def float1;
if GetSymbol() == sym1 then {
  float1 = s1_float;
} else if GetSymbol() == sym2 then {
  float1 = s2_float;
} else if GetSymbol() == sym3 then {
  float1 = s3_float;
} else if GetSymbol() == sym4 then {
  float1 = s4_float;
} else if GetSymbol() == sym5 then {
  float1 = s5_float;
} else {
  float1 = 0;
}

# read the close price from a variable name
# def c1 = close(sym1)

https://www.tradingsim.com/day-trading/float-rotation
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
507 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