StochasticSlow Data from Higher Aggregation Period


Category:
0
0
  • I am looking for help to create a label that pulls data from a higher buy period. For example, I want to look at the daily chart and have a label that tells me if the StochasticSlow, SlowK is greater than the StochasticSlow, SlowK from the candle before on the weekly chart. I wrote the following code below but it only tells me the information from the current aggregation period that I am looking at and not the weekly. Any help would be greatly appreciated.
    input firstAggregation = AggregationPeriod.WEEK;

    def StochasticSlowUp;

    if GetAggregationPeriod() <= firstAggregation
    {

    StochasticSlowUp = StochasticSlow(“average type” = “EXPONENTIAL”).”SlowK” is greater than StochasticSlow(“average type” = “EXPONENTIAL”).”SlowK” from 1 bars ago;

    }
    else {

    StochasticSlowUp = 0;

    }

    addlabel(yes, StochasticSlowUp);

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on September 26, 2021 10:39 am
114 views
0
Private answer

There are many examples of how to reference higher time frames in this forum. We also have a complete MTF MACD chart study available through the following video:

https://www.hahn-tech.com/thinkorswim-mtf-macd-indicator/

Yes, I know that is not covering the Stochastic. But there is no blanket solution to this and each and every indicator must modified in it's own way. But once you see how this is done for 2-3 different indicators you begin to see the changes that are required to make this work.

I only had time to assemble the StochasticFull that references a higher time frame. You can take this example and use it to build the rest of the code to build your chart label.

input stochOB = 80;
input stochOS = 20;
input kPeriod = 10;
input dPeriod = 10;
input timeFrameOne = AggregationPeriod.DAY;
input slowingPeriod = 3;
input stochAverageType = AverageType.SIMPLE;
def lowestK = Lowest(low(period = timeFrameOne), kPeriod);
def changeA = close(period = timeFrameOne) - lowestK;
def changeB = Highest(high(period = timeFrameOne), kPeriod) - lowestK;
def fastK = if changeB != 0 then changeA / changeB * 100 else 0;
plot fullK = MovingAverage(stochAverageType, fastK, slowingPeriod);
plot fullD = MovingAverage(stochAverageType, fullK, dPeriod);
plot overbought = stochOB;
plot oversold = stochOS;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 27, 2021 8:11 am
0
Thank you so much for your help Pete!
( at October 3, 2021 8:12 am)