Hi all,
I have an indicator on the daily chart that sums various conditions, based on various study results, into a "score" of how bullish the stock is.
I want to keep using the "DAY" aggregation period for displaying this score as a label on the daily chart.
However, I also want to sum the score that is calculated for various intraday aggregation periods - 1 hour, 5 minute, and 15 minute - and then display this sum as an additional, second label on the daily chart.
(For example, if the score for the day period is 10, the chart label says: "Day Score: 10" and if the scores on the 1 hour, 5 minute, and 15 minute charts are 9, 3, and 11 then I want a second label to say "Intraday Score: 23.")
The script for the scoring is too long to just copy/paste duplicates of the entire script for each intraday aggregation period defined individually (it will produce an error in TOS saying the the script is too complex). So is there some shortcut method to calculate each of the four aggregation periods (i.e. without modifying each section of code into a different duplicate section that only differs from the others in the aggregation period used)?
For example, one component of the total score is a volume trend calculation. If the condition of the bullish volume trend is met, this makes the total score increase by two using a counter variable like this:
Without duplicating the entire code for the VolTrndScan component individually, i.e. for each aggregation period that I want summed, to get a combined intraday score using the three time frames, is it possible to add three lines of code like this?
The syntax is totally made up in the above example, it's just meant to show the kind of solution that I'm looking for: a simple way to make the code for the entire VolTrndScan calculation just use a different aggregation period than the default that is inherited from the current chart time frame (which in this case is 1D since I want this "Intraday Score" summed and displayed on the 1D chart).
Is this making sense? Is there a solution?
I have an indicator on the daily chart that sums various conditions, based on various study results, into a "score" of how bullish the stock is.
I want to keep using the "DAY" aggregation period for displaying this score as a label on the daily chart.
However, I also want to sum the score that is calculated for various intraday aggregation periods - 1 hour, 5 minute, and 15 minute - and then display this sum as an additional, second label on the daily chart.
(For example, if the score for the day period is 10, the chart label says: "Day Score: 10" and if the scores on the 1 hour, 5 minute, and 15 minute charts are 9, 3, and 11 then I want a second label to say "Intraday Score: 23.")
The script for the scoring is too long to just copy/paste duplicates of the entire script for each intraday aggregation period defined individually (it will produce an error in TOS saying the the script is too complex). So is there some shortcut method to calculate each of the four aggregation periods (i.e. without modifying each section of code into a different duplicate section that only differs from the others in the aggregation period used)?
For example, one component of the total score is a volume trend calculation. If the condition of the bullish volume trend is met, this makes the total score increase by two using a counter variable like this:
Code:
def VolTrndCounter = if VolTrndScan then 2 else 0;
Without duplicating the entire code for the VolTrndScan component individually, i.e. for each aggregation period that I want summed, to get a combined intraday score using the three time frames, is it possible to add three lines of code like this?
Code:
def VolTrndCounter5min = if VolTrndScan(use.aggregation.period.5MIN) then 2 else 0;
def VolTrndCounter15min = if VolTrndScan(use.aggregation.period.15MIN) then 2 else 0;
def VolTrndCounter1hour = if VolTrndScan(use.aggregation.period.1HOUR) then 2 else 0;
The syntax is totally made up in the above example, it's just meant to show the kind of solution that I'm looking for: a simple way to make the code for the entire VolTrndScan calculation just use a different aggregation period than the default that is inherited from the current chart time frame (which in this case is 1D since I want this "Intraday Score" summed and displayed on the 1D chart).
Is this making sense? Is there a solution?
Last edited: