Repaints Multi Time Frame MTF Squeeze HISTOGRAM Colored Labels for ThinkOrSwim

Repaints
Anybody know how I can use this squeeze Histogram in certain timeframes in the scan as a condition? Such as lets say find stock that has magenta increasing momentum over 0 on daily? or If you wanted to find stocks to short with negative momentum red on the weekly for example
You have to spit the time frames up and scan separat study in a single scan
 
Appreciate response, I was looking for just histo scan specific part of squeeze. I can put time frame in the study scan part of thinkorswim. I wanted to scan to find stocks in cyan specific momo in the histogram part of squeeze.

You have to spit the time frames up and scan separat study in a single scan
 
Last edited:
Appreciate response, I was looking for just histo scan specific part of squeeze. I can put time frame in the study scan part of thinkorswim. I wanted to scan to find stocks in cyan specific momo in the histogram part of squeeze.
its base on the ema. ema value higher then last period histo higher lower then lower. just like any other histogram. hope that helps
 
What does Pos up/down and neg up/down represent?
Sorry for delayed reply in answering you - to be honest, I’m surprised somebody else hasn’t done so already! The pos up/down and neg up/down represent momentum. If momentum is > 0 then momentum is positive and if momentum is <= 0 then it’s negative. Then for the up and down portion —> if the momentum of he current bar/candle is > the momentum of the previous bar/candle then it’s UP. Vice versa with down - if the momentum of the current bar/candle is less than the momentum of the previous bar/candle then it’s DOWN.

Just to make this crystal clear - if you have momentum <= 0 then it’s NEGATIVE and if the momentum of the current bar is < the momentum of the previous bar then it would be NegDn (negative down)

If you have momentum <= 0 then it’s NEGATIVE and if the momentum of the current bar is > the momentum of the previous bar then it would be NegUp (momentum is negative but it’s getting weaker to the downside and pushing towards the upside)

If you have momentum > 0 then it’s POSITIVE and if the momentum of the current bar is > the momentum of the previous bar then it would be PosUp

If you have momentum > 0 then it’s POSITIVE and if the momentum of the current bar is < the momentum of the previous bar then it would be PosDn (momentum is positive but it’s losing steam to the upside)

It’s like if there’s a HUGE rally - people are buying a stock like it’s the only thing that’ll save their lives. It drives the price of a stock up quickly.(PosUp) But it gets to a point where people will stop buying/buying slows down and the early buyers will even start selling. (PosDn)

Same goes for if there’s a HUGE sell-off causing a stock/underlying to plummet (NegDn). But again, it’ll get to a point where volume is exhausted and/or the underlying is at a price that’s appealing for long-term investors to jump in and buy it (NegUp).

Hope this wasn’t too horribly redundant and answers your question!
 
Is there a way to get Histogram Multi timeframes specific chart below where there is there 0 line and have each time frame plot own lines to one chart below visually see those other time frames moving up and below 0
 
See the revised code attached. Took out the GlobalColor redundancies and added on/off selections for each time frame! I'm going to edit the script at the top of this thread with this new version as well.
Code:
##MTF Squeeze Histogram Labels
##Created By: Casey Brett
##Global Variables

input price = close;
input length = 20;
input averageType = AverageType.EXPONENTIAL;
input displace = 0;

def K = (Highest(high, length) + Lowest(low, length)) /2 + ExpAverage(close, length);
def momo = Inertia(price - K / 2, length);

def pos         = momo >= 0;
def neg         = momo < 0;
def up         = momo >= momo[1];
def dn         = momo < momo[1];

def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;

input MonthLabel = yes;
input WeekLabel = yes;
input FourDayLabel = yes;
input ThreeDayLabel = yes;
input TwoDayLabel = yes;
input DayLabel = yes;
input FourHourLabel = yes;
input TwoHourLabel = yes;
input OneHourLabel = yes;
input ThirtyMinLabel = yes;
input TwentyMinLabel = yes;
input FifteenMinLabel = yes;
input TenMinLabel = yes;
input FiveMinLabel = yes;
input FourMinLabel = yes;
input ThreeMinLabel = yes;
input TwoMinLabel = yes;
input OneMinLabel = yes;


defineGlobalColor("PosUp", color.cyan);
defineGlobalColor("PosDn", color.blue);
defineGlobalColor("NegDn", color.red);
defineGlobalColor("NegUp", color.yellow);
defineGlobalColor("Neutral", color.gray);

