
https://tosindicators.com/backtesters/ttm-squeeze-histogram
Code:
input consecutiveHistogramBars = 7;
input RSIOverboughtVal = 60;
input RSIOversoldVal = 40;
input longEntries = yes;
input shortEntries = yes;
def histogram = TTM_Squeeze().histogram;
#Cyan, Blue, Yellow and Red Histogram Bar Definitions
def cyan = histogram > histogram[1] and histogram > 0;
def blue = histogram < histogram[1] and histogram > 0;
def red = histogram < histogram[1] and histogram < 0;
def yellow = histogram > histogram[1] and histogram < 0;
#Consecutive Momentum Histogram Bars
def minCyanBars = Sum(cyan, consecutiveHistogramBars) >= consecutiveHistogramBars;
def minRedBars = Sum(red, consecutiveHistogramBars) >= consecutiveHistogramBars;
#Momentum Shifts in Histogram
def momoDown = minCyanBars[1] and blue;
def momoUp = minRedBars[1] and yellow;
#RSI
def RSIOverbought = RSI() > RSIOverboughtVal;
def RSIOversold = RSI() < RSIOversoldVal;
AddOrder(OrderType.Buy_To_Open, longEntries and momoUp and RSIOversold, open[-1]);
AddOrder(OrderType.Sell_To_Close, histogram < histogram[1], open[-1]);
AddOrder(OrderType.Sell_To_Open, shortEntries and momoDown and RSIOverbought, open[-1]);
AddOrder(OrderType.Buy_To_Close, histogram > histogram[1], open[-1]);