Prime Number Checker
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Eliza123123

//@version=4
study("Prime Number Checker v3", overlay = true)

//v2
//more workable version of yesterdays script. please still only use on assets $10 to $100 as scalability hasn't been added for all assets yet. BG colors are theres to show historic prevalence of "primeness".
//The table in the top right will flash purple when the open high low or close encounters "primeness". 
//When they all light up thats when you can potentially expect a reversal. Use on lower time frame to see the effect quickly. Note this still isn't a foolproof method for finding primes but I will be improving it in later editions

//v3
//added scaling for pairs from $0.10 up to $1000. May still be slight different in indicator performance betwwen the two extremes of that scale.
// Clear OHLC prime pivot points have been added.
//Introducing the volumeometer. Pretty self explanatory.
// Red candle count and green candle count for last 100 candles.



f_close = close, f_low = low, f_high = high, f_open = open
flagc = 0, flagl = 0, flagh = 0, flago = 0




//Assets $0.10-1
if close >= 0.100 and close < 0.9999
    f_close := f_close * 100000
if low >= 0.100 and low < 0.9999
    f_low := f_low * 100000
if high >= 0.100 and high < 0.9999
    f_high := f_high * 100000
if open >= 0.100 and open < 0.9999
    f_open := f_open * 100000

//Assets $1-10
if close >= 1.000 and close < 9.999
    f_close := f_close * 10000
if low >= 1.000 and low < 9.999
    f_low := f_low * 10000
if high >= 1.000 and high < 9.999
    f_high := f_high * 10000
if open >= 1.000 and open < 9.999
    f_open := f_open * 10000

//Assets $10-100
if close >= 10.000 and close < 99.999
    f_close := f_close * 1000
if low >= 10.000 and low < 99.999
    f_low := f_low * 1000
if high >= 10.000 and high < 99.999
    f_high := f_high * 1000
if open >= 10.000 and open < 99.999
    f_open := f_open * 1000

//Assets $100-1000
if close >= 100.000 and close < 999.999
    f_close := f_close * 100
if low >= 100.000 and low < 999.999
    f_low := f_low * 100
if high >= 100.000 and high < 999.999
    f_high := f_high * 100
if open >= 100.000 and open < 999.999
    f_open := f_open * 100


if f_close > 1
    for  i = 2 to 3
        if (f_close % i) == 0
            flagc := 1
        for  i = 4 to 5
            if (f_close % i) == 0
                flagc := 1
            for  i = 6 to 7
                if (f_close % i) == 0
                    flagc := 1
                for  i = 8 to 9
                    if (f_close % i) == 0
                        flagc := 1

if f_low > 1
    for  i = 2 to 3
        if (f_low % i) == 0
            flagl := 1
        for  i = 4 to 5
            if (f_low % i) == 0
                flagl := 1
            for  i = 6 to 7
                if (f_low % i) == 0
                    flagl := 1
                for  i = 8 to 9
                    if (f_low % i) == 0
                        flagl := 1

if f_high > 1
    for  i = 2 to 3
        if (f_high % i) == 0
            flagh := 1
        for  i = 4 to 5
            if (f_high % i) == 0
                flagh := 1
            for  i = 6 to 7
                if (f_high % i) == 0
                    flagh := 1
                for  i = 8 to 9
                    if (f_high % i) == 0
                        flagh := 1

if f_open > 1
    for  i = 2 to 3
        if (f_open % i) == 0
            flago := 1
        for  i = 4 to 5
            if (f_open % i) == 0
                flago := 1
            for  i = 6 to 7
                if (f_open % i) == 0
                    flago := 1
                for  i = 8 to 9
                    if (f_open % i) == 0
                        flago := 1


bgcolor(color = flagc == 0 ? color.yellow : na, transp = 99)
bgcolor(color = flagl == 0 ? color.yellow : na, transp = 99)
bgcolor(color = flagh == 0 ? color.yellow : na, transp = 99)
bgcolor(color = flago == 0 ? color.yellow : na, transp = 99)

bgcolor(color = flago == 0 and flagh == 0 ? color.purple : na, transp = 98)
bgcolor(color = flago == 0 and flagl == 0 ? color.purple : na, transp = 98)
bgcolor(color = flago == 0 and flagc == 0 ? color.purple : na, transp = 98)
bgcolor(color = flagl == 0 and flagc == 0 ? color.purple : na, transp = 98)
bgcolor(color = flagl == 0 and flagh == 0 ? color.purple : na, transp = 98)
bgcolor(color = flagc == 0 and flagh == 0 ? color.purple : na, transp = 98)

bgcolor(color = flagc == 0 and flagh == 0 and flago == 0 ? color.fuchsia : na, transp = 97)
bgcolor(color = flagc == 0 and flagh == 0 and flagl == 0 ? color.fuchsia : na, transp = 97)
bgcolor(color = flago == 0 and flagc == 0 and flagl == 0 ? color.fuchsia : na, transp = 97)
bgcolor(color = flago == 0 and flagh == 0 and flagl == 0 ? color.fuchsia : na, transp = 97)


volumesBeaten = 0
for i = 1 to 1440
    if volume > volume[i]
        volumesBeaten := volumesBeaten + 1
volume_percent_class = (volumesBeaten / 1440) * 100

howManyreds = 0
for i = 1 to 100
    if open[i] > close[i]
        howManyreds := howManyreds + 1
        
howManygreens = 0
for i = 1 to 100
    if open[i] < close[i]
        howManygreens := howManygreens + 1

var testTable = table.new(position = position.top_right, columns = 2, rows = 4, bgcolor = color.white, border_width = 1)
if barstate.islast
    table.cell(table_id = testTable, column = 0, row = 0, text = "Open is " + tostring(open), bgcolor = flago == 0 ? color.fuchsia : na)
    table.cell(table_id = testTable, column = 1, row = 0, text = "Close is " + tostring(close), bgcolor = flagc == 0 ? color.fuchsia : na)
    table.cell(table_id = testTable, column = 0, row = 1, text = "High is " + tostring(high), bgcolor = flagh == 0 ? color.fuchsia : na)
    table.cell(table_id = testTable, column = 1, row = 1, text = "Low is " + tostring(low), bgcolor = flagl == 0 ? color.fuchsia : na)
    table.cell(table_id = testTable, column = 0, row = 2, text = " Volume higher than " + tostring(volume_percent_class) + "% of recent data", bgcolor = color.black, text_color = color.white)
    table.cell(table_id = testTable, column = 1, row = 2, text = "Reds " + tostring(howManyreds), bgcolor = color.red, text_color = color.white)
    table.cell(table_id = testTable, column = 0, row = 3, text = "Hope this helps!   Eliza x", bgcolor = #fc03a5, text_color = #d5ff03)
    table.cell(table_id = testTable, column = 1, row = 3, text = "Greens " + tostring(howManygreens), bgcolor = color.green, text_color = color.white)


plotshape(flagc == 0 and flagh == 0 and flago == 0 and flagl == 0, location = location.belowbar, color = color.purple, text = "Piv", textcolor = color.white)