def monthprice;
def Kmonth;
def monthmomo;
Def Month_ExpAverage;
Def monthpos;
Def monthneg;
Def monthup;
Def monthdn;
Def monthPosUp;
Def monthPosDn;
Def monthNegDn;
Def monthNegUp;
Def monthAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.Month {
    monthprice = close(period="Month");
    Kmonth = (Highest(high(period="Month"), length) + Lowest(low(period="Month"), length)) /2 + ExpAverage(close(period="Month"), length);
    monthmomo = Inertia(monthprice- kmonth / 2, length);
    Month_ExpAverage = ExpAverage(close(period="Month"), Length);
    monthpos = monthmomo >= 0;
    monthneg = monthmomo < 0;
    monthup  = monthmomo >= monthmomo[1];
    monthdn  = monthmomo < monthmomo[1];

    monthPosUp = monthpos and monthup;
    monthPosDn = monthpos and monthdn;
    monthNegDn = monthneg and monthdn;
    monthNegUp = monthneg and monthup;
    monthAggregationPeriod = 1;
}
Else {
    monthprice = 0;
    Kmonth = 0;
    monthmomo = 0;
    Month_ExpAverage = 0;
    monthpos = 0;
    monthneg = 0;
    monthup = 0;
    monthdn = 0;
    monthPosUp = 0;
    monthPosDn = 0;
    monthNegDn = 0;
    monthNegUp = 0;
    monthAggregationPeriod = 0;
}
AddLabel(monthLabel and monthAggregationPeriod, "M", if monthPosUp then globalColor("PosUp") else if monthPosDn then globalColor("PosDn") else if monthNegDn then globalColor("NegDn") else if monthNegUp then globalColor("NegUp") else globalColor("Neutral"));

def Weekprice;
def KWeek;
def Weekmomo;
Def Week_ExpAverage;
Def Weekpos;
Def Weekneg;
Def Weekup;
Def Weekdn;
Def WeekPosUp;
Def WeekPosDn;
Def WeekNegDn;
Def WeekNegUp;
Def WeekAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.Week {
    Weekprice = close(period="Week");
    KWeek = (Highest(high(period="Week"), length) + Lowest(low(period="Week"), length)) /2 + ExpAverage(close(period="week"), length);
    Weekmomo = Inertia(Weekprice- kWeek / 2, length);
    Week_ExpAverage = ExpAverage(close(period="Week"), Length);
    Weekpos = Weekmomo >= 0;
    Weekneg = Weekmomo < 0;
    Weekup  = Weekmomo >= Weekmomo[1];
    Weekdn  = Weekmomo < Weekmomo[1];

    WeekPosUp = Weekpos and Weekup;
    WeekPosDn = Weekpos and Weekdn;
    WeekNegDn = Weekneg and Weekdn;
    WeekNegUp = Weekneg and Weekup;
    WeekAggregationPeriod = 1;
}
Else {
    Weekprice = 0;
    KWeek = 0;
    Weekmomo = 0;
    Week_ExpAverage = 0;
    Weekpos = 0;
    Weekneg = 0;
    Weekup = 0;
    Weekdn = 0;
    WeekPosUp = 0;
    WeekPosDn = 0;
    WeekNegDn = 0;
    WeekNegUp = 0;
    WeekAggregationPeriod = 0;
}
AddLabel(WeekLabel and WeekAggregationPeriod, "W", if WeekPosUp then globalColor("PosUp") else if WeekPosDn then globalColor("PosDn") else if WeekNegDn then globalColor("NegDn") else if WeekNegUp then globalColor("NegUp") else globalColor("Neutral"));


def four_daysprice;
def Kfour_days;
def four_daysmomo;
Def four_days_ExpAverage;
Def four_dayspos;
Def four_daysneg;
Def four_daysup;
Def four_daysdn;
Def four_daysPosUp;
Def four_daysPosDn;
Def four_daysNegDn;
Def four_daysNegUp;
Def four_daysAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.four_days {
    four_daysprice = close(period="4 Days");
    Kfour_days = (Highest(high(period="4 Days"), length) + Lowest(low(period="4 Days"), length)) /2 + ExpAverage(close(period="4 Days"), length);
    four_daysmomo = Inertia(four_daysprice- kfour_days / 2, length);
    four_days_ExpAverage = ExpAverage(close(period="4 Days"), Length);
    four_dayspos = four_daysmomo >= 0;
    four_daysneg = four_daysmomo < 0;
    four_daysup  = four_daysmomo >= four_daysmomo[1];
    four_daysdn  = four_daysmomo < four_daysmomo[1];

    four_daysPosUp = four_dayspos and four_daysup;
    four_daysPosDn = four_dayspos and four_daysdn;
    four_daysNegDn = four_daysneg and four_daysdn;
    four_daysNegUp = four_daysneg and four_daysup;
    four_daysAggregationPeriod = 1;
}
Else {
    four_daysprice = 0;
    Kfour_days = 0;
    four_daysmomo = 0;
    four_days_ExpAverage = 0;
    four_dayspos = 0;
    four_daysneg = 0;
    four_daysup = 0;
    four_daysdn = 0;
    four_daysPosUp = 0;
    four_daysPosDn = 0;
    four_daysNegDn = 0;
    four_daysNegUp = 0;
    four_daysAggregationPeriod = 0;
}
AddLabel(FourDayLabel and four_daysAggregationPeriod, "4D", if four_daysPosUp then globalColor("PosUp") else if four_daysPosDn then globalColor("PosDn") else if four_daysNegDn then globalColor("NegDn") else if four_daysNegUp then globalColor("NegUp") else globalColor("Neutral"));

