JiminySmanchez
New member
Hi everyone! First I want to say thank you to everyone here, as this site has been a huge help to me on my learning journey and I'm super grateful for this community already.
I have been working on the watchlist column indicator shown at the right in the image above. This indicator should show me when the close is greater than or equal to the upper stdDevs and when close is less than or equal to the lower StdDevs (i.e. N/A for inside first dev channel, UP1 for >= first stdDev, UP2 for >= second stdDev...). It should follow the below example on the chart.
My biggest issue now is getting it to work within my preferred timeframe, which would be Today: 1m. Ideally, I would like to see what the code would look like both with and without PM included (I like to use PM for the first 30 minutes of the day and only regular trading hours during the remainder of the day). If the code can be written to include both timeframes that would be AMAZING, and would prevent me from needing to switch back and forth, however, I'm not opposed to making the switch if needed and understand I may need to considering the "Include Extended-Hours Trading session" checkbox.
The code I have so far is:
BONUS: If we can update the code to use Inerita(); and stDev(); instead of the All variants included in the regression and stdDeviation definitions, we should be able to remove the complex script warning from this code. The issue I've face when challenging this is that length needs to be a constant, so defining length has been unsuccessful for me.
Again, thank you all for any help you're able to provide!
I have been working on the watchlist column indicator shown at the right in the image above. This indicator should show me when the close is greater than or equal to the upper stdDevs and when close is less than or equal to the lower StdDevs (i.e. N/A for inside first dev channel, UP1 for >= first stdDev, UP2 for >= second stdDev...). It should follow the below example on the chart.
My biggest issue now is getting it to work within my preferred timeframe, which would be Today: 1m. Ideally, I would like to see what the code would look like both with and without PM included (I like to use PM for the first 30 minutes of the day and only regular trading hours during the remainder of the day). If the code can be written to include both timeframes that would be AMAZING, and would prevent me from needing to switch back and forth, however, I'm not opposed to making the switch if needed and understand I may need to considering the "Include Extended-Hours Trading session" checkbox.
The code I have so far is:
Code:
def price = close;
def regression;
regression = inertiaAll(price);
def stdDeviation;
stdDeviation = stDevAll(price);
# First StdDev
input dev1 = 1.0;
def upperLine1 = regression + dev1 * stdDeviation;
def lowerLine1 = regression - dev1 * stdDeviation;
# Second StdDev
input dev2 = 2.0;
def upperLine2 = regression + dev2 * stdDeviation;
def lowerLine2 = regression - dev2 * stdDeviation;
# Third StdDev
input dev3 = 3.0;
def upperLine3 = regression + dev3 * stdDeviation;
def lowerLine3 = regression - dev3 * stdDeviation;
# Plot
def status = if price is greater than or equal to upperLine3 then 3
else if price is greater than or equal to upperLine2 then 2
else if price is greater than or equal to upperLine1 then 1
else if price is less than or equal to lowerLine3 then -3
else if price is less than or equal to lowerLine2 then -2
else if price is less than or equal to lowerLine1 then -1
else Double.NaN;
AddLabel(yes,
if status == 3 then "UP3"
else if status == 2 then "UP2"
else if status == 1 then "UP1"
else if status == -3 then "DN3"
else if status == -2 then "DN2"
else if status == -1 then "DN1"
else "N/A",
if status <> 0 then color.Black
else color.White);
AssignBackgroundColor(
if status == 1 then color.YELLOW
else if status == 2 then color.ORANGE
else if status == 3 then color.DOWNTICK
else if status == -1 then color.CYAN
else if status == -2 then color.LIGHT_GREEN
else if status == -3 then color.UPTICK
else color.CURRENT);
BONUS: If we can update the code to use Inerita(); and stDev(); instead of the All variants included in the regression and stdDeviation definitions, we should be able to remove the complex script warning from this code. The issue I've face when challenging this is that length needs to be a constant, so defining length has been unsuccessful for me.
Again, thank you all for any help you're able to provide!