Pi Price Levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fvideira

//@version=5
indicator("Pi Price Levels", overlay=true)

// Study of Pi levels from Eliza123123's quantative trading series: https://youtu.be/S7UMA__wz74

// Pi Const.

piStd = input.bool(true, "Standard Multiples", group = "Pi Constant 3.14159")

piPrime = input(true, "Prime Multiples", group = "Pi Constant 3.14159")

piMulti = input(true, "Multiples of 10", group = "Pi Constant 3.14159")



// Scale Factors & Constants

scale = 0.0

if close >= 10000
    scale := 1000

if close >= 1000 and close <=9999.999999
    scale := 100

if close >= 100 and close <=999.999999
    scale := 10

if close >= 10 and close <=99.999999
    scale := 1
    
if close >= 1 and close <=9.999999
    scale := 0.1
    
if close >= 0.1 and close <=0.999999
    scale := 0.01

if close >= 0.01 and close <=0.099999
    scale := 0.001
    
if close >= 0.001 and close <=0.009999
    scale := 0.0001
    
    
    
// Variables

pi = 3.14159 * scale

pi1 = 0.0
pi2 = 0.0
pi3 = 0.0
pi4 = 0.0
pi5 = 0.0
pi6 = 0.0
pi7 = 0.0
pi8 = 0.0
pi9 = 0.0
pi10 = 0.0
pi11 = 0.0
pi12 = 0.0
pi13 = 0.0
pi14 = 0.0
pi15 = 0.0
pi16 = 0.0
pi17 = 0.0
pi18 = 0.0
pi19 = 0.0
pi20 = 0.0
pi21 = 0.0
pi22 = 0.0
pi23 = 0.0
pi24 = 0.0
pi25 = 0.0
pi26 = 0.0
pi27 = 0.0
pi28 = 0.0
pi29 = 0.0
pi30 = 0.0
pi31 = 0.0
pi32 = 0.0
pi33 = 0.0
pi34 = 0.0
pi35 = 0.0
pi36 = 0.0
pi37 = 0.0
pi38 = 0.0



// If clauses (for inputs to work as on/off)

if piStd
    pi4 := pi*4
    pi6 := pi*6
    pi8 := pi*8
    pi9 := pi*9
    pi12 := pi*12
    pi14 := pi*14
    pi15 := pi*15
    pi16 := pi*16
    pi18 := pi*18
    pi21 := pi*21
    pi22 := pi*22
    pi24 := pi*24
    pi25 := pi*25
    pi26 := pi*26
    pi27 := pi*27
    pi28 := pi*28
    pi32 := pi*32
    pi33 := pi*33
    pi34 := pi*34
    pi35 := pi*35
    pi36 := pi*36
    pi38 := pi*38
else
    pi4 := na
    pi6 := na
    pi8 := na
    pi9 := na
    pi12 := na
    pi14 := na
    pi15 := na
    pi16 := na
    pi18 := na
    pi21 := na
    pi22 := na
    pi24 := na
    pi25 := na
    pi26 := na
    pi27 := na
    pi28 := na
    pi32 := na
    pi33 := na
    pi34 := na
    pi35 := na
    pi36 := na
    pi38 := na

if piPrime
    pi1 := pi*1
    pi2 := pi*2
    pi3 := pi*3
    pi5 := pi*5
    pi7 := pi*7
    pi11 := pi*11
    pi13 := pi*13
    pi17 := pi*17
    pi19 := pi*19
    pi23 := pi*23
    pi29 := pi*29
    pi31 := pi*31
    pi37 := pi*37
else
    pi1 := na
    pi2 := na
    pi3 := na
    pi5 := na
    pi7 := na
    pi11 := na
    pi13 := na
    pi17 := na
    pi19 := na
    pi23 := na
    pi29 := na
    pi31 := na
    pi37 := na
    
if piMulti
    pi10 := pi*10
    pi20 := pi*20
    pi30 := pi*30
else
    pi10 := na
    pi20 := na
    pi30 := na
    
    
// Plots

plot(pi, color = color.new(color.silver, 10)), plot(pi2, color = color.new(color.silver, 0)),
plot(pi3, color = color.new(color.silver, 0)), plot(pi4, color = color.new(color.black, 0)),
plot(pi5, color = color.new(color.silver, 0)), plot(pi6, color = color.new(color.black, 0)),
plot(pi7, color = color.new(color.silver, 0)), plot(pi8, color = color.new(color.black, 0)),
plot(pi9, color = color.new(color.black, 0)), plot(pi10, color = color.new(color.orange, 10)),
plot(pi11, color = color.new(color.silver, 0)), plot(pi12, color = color.new(color.black, 0)),
plot(pi13, color = color.new(color.silver, 0)), plot(pi14, color = color.new(color.black, 0)),
plot(pi15, color = color.new(color.black, 0)), plot(pi16, color = color.new(color.black, 0)),
plot(pi17, color = color.new(color.silver, 0)), plot(pi18, color = color.new(color.black, 0)),
plot(pi19, color = color.new(color.silver, 0)), plot(pi20, color = color.new(color.orange, 10)),
plot(pi21, color = color.new(color.black, 0)), plot(pi22, color = color.new(color.black, 0)),
plot(pi23, color = color.new(color.silver, 0)), plot(pi24, color = color.new(color.black, 0)),
plot(pi25, color = color.new(color.black, 0)), plot(pi26, color = color.new(color.black, 0)),
plot(pi27, color = color.new(color.black, 0)), plot(pi28, color = color.new(color.black, 0)),
plot(pi29, color = color.new(color.silver, 0)), plot(pi30, color = color.new(color.orange, 10)),
plot(pi31, color = color.new(color.silver, 0)), plot(pi32, color = color.new(color.black, 0)),
plot(pi33, color = color.new(color.black, 0)), plot(pi34, color = color.new(color.black, 0)),
plot(pi35, color = color.new(color.black, 0)), plot(pi36, color = color.new(color.black, 0)),
plot(pi37, color = color.new(color.silver, 0)), plot(pi38, color = color.new(color.black, 0))

///