def three_daysprice;
def Kthree_days;
def three_daysmomo;
Def three_days_ExpAverage;
Def three_dayspos;
Def three_daysneg;
Def three_daysup;
Def three_daysdn;
Def three_daysPosUp;
Def three_daysPosDn;
Def three_daysNegDn;
Def three_daysNegUp;
Def three_daysAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.three_days {
    three_daysprice = close(period="3 Days");
    Kthree_days = (Highest(high(period="3 Days"), length) + Lowest(low(period="3 Days"), length)) /2 + ExpAverage(close(period="3 Days"), length);
    three_daysmomo = Inertia(three_daysprice- kthree_days / 2, length);
    three_days_ExpAverage = ExpAverage(close(period="3 Days"), Length);
    three_dayspos = three_daysmomo >= 0;
    three_daysneg = three_daysmomo < 0;
    three_daysup  = three_daysmomo >= three_daysmomo[1];
    three_daysdn  = three_daysmomo < three_daysmomo[1];

    three_daysPosUp = three_dayspos and three_daysup;
    three_daysPosDn = three_dayspos and three_daysdn;
    three_daysNegDn = three_daysneg and three_daysdn;
    three_daysNegUp = three_daysneg and three_daysup;
    three_daysAggregationPeriod = 1;
}
Else {
    three_daysprice = 0;
    Kthree_days = 0;
    three_daysmomo = 0;
    three_days_ExpAverage = 0;
    three_dayspos = 0;
    three_daysneg = 0;
    three_daysup = 0;
    three_daysdn = 0;
    three_daysPosUp = 0;
    three_daysPosDn = 0;
    three_daysNegDn = 0;
    three_daysNegUp = 0;
    three_daysAggregationPeriod = 0;
}
AddLabel(ThreeDayLabel and three_daysAggregationPeriod, "3D", if three_daysPosUp then globalColor("PosUp") else if three_daysPosDn then globalColor("PosDn") else if three_daysNegDn then globalColor("NegDn") else if three_daysNegUp then globalColor("NegUp") else globalColor("Neutral"));




def two_daysprice;
def Ktwo_days;
def two_daysmomo;
Def two_days_ExpAverage;
Def two_dayspos;
Def two_daysneg;
Def two_daysup;
Def two_daysdn;
Def two_daysPosUp;
Def two_daysPosDn;
Def two_daysNegDn;
Def two_daysNegUp;
Def two_daysAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.two_days {
    two_daysprice = close(period="2 Days");
    Ktwo_days = (Highest(high(period="2 Days"), length) + Lowest(low(period="2 Days"), length)) /2 + ExpAverage(close(period="2 Days"), length);
    two_daysmomo = Inertia(two_daysprice- ktwo_days / 2, length);
    two_days_ExpAverage = ExpAverage(close(period="2 Days"), Length);
    two_dayspos = two_daysmomo >= 0;
    two_daysneg = two_daysmomo < 0;
    two_daysup  = two_daysmomo >= two_daysmomo[1];
    two_daysdn  = two_daysmomo < two_daysmomo[1];

    two_daysPosUp = two_dayspos and two_daysup;
    two_daysPosDn = two_dayspos and two_daysdn;
    two_daysNegDn = two_daysneg and two_daysdn;
    two_daysNegUp = two_daysneg and two_daysup;
    two_daysAggregationPeriod = 1;
}
Else {
    two_daysprice = 0;
    Ktwo_days = 0;
    two_daysmomo = 0;
    two_days_ExpAverage = 0;
    two_dayspos = 0;
    two_daysneg = 0;
    two_daysup = 0;
    two_daysdn = 0;
    two_daysPosUp = 0;
    two_daysPosDn = 0;
    two_daysNegDn = 0;
    two_daysNegUp = 0;
    two_daysAggregationPeriod = 0;
}
AddLabel(TwoDayLabel and two_daysAggregationPeriod, "2D", if two_daysPosUp then globalColor("PosUp") else if two_daysPosDn then globalColor("PosDn") else if two_daysNegDn then globalColor("NegDn") else if two_daysNegUp then globalColor("NegUp") else globalColor("Neutral"));


