PineScript Code Modification
Budget: $30 – $250 USD
Changes to be made to existing code and expected end results requirements for successfully completing milestone
This indicator is for US Stocks. Right now as the indicator is currently coded it uses the previous day’s daily bar High+Low+Close divided by 3 to get the main pivot and other levels.
study(title="VPP", shorttitle="VPP", overlay = true)
width = input(2, minval=1)
xHigh = security(tickerid,"D", high[1])
xLow = security(tickerid,"D", low[1])
xClose = security(tickerid,"D", close[1])
vPP = (xHigh+xLow+xClose) / 3
vR1 = (vPP * 2) - xLow
vS1 = (vPP * 2) - xHigh
vR2 = vPP + (vR1 - vS1)
vS2 = vPP - (vR1 - vS1)
plot(vPP, color=#4000ff, title="VPP", style = circles, linewidth = width)
plot(vS1, color=#ff0000, title="S1", style = circles, linewidth = width)
plot(vS2, color=#ff002a, title="S2", style = circles, linewidth = width)
plot(vR1, color=#009600, title="R1", style = circles, linewidth = width)
plot(vR2, color=#006F00, title="R2", style = circles, linewidth = width)
Even though the current code does not define a time period for what a “daily bar” is – the daily bar for US stocks is naturally defined in tradingview on US stocks as start 930am EST and end at 4pm EST (which is the New York RTH trading session for US Stocks. The way it is coded now it does not matter if I have my chart set to 1 min, 5 min, 4 hour or any other time frame of 1 day or less for it to work properly and to initially generate the proper correct levels. Additionally the way it is coded now it properly displays the same pivot level and same all other levels correctly on any time frame of 1 day or less even if the user changes their chart time frame (after the levels generated) to any other chart time frame that is 1 Day or less such as: 1 DAY, 4 hours, 3 hours, 2 hours, 1 Hour, 45 min, 30 min, 15 min, 15 min, 5 min, 3 min, 2 min, 1min
It also doesn’t matter if the US stock symbol’s chart in Tradingview is set to RTH trading hours or ETH trading hours the data it uses (the high low close it takes from the previous day’s daily bar remains the same--- as a “daily bar” for US stocks is naturally defined in tradingview on US stocks as start 930am EST and end at 4pm EST (which is the New York RTH trading session for US Stocks.
So what I want to do is add 1 additional session and then in the user control panel the user can choose from 1 of 2 sessions
Session 1 – is the session it is coded for now in the existing code – if the user selects this session then everything works as it does now
Session 2 will be a new custom time period session that defined by the user which will be for a time period that starts and ends in the “Current Trading Day” as opposed to session 1 which is takes the High, Low and Close from the previous trading day’s daily bar.
Example 1- So for example if the user selects session 2 and inputs for session 2 to use start time of 6AM EST and an end time of 10AM EST
The indicator would then takes the High+Low+Close that occurs between 6AM and 10AM to generate the pivot
The highest high that occurs between 6:00AM EST and 10:00AM EST
The lowest low that occurs between 6:00AM EST and 10:00AM EST
And
The closing price that occurs at 10:00AM EST
Then right after the closing price occurs 10:00 AM EST same day it generates the pivot level and the other levels
Example 2- If the user instead selected Session 2 and inputs for session 2 to use start time of 8:15 AM EST and an end time of 10:30AM EST
The indicator would then takes the High+Low+Close that occurs between 815 AM EST and 10:30AM EST to generate the pivot
The highest high that occurs between 8:15AM EST and 10:30AM EST
The lowest low that occurs between 8:15AM EST and 10:30AM EST
And
The closing price that occurs at 10:30AM EST
Then right after the closing price occurs 10:30 AM EST same day it generates the pivot level and the other levels
So for example going back to this example for session 2 above
Example 2- If the user instead selected Session 2 and inputs for session 2 to use start time of 8:15 EST and an end time of 10:30AM EST
And the High occurring between start time of 8:15 AM EST and an end time of 10:30AM EST was 910.98
And the Low occurring between start time of 8:15 AM EST and an end time of 10:30AM EST was 876.16
And the Closing price at 10:30AM EST was 879.44
---------------------
Total High (910.98)+Low(876.16)+Close(879.44)= 2666.58 divided by 3= 888.86 main pivot
The main end result is that if the user instead selects session 2 and inputs a specific start time and end time that it should not matter (the same way it doesn’t matter in session 1) if I have my chart set to 1 min, 5 min, 4 hour or any other time frame of 1 day or less for it to work properly and initially generate the proper correct levels for the specific start and end time inputted for Session 2. Additionally it should continue to properly display the same correct pivot level it initially generated (in this example 888.76) and the same correct all other levels initially also generated on any time frame of 1 day or less even if the user changes their chart time frame (after the levels were generated to any other chart time frame that is 1 Day or less such as: 1 DAY, 4 hours, 3 hours, 2 hours, 1 Hour, 45 min, 30 min, 15 min, 15 min, 5 min, 3 min, 2 min, 1min
Whether that proper end result for session 2 with the custome start time and end time inputs in user control panel has to be accomplished by using the security() function in Pine Script to fetch data from a lower timeframe within your script to ensure that you're always working with the 1-minute timeframe data for your session calculations, regardless of the chart timeframe being viewed by the user, Or if that is not workable then whatever other method in pinescript that will ensure the end result for session 2 with user defined start and end will generate the levels properly and correctly on any user chart time frame 1 day or lower and will continue to display the same correct levels even if user changes the chart time frame after the levels were generated as long as that chart time frame is is changed to anything that is 1 day or less
This indicator is for US Stocks. Right now as the indicator is currently coded it uses the previous day’s daily bar High+Low+Close divided by 3 to get the main pivot and other levels.
study(title="VPP", shorttitle="VPP", overlay = true)
width = input(2, minval=1)
xHigh = security(tickerid,"D", high[1])
xLow = security(tickerid,"D", low[1])
xClose = security(tickerid,"D", close[1])
vPP = (xHigh+xLow+xClose) / 3
vR1 = (vPP * 2) - xLow
vS1 = (vPP * 2) - xHigh
vR2 = vPP + (vR1 - vS1)
vS2 = vPP - (vR1 - vS1)
plot(vPP, color=#4000ff, title="VPP", style = circles, linewidth = width)
plot(vS1, color=#ff0000, title="S1", style = circles, linewidth = width)
plot(vS2, color=#ff002a, title="S2", style = circles, linewidth = width)
plot(vR1, color=#009600, title="R1", style = circles, linewidth = width)
plot(vR2, color=#006F00, title="R2", style = circles, linewidth = width)
Even though the current code does not define a time period for what a “daily bar” is – the daily bar for US stocks is naturally defined in tradingview on US stocks as start 930am EST and end at 4pm EST (which is the New York RTH trading session for US Stocks. The way it is coded now it does not matter if I have my chart set to 1 min, 5 min, 4 hour or any other time frame of 1 day or less for it to work properly and to initially generate the proper correct levels. Additionally the way it is coded now it properly displays the same pivot level and same all other levels correctly on any time frame of 1 day or less even if the user changes their chart time frame (after the levels generated) to any other chart time frame that is 1 Day or less such as: 1 DAY, 4 hours, 3 hours, 2 hours, 1 Hour, 45 min, 30 min, 15 min, 15 min, 5 min, 3 min, 2 min, 1min
It also doesn’t matter if the US stock symbol’s chart in Tradingview is set to RTH trading hours or ETH trading hours the data it uses (the high low close it takes from the previous day’s daily bar remains the same--- as a “daily bar” for US stocks is naturally defined in tradingview on US stocks as start 930am EST and end at 4pm EST (which is the New York RTH trading session for US Stocks.
So what I want to do is add 1 additional session and then in the user control panel the user can choose from 1 of 2 sessions
Session 1 – is the session it is coded for now in the existing code – if the user selects this session then everything works as it does now
Session 2 will be a new custom time period session that defined by the user which will be for a time period that starts and ends in the “Current Trading Day” as opposed to session 1 which is takes the High, Low and Close from the previous trading day’s daily bar.
Example 1- So for example if the user selects session 2 and inputs for session 2 to use start time of 6AM EST and an end time of 10AM EST
The indicator would then takes the High+Low+Close that occurs between 6AM and 10AM to generate the pivot
The highest high that occurs between 6:00AM EST and 10:00AM EST
The lowest low that occurs between 6:00AM EST and 10:00AM EST
And
The closing price that occurs at 10:00AM EST
Then right after the closing price occurs 10:00 AM EST same day it generates the pivot level and the other levels
Example 2- If the user instead selected Session 2 and inputs for session 2 to use start time of 8:15 AM EST and an end time of 10:30AM EST
The indicator would then takes the High+Low+Close that occurs between 815 AM EST and 10:30AM EST to generate the pivot
The highest high that occurs between 8:15AM EST and 10:30AM EST
The lowest low that occurs between 8:15AM EST and 10:30AM EST
And
The closing price that occurs at 10:30AM EST
Then right after the closing price occurs 10:30 AM EST same day it generates the pivot level and the other levels
So for example going back to this example for session 2 above
Example 2- If the user instead selected Session 2 and inputs for session 2 to use start time of 8:15 EST and an end time of 10:30AM EST
And the High occurring between start time of 8:15 AM EST and an end time of 10:30AM EST was 910.98
And the Low occurring between start time of 8:15 AM EST and an end time of 10:30AM EST was 876.16
And the Closing price at 10:30AM EST was 879.44
---------------------
Total High (910.98)+Low(876.16)+Close(879.44)= 2666.58 divided by 3= 888.86 main pivot
The main end result is that if the user instead selects session 2 and inputs a specific start time and end time that it should not matter (the same way it doesn’t matter in session 1) if I have my chart set to 1 min, 5 min, 4 hour or any other time frame of 1 day or less for it to work properly and initially generate the proper correct levels for the specific start and end time inputted for Session 2. Additionally it should continue to properly display the same correct pivot level it initially generated (in this example 888.76) and the same correct all other levels initially also generated on any time frame of 1 day or less even if the user changes their chart time frame (after the levels were generated to any other chart time frame that is 1 Day or less such as: 1 DAY, 4 hours, 3 hours, 2 hours, 1 Hour, 45 min, 30 min, 15 min, 15 min, 5 min, 3 min, 2 min, 1min
Whether that proper end result for session 2 with the custome start time and end time inputs in user control panel has to be accomplished by using the security() function in Pine Script to fetch data from a lower timeframe within your script to ensure that you're always working with the 1-minute timeframe data for your session calculations, regardless of the chart timeframe being viewed by the user, Or if that is not workable then whatever other method in pinescript that will ensure the end result for session 2 with user defined start and end will generate the levels properly and correctly on any user chart time frame 1 day or lower and will continue to display the same correct levels even if user changes the chart time frame after the levels were generated as long as that chart time frame is is changed to anything that is 1 day or less