Get Specific Months For Seasonality

tdespenza

New member
VIP
I've trying to replicate the seasonality with labels from Stockcharts but I'm having trouble accessing the specific months. Can someone point me in the right direction?

$NFLX example => https://stockcharts.com/freecharts/seasonality.php?symbol=nflx&compare=

Here's what I have so far:

Code:
Assert(GetAggregationPeriod() == AggregationPeriod.MONTH, "The `MonthlySeasonality` study is designed for monthly charts only");

def month = GetMonth();

def currentMoney = close - open;
def currentPercentage = (currentMoney / close) * 100;
AddLabel(visible = Yes, text = "Current: " + AsText(currentMoney, format = NumberFormat.DOLLAR) + "/" + AsText(currentPercentage) + "%", color = Color.LIGHT_GRAY);

def janDifference = Average(data = close[1]) - Average(data = open[1]);
def janPercentage = Average(janDifference) / Average(data = close[1]) * 100;
def janPostive = Average(janPercentage > 0) * 100;
AddLabel(visible = Yes, text = "Jan: " + AsText(value = janPostive) + "%+|Avg: " + AsText(janPercentage) + "%", color = Color.WHITE);
 
Last edited:

XeoNoX

Well-known member
VIP
You can do this easier by:

23moback = aggregate to monthly and scan within last 23 months since TOS scan wont go 24 months back

Code:
score = if  close > open then plus 1 else 0
finalscore = sum of score

reference for scoring ( https://usethinkscript.com/threads/basic-scoring-system.4954/#post-46304 )

final_scan = final score percent forumula

if you want help repeat this pattern below until you get to month1 and post the code back ( just repeat the countdown till you hit 1, should be a total of 23 lines that look similar)

Code:
def month21 = if (open(period = AggregationPeriod.MONTH)[21]) < (close(period = AggregationPeriod.MONTH)[21]) then 1 else 0;
def month22 = if (open(period = AggregationPeriod.MONTH)[22]) < (close(period = AggregationPeriod.MONTH)[22]) then 1 else 0;
def month23 = if (open(period = AggregationPeriod.MONTH)[23]) < (close(period = AggregationPeriod.MONTH)[23]) then 1 else 0;
 
Last edited:

XeoNoX

Well-known member
VIP
@tdespenza You were looking for something like this? One shows the percentage of higher closes over 48 months and the other shows number of consecutive bars over 48 months plotted (non percent) or were u looking for year over year same month comparison 4 years back?

Capture.png
 

tdespenza

New member
VIP
Unfortunately, I don't have a better one.

But what I'm looking for are labels to add to the chart. Whereas it displays the seasonality of a specific month.
 

bp805

New member
Giving this a bump. Im interested in trying to get this to work as well.

Basically what we're looking for is a chart label for every month displayed on a monthly time frame that gives the historical % that a given stock is up during that month, and an average % gain for that month. Ideally we'd be able to have the label show this for the life of the stock, but if that wont work, at least 10 years worth would be good.
 

Similar threads

Top