def Dayprice;
def KDay;
def Daymomo;
Def Day_ExpAverage;
Def Daypos;
Def Dayneg;
Def Dayup;
Def Daydn;
Def DayPosUp;
Def DayPosDn;
Def DayNegDn;
Def DayNegUp;
Def DayAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.Day {
    Dayprice = close(period="Day");
    KDay = (Highest(high(period="Day"), length) + Lowest(low(period="Day"), length)) /2 + ExpAverage(close(period="Day"), length);
    Daymomo = Inertia(Dayprice- kDay / 2, length);
    Day_ExpAverage = ExpAverage(close(period="Day"), Length);
    Daypos = Daymomo >= 0;
    Dayneg = Daymomo < 0;
    Dayup  = Daymomo >= Daymomo[1];
    Daydn  = Daymomo < Daymomo[1];

    DayPosUp = Daypos and Dayup;
    DayPosDn = Daypos and Daydn;
    DayNegDn = Dayneg and Daydn;
    DayNegUp = Dayneg and Dayup;
    DayAggregationPeriod = 1;
}
Else {
    Dayprice = 0;
    KDay = 0;
    Daymomo = 0;
    Day_ExpAverage = 0;
    Daypos = 0;
    Dayneg = 0;
    Dayup = 0;
    Daydn = 0;
    DayPosUp = 0;
    DayPosDn = 0;
    DayNegDn = 0;
    DayNegUp = 0;
    DayAggregationPeriod = 0;
}
AddLabel(DayLabel and DayAggregationPeriod, "D", if DayPosUp then globalColor("PosUp") else if DayPosDn then globalColor("PosDn") else if DayNegDn then globalColor("NegDn") else if DayNegUp then globalColor("NegUp") else globalColor("Neutral"));


def four_hoursprice;
def Kfour_hours;
def four_hoursmomo;
Def four_hours_ExpAverage;
Def four_hourspos;
Def four_hoursneg;
Def four_hoursup;
Def four_hoursdn;
Def four_hoursPosUp;
Def four_hoursPosDn;
Def four_hoursNegDn;
Def four_hoursNegUp;
Def four_hoursAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.four_hours {
    four_hoursprice = close(period="4 Hours");
    Kfour_hours = (Highest(high(period="4 Hours"), length) + Lowest(low(period="4 Hours"), length)) /2 + ExpAverage(close(period="4 Hours"), length);
    four_hoursmomo = Inertia(four_hoursprice- kfour_hours / 2, length);
    four_hours_ExpAverage = ExpAverage(close(period="4 Hours"), Length);
    four_hourspos = four_hoursmomo >= 0;
    four_hoursneg = four_hoursmomo < 0;
    four_hoursup  = four_hoursmomo >= four_hoursmomo[1];
    four_hoursdn  = four_hoursmomo < four_hoursmomo[1];

    four_hoursPosUp = four_hourspos and four_hoursup;
    four_hoursPosDn = four_hourspos and four_hoursdn;
    four_hoursNegDn = four_hoursneg and four_hoursdn;
    four_hoursNegUp = four_hoursneg and four_hoursup;
    four_hoursAggregationPeriod = 1;
}
Else {
    four_hoursprice = 0;
    Kfour_hours = 0;
    four_hoursmomo = 0;
    four_hours_ExpAverage = 0;
    four_hourspos = 0;
    four_hoursneg = 0;
    four_hoursup = 0;
    four_hoursdn = 0;
    four_hoursPosUp = 0;
    four_hoursPosDn = 0;
    four_hoursNegDn = 0;
    four_hoursNegUp = 0;
    four_hoursAggregationPeriod = 0;
}
AddLabel(FourHourLabel and four_hoursAggregationPeriod, "4h", if four_hoursPosUp then globalColor("PosUp") else if four_hoursPosDn then globalColor("PosDn") else if four_hoursNegDn then globalColor("NegDn") else if four_hoursNegUp then globalColor("NegUp") else globalColor("Neutral"));



def two_hoursprice;
def Ktwo_hours;
def two_hoursmomo;
Def two_hours_ExpAverage;
Def two_hourspos;
Def two_hoursneg;
Def two_hoursup;
Def two_hoursdn;
Def two_hoursPosUp;
Def two_hoursPosDn;
Def two_hoursNegDn;
Def two_hoursNegUp;
Def two_hoursAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.two_hours {
    two_hoursprice = close(period="2 Hours");
    Ktwo_hours = (Highest(high(period="2 Hours"), length) + Lowest(low(period="2 Hours"), length)) /2 + ExpAverage(close(period="2 Hours"), length);
    two_hoursmomo = Inertia(two_hoursprice- ktwo_hours / 2, length);
    two_hours_ExpAverage = ExpAverage(close(period="2 Hours"), Length);
    two_hourspos = two_hoursmomo >= 0;
    two_hoursneg = two_hoursmomo < 0;
    two_hoursup  = two_hoursmomo >= two_hoursmomo[1];
    two_hoursdn  = two_hoursmomo < two_hoursmomo[1];

    two_hoursPosUp = two_hourspos and two_hoursup;
    two_hoursPosDn = two_hourspos and two_hoursdn;
    two_hoursNegDn = two_hoursneg and two_hoursdn;
    two_hoursNegUp = two_hoursneg and two_hoursup;
    two_hoursAggregationPeriod = 1;
}
Else {
    two_hoursprice = 0;
    Ktwo_hours = 0;
    two_hoursmomo = 0;
    two_hours_ExpAverage = 0;
    two_hourspos = 0;
    two_hoursneg = 0;
    two_hoursup = 0;
    two_hoursdn = 0;
    two_hoursPosUp = 0;
    two_hoursPosDn = 0;
    two_hoursNegDn = 0;
    two_hoursNegUp = 0;
    two_hoursAggregationPeriod = 0;
}
AddLabel(TwoHourLabel and two_hoursAggregationPeriod, "2h", if two_hoursPosUp then globalColor("PosUp") else if two_hoursPosDn then globalColor("PosDn") else if two_hoursNegDn then globalColor("NegDn") else if two_hoursNegUp then globalColor("NegUp") else globalColor("Neutral"));



def hourprice;
def Khour;
def hourmomo;
Def hour_ExpAverage;
Def hourpos;
Def hourneg;
Def hourup;
Def hourdn;
Def hourPosUp;
Def hourPosDn;
Def hourNegDn;
Def hourNegUp;
Def hourAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.hour {
    hourprice = close(period="1 Hour");
    Khour = (Highest(high(period="1 Hour"), length) + Lowest(low(period="1 Hour"), length)) /2 + ExpAverage(close(period="1 Hour"), length);
    hourmomo = Inertia(hourprice- khour / 2, length);
    hour_ExpAverage = ExpAverage(close(period="1 Hour"), Length);
    hourpos = hourmomo >= 0;
    hourneg = hourmomo < 0;
    hourup  = hourmomo >= hourmomo[1];
    hourdn  = hourmomo < hourmomo[1];

    hourPosUp = hourpos and hourup;
    hourPosDn = hourpos and hourdn;
    hourNegDn = hourneg and hourdn;
    hourNegUp = hourneg and hourup;
    hourAggregationPeriod = 1;
}
Else {
    hourprice = 0;
    Khour = 0;
    hourmomo = 0;
    hour_ExpAverage = 0;
    hourpos = 0;
    hourneg = 0;
    hourup = 0;
    hourdn = 0;
    hourPosUp = 0;
    hourPosDn = 0;
    hourNegDn = 0;
    hourNegUp = 0;
    hourAggregationPeriod = 0;
}
AddLabel(OneHourLabel and hourAggregationPeriod, "1h", if hourPosUp then globalColor("PosUp") else if hourPosDn then globalColor("PosDn") else if hourNegDn then globalColor("NegDn") else if hourNegUp then globalColor("NegUp") else globalColor("Neutral"));



def thirty_minprice;
def Kthirty_min;
def thirty_minmomo;
Def thirty_min_ExpAverage;
Def thirty_minpos;
Def thirty_minneg;
Def thirty_minup;
Def thirty_mindn;
Def thirty_minPosUp;
Def thirty_minPosDn;
Def thirty_minNegDn;
Def thirty_minNegUp;
Def thirty_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.thirty_min {
    thirty_minprice = close(period="30 Min");
    Kthirty_min = (Highest(high(period="30 Min"), length) + Lowest(low(period="30 Min"), length)) /2 + ExpAverage(close(period="30 Min"), length);
    thirty_minmomo = Inertia(thirty_minprice- kthirty_min / 2, length);
    thirty_min_ExpAverage = ExpAverage(close(period="30 Min"), Length);
    thirty_minpos = thirty_minmomo >= 0;
    thirty_minneg = thirty_minmomo < 0;
    thirty_minup  = thirty_minmomo >= thirty_minmomo[1];
    thirty_mindn  = thirty_minmomo < thirty_minmomo[1];

    thirty_minPosUp = thirty_minpos and thirty_minup;
    thirty_minPosDn = thirty_minpos and thirty_mindn;
    thirty_minNegDn = thirty_minneg and thirty_mindn;
    thirty_minNegUp = thirty_minneg and thirty_minup;
    thirty_minAggregationPeriod = 1;
}
Else {
    thirty_minprice = 0;
    Kthirty_min = 0;
    thirty_minmomo = 0;
    thirty_min_ExpAverage = 0;
    thirty_minpos = 0;
    thirty_minneg = 0;
    thirty_minup = 0;
    thirty_mindn = 0;
    thirty_minPosUp = 0;
    thirty_minPosDn = 0;
    thirty_minNegDn = 0;
    thirty_minNegUp = 0;
    thirty_minAggregationPeriod = 0;
}
AddLabel(ThirtyMinLabel and thirty_minAggregationPeriod, "30m", if thirty_minPosUp then globalColor("PosUp") else if thirty_minPosDn then globalColor("PosDn") else if thirty_minNegDn then globalColor("NegDn") else if thirty_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def twenty_minprice;
def Ktwenty_min;
def twenty_minmomo;
Def twenty_min_ExpAverage;
Def twenty_minpos;
Def twenty_minneg;
Def twenty_minup;
Def twenty_mindn;
Def twenty_minPosUp;
Def twenty_minPosDn;
Def twenty_minNegDn;
Def twenty_minNegUp;
Def twenty_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.twenty_min {
    twenty_minprice = close(period="20 Min");
    Ktwenty_min = (Highest(high(period="20 Min"), length) + Lowest(low(period="20 Min"), length)) /2 + ExpAverage(close(period="20 Min"), length);
    twenty_minmomo = Inertia(twenty_minprice- ktwenty_min / 2, length);
    twenty_min_ExpAverage = ExpAverage(close(period="20 Min"), Length);
    twenty_minpos = twenty_minmomo >= 0;
    twenty_minneg = twenty_minmomo < 0;
    twenty_minup  = twenty_minmomo >= twenty_minmomo[1];
    twenty_mindn  = twenty_minmomo < twenty_minmomo[1];

    twenty_minPosUp = twenty_minpos and twenty_minup;
    twenty_minPosDn = twenty_minpos and twenty_mindn;
    twenty_minNegDn = twenty_minneg and twenty_mindn;
    twenty_minNegUp = twenty_minneg and twenty_minup;
    twenty_minAggregationPeriod = 1;
}
Else {
    twenty_minprice = 0;
    Ktwenty_min = 0;
    twenty_minmomo = 0;
    twenty_min_ExpAverage = 0;
    twenty_minpos = 0;
    twenty_minneg = 0;
    twenty_minup = 0;
    twenty_mindn = 0;
    twenty_minPosUp = 0;
    twenty_minPosDn = 0;
    twenty_minNegDn = 0;
    twenty_minNegUp = 0;
    twenty_minAggregationPeriod = 0;
}
AddLabel(TwentyMinLabel and twenty_minAggregationPeriod, "20m", if twenty_minPosUp then globalColor("PosUp") else if twenty_minPosDn then globalColor("PosDn") else if twenty_minNegDn then globalColor("NegDn") else if twenty_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def fifteen_minprice;
def Kfifteen_min;
def fifteen_minmomo;
Def fifteen_min_ExpAverage;
Def fifteen_minpos;
Def fifteen_minneg;
Def fifteen_minup;
Def fifteen_mindn;
Def fifteen_minPosUp;
Def fifteen_minPosDn;
Def fifteen_minNegDn;
Def fifteen_minNegUp;
Def fifteen_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.fifteen_min {
    fifteen_minprice = close(period="15 Min");
    Kfifteen_min = (Highest(high(period="15 Min"), length) + Lowest(low(period="15 Min"), length)) /2 + ExpAverage(close(period="15 Min"), length);
    fifteen_minmomo = Inertia(fifteen_minprice- kfifteen_min / 2, length);
    fifteen_min_ExpAverage = ExpAverage(close(period="15 Min"), Length);
    fifteen_minpos = fifteen_minmomo >= 0;
    fifteen_minneg = fifteen_minmomo < 0;
    fifteen_minup  = fifteen_minmomo >= fifteen_minmomo[1];
    fifteen_mindn  = fifteen_minmomo < fifteen_minmomo[1];

    fifteen_minPosUp = fifteen_minpos and fifteen_minup;
    fifteen_minPosDn = fifteen_minpos and fifteen_mindn;
    fifteen_minNegDn = fifteen_minneg and fifteen_mindn;
    fifteen_minNegUp = fifteen_minneg and fifteen_minup;
    fifteen_minAggregationPeriod = 1;
}
Else {
    fifteen_minprice = 0;
    Kfifteen_min = 0;
    fifteen_minmomo = 0;
    fifteen_min_ExpAverage = 0;
    fifteen_minpos = 0;
    fifteen_minneg = 0;
    fifteen_minup = 0;
    fifteen_mindn = 0;
    fifteen_minPosUp = 0;
    fifteen_minPosDn = 0;
    fifteen_minNegDn = 0;
    fifteen_minNegUp = 0;
    fifteen_minAggregationPeriod = 0;
}
AddLabel(FifteenMinLabel and fifteen_minAggregationPeriod, "15m", if fifteen_minPosUp then globalColor("PosUp") else if fifteen_minPosDn then globalColor("PosDn") else if fifteen_minNegDn then globalColor("NegDn") else if fifteen_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def ten_minprice;
def Kten_min;
def ten_minmomo;
Def ten_min_ExpAverage;
Def ten_minpos;
Def ten_minneg;
Def ten_minup;
Def ten_mindn;
Def ten_minPosUp;
Def ten_minPosDn;
Def ten_minNegDn;
Def ten_minNegUp;
Def ten_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.ten_min {
    ten_minprice = close(period="10 Min");
    Kten_min = (Highest(high(period="10 Min"), length) + Lowest(low(period="10 Min"), length)) /2 + ExpAverage(close(period="10 Min"), length);
    ten_minmomo = Inertia(ten_minprice- kten_min / 2, length);
    ten_min_ExpAverage = ExpAverage(close(period="10 Min"), Length);
    ten_minpos = ten_minmomo >= 0;
    ten_minneg = ten_minmomo < 0;
    ten_minup  = ten_minmomo >= ten_minmomo[1];
    ten_mindn  = ten_minmomo < ten_minmomo[1];

    ten_minPosUp = ten_minpos and ten_minup;
    ten_minPosDn = ten_minpos and ten_mindn;
    ten_minNegDn = ten_minneg and ten_mindn;
    ten_minNegUp = ten_minneg and ten_minup;
    ten_minAggregationPeriod = 1;
}
Else {
    ten_minprice = 0;
    Kten_min = 0;
    ten_minmomo = 0;
    ten_min_ExpAverage = 0;
    ten_minpos = 0;
    ten_minneg = 0;
    ten_minup = 0;
    ten_mindn = 0;
    ten_minPosUp = 0;
    ten_minPosDn = 0;
    ten_minNegDn = 0;
    ten_minNegUp = 0;
    ten_minAggregationPeriod = 0;
}
AddLabel(TenMinLabel and ten_minAggregationPeriod, "10m", if ten_minPosUp then globalColor("PosUp") else if ten_minPosDn then globalColor("PosDn") else if ten_minNegDn then globalColor("NegDn") else if ten_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def five_minprice;
def Kfive_min;
def five_minmomo;
Def five_min_ExpAverage;
Def five_minpos;
Def five_minneg;
Def five_minup;
Def five_mindn;
Def five_minPosUp;
Def five_minPosDn;
Def five_minNegDn;
Def five_minNegUp;
Def five_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.five_min {
    five_minprice = close(period="5 Min");
    Kfive_min = (Highest(high(period="5 Min"), length) + Lowest(low(period="5 Min"), length)) /2 + ExpAverage(close(period="5 Min"), length);
    five_minmomo = Inertia(five_minprice- kfive_min / 2, length);
    five_min_ExpAverage = ExpAverage(close(period="5 Min"), Length);
    five_minpos = five_minmomo >= 0;
    five_minneg = five_minmomo < 0;
    five_minup  = five_minmomo >= five_minmomo[1];
    five_mindn  = five_minmomo < five_minmomo[1];

    five_minPosUp = five_minpos and five_minup;
    five_minPosDn = five_minpos and five_mindn;
    five_minNegDn = five_minneg and five_mindn;
    five_minNegUp = five_minneg and five_minup;
    five_minAggregationPeriod = 1;
}
Else {
    five_minprice = 0;
    Kfive_min = 0;
    five_minmomo = 0;
    five_min_ExpAverage = 0;
    five_minpos = 0;
    five_minneg = 0;
    five_minup = 0;
    five_mindn = 0;
    five_minPosUp = 0;
    five_minPosDn = 0;
    five_minNegDn = 0;
    five_minNegUp = 0;
    five_minAggregationPeriod = 0;
}
AddLabel(FiveMinLabel and five_minAggregationPeriod, "5m", if five_minPosUp then globalColor("PosUp") else if five_minPosDn then globalColor("PosDn") else if five_minNegDn then globalColor("NegDn") else if five_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def four_minprice;
def Kfour_min;
def four_minmomo;
Def four_min_ExpAverage;
Def four_minpos;
Def four_minneg;
Def four_minup;
Def four_mindn;
Def four_minPosUp;
Def four_minPosDn;
Def four_minNegDn;
Def four_minNegUp;
Def four_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.four_min {
    four_minprice = close(period="4 Min");
    Kfour_min = (Highest(high(period="4 Min"), length) + Lowest(low(period="4 Min"), length)) /2 + ExpAverage(close(period="4 Min"), length);
    four_minmomo = Inertia(four_minprice- kfour_min / 2, length);
    four_min_ExpAverage = ExpAverage(close(period="4 Min"), Length);
    four_minpos = four_minmomo >= 0;
    four_minneg = four_minmomo < 0;
    four_minup  = four_minmomo >= four_minmomo[1];
    four_mindn  = four_minmomo < four_minmomo[1];

    four_minPosUp = four_minpos and four_minup;
    four_minPosDn = four_minpos and four_mindn;
    four_minNegDn = four_minneg and four_mindn;
    four_minNegUp = four_minneg and four_minup;
    four_minAggregationPeriod = 1;
}
Else {
    four_minprice = 0;
    Kfour_min = 0;
    four_minmomo = 0;
    four_min_ExpAverage = 0;
    four_minpos = 0;
    four_minneg = 0;
    four_minup = 0;
    four_mindn = 0;
    four_minPosUp = 0;
    four_minPosDn = 0;
    four_minNegDn = 0;
    four_minNegUp = 0;
    four_minAggregationPeriod = 0;
}
AddLabel(FourMinLabel and four_minAggregationPeriod, "4m", if four_minPosUp then globalColor("PosUp") else if four_minPosDn then globalColor("PosDn") else if four_minNegDn then globalColor("NegDn") else if four_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def three_minprice;
def Kthree_min;
def three_minmomo;
Def three_min_ExpAverage;
Def three_minpos;
Def three_minneg;
Def three_minup;
Def three_mindn;
Def three_minPosUp;
Def three_minPosDn;
Def three_minNegDn;
Def three_minNegUp;
Def three_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.three_min {
    three_minprice = close(period="3 Min");
    Kthree_min = (Highest(high(period="3 Min"), length) + Lowest(low(period="3 Min"), length)) /2 + ExpAverage(close(period="3 Min"), length);
    three_minmomo = Inertia(three_minprice- kthree_min / 2, length);
    three_min_ExpAverage = ExpAverage(close(period="3 Min"), Length);
    three_minpos = three_minmomo >= 0;
    three_minneg = three_minmomo < 0;
    three_minup  = three_minmomo >= three_minmomo[1];
    three_mindn  = three_minmomo < three_minmomo[1];

    three_minPosUp = three_minpos and three_minup;
    three_minPosDn = three_minpos and three_mindn;
    three_minNegDn = three_minneg and three_mindn;
    three_minNegUp = three_minneg and three_minup;
    three_minAggregationPeriod = 1;
}
Else {
    three_minprice = 0;
    Kthree_min = 0;
    three_minmomo = 0;
    three_min_ExpAverage = 0;
    three_minpos = 0;
    three_minneg = 0;
    three_minup = 0;
    three_mindn = 0;
    three_minPosUp = 0;
    three_minPosDn = 0;
    three_minNegDn = 0;
    three_minNegUp = 0;
    three_minAggregationPeriod = 0;
}
AddLabel(ThreeMinLabel and three_minAggregationPeriod, "3m", if three_minPosUp then globalColor("PosUp") else if three_minPosDn then globalColor("PosDn") else if three_minNegDn then globalColor("NegDn") else if three_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def two_minprice;
def Ktwo_min;
def two_minmomo;
Def two_min_ExpAverage;
Def two_minpos;
Def two_minneg;
Def two_minup;
Def two_mindn;
Def two_minPosUp;
Def two_minPosDn;
Def two_minNegDn;
Def two_minNegUp;
Def two_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.two_min {
    two_minprice = close(period="2 Min");
    Ktwo_min = (Highest(high(period="2 Min"), length) + Lowest(low(period="2 Min"), length)) /2 + ExpAverage(close(period="2 Min"), length);
    two_minmomo = Inertia(two_minprice- ktwo_min / 2, length);
    two_min_ExpAverage = ExpAverage(close(period="2 Min"), Length);
    two_minpos = two_minmomo >= 0;
    two_minneg = two_minmomo < 0;
    two_minup  = two_minmomo >= two_minmomo[1];
    two_mindn  = two_minmomo < two_minmomo[1];

    two_minPosUp = two_minpos and two_minup;
    two_minPosDn = two_minpos and two_mindn;
    two_minNegDn = two_minneg and two_mindn;
    two_minNegUp = two_minneg and two_minup;
    two_minAggregationPeriod = 1;
}
Else {
    two_minprice = 0;
    Ktwo_min = 0;
    two_minmomo = 0;
    two_min_ExpAverage = 0;
    two_minpos = 0;
    two_minneg = 0;
    two_minup = 0;
    two_mindn = 0;
    two_minPosUp = 0;
    two_minPosDn = 0;
    two_minNegDn = 0;
    two_minNegUp = 0;
    two_minAggregationPeriod = 0;
}
AddLabel(TwoMinLabel and two_minAggregationPeriod, "2m", if two_minPosUp then globalColor("PosUp") else if two_minPosDn then globalColor("PosDn") else if two_minNegDn then globalColor("NegDn") else if two_minNegUp then globalColor("NegUp") else globalColor("Neutral"));



def one_minprice;
def Kone_min;
def one_minmomo;
Def one_min_ExpAverage;
Def one_minpos;
Def one_minneg;
Def one_minup;
Def one_mindn;
Def one_minPosUp;
Def one_minPosDn;
Def one_minNegDn;
Def one_minNegUp;
Def one_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.Min {
    one_minprice = close(period="1 Min");
    Kone_min = (Highest(high(period="1 Min"), length) + Lowest(low(period="1 Min"), length)) /2 + ExpAverage(close(period="1 Min"), length);
    one_minmomo = Inertia(one_minprice- kone_min / 2, length);
    one_min_ExpAverage = ExpAverage(close(period="1 Min"), Length);
    one_minpos = one_minmomo >= 0;
    one_minneg = one_minmomo < 0;
    one_minup  = one_minmomo >= one_minmomo[1];
    one_mindn  = one_minmomo < one_minmomo[1];

    one_minPosUp = one_minpos and one_minup;
    one_minPosDn = one_minpos and one_mindn;
    one_minNegDn = one_minneg and one_mindn;
    one_minNegUp = one_minneg and one_minup;
    one_minAggregationPeriod = 1;
}
Else {
    one_minprice = 0;
    Kone_min = 0;
    one_minmomo = 0;
    one_min_ExpAverage = 0;
    one_minpos = 0;
    one_minneg = 0;
    one_minup = 0;
    one_mindn = 0;
    one_minPosUp = 0;
    one_minPosDn = 0;
    one_minNegDn = 0;
    one_minNegUp = 0;
    one_minAggregationPeriod = 0;
}
AddLabel(OneMinLabel and one_minAggregationPeriod, "1m", if one_minPosUp then globalColor("PosUp") else if one_minPosDn then globalColor("PosDn") else if one_minNegDn then globalColor("NegDn") else if one_minNegUp then globalColor("NegUp") else globalColor("Neutral"));
Thank you this exactly what I was looking for
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
480 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top