S

#### sierioiza

##### New member

My first post here. I tweaked the DMI script on TOS to basically do what John Carter's 10x bars do (yay me! almost no experience with thinkscript).

Here is what I got.

I tried replacing his script MySqueeze {the whole script} with 10x bars script at the top, but TOS is asking for at least one plot, and the Squeeze labels only used 2 colors--I need three colors. It also showed error with dSQ, and I had no idea how it wanted me to correct it. If anyone could help me figure out how to use my 10x bars script to create MTF label study I would highly appreciate that. Thank you!

Here is what I got.

Code:

```
input length = 14;
input averageType = AverageType.WILDERS;
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;
def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
def ADX = MovingAverage(averageType, DX, length);
declare upper;
declare once_per_bar;
AssignPriceColor(if "DI+" > "DI-" and ADX > 20 then Color.GREEN
else if "DI+" < "DI-" and ADX > 20 then Color.RED
else Color.YELLOW);
The next thing I want to accomplish is to use this study to create multi-time frame labels. I have Mobius's MTF label for TTM_Squeeze.
input dStr =aggregationPeriod.DAY;
script MySqueeze{
def length = 20;
def AtrMult = 2.0;
def SdMult = 2.0;
input period = aggregationPeriod.DAY;;
def valueClose = close(period = period);
def valueHigh = high(period = period);
def valueLow = low(period = period);
def SD = StDev(valueClose, length);
def Avg = Average(valueClose, length);
def ATR = Average(TrueRange(valueHigh, valueClose, valueLow), length);
def SDup = Avg + (SdMult * SD);
def ATRup = Avg + (AtrMult * ATR);
plot Squeeze = if SDup < ATRup
then 1
else 0;
}
def dSQ= MySqueeze(dStr);
# AddLabel(yes, dStr, if dSQ
# then Color.RED else Color.GREEN); # display label red if has squeeze
AddLabel(yes, if dStr == aggregationPeriod.MONTH then "M"
else
if dStr == aggregationPeriod.WEEK then "W"
else
if dStr == aggregationPeriod.FOUR_DAYS then "4D"
else
if dStr == aggregationPeriod.THREE_DAYS then "3D"
else
if dStr == aggregationPeriod.TWO_DAYS then "2D"
else
if dStr == aggregationPeriod.DAY then "D"
else
if dStr == aggregationPeriod.FOUR_HOURS then "4H"
else
if dStr == aggregationPeriod.TWO_HOURS then "2H"
else
if dStr == aggregationPeriod.HOUR then "1H"
else
if dStr == aggregationPeriod.THIRTY_MIN then "30m"
else
if dStr == aggregationPeriod.TWENTY_MIN then "20m"
else
if dStr == aggregationPeriod.FIFTEEN_MIN then "15m"
else
if dStr == aggregationPeriod.TEN_MIN then "10m"
else
if dStr == aggregationPeriod.FIVE_MIN then "5m"
else
if dStr == aggregationPeriod.FOUR_MIN then "4m"
else
if dStr == aggregationPeriod.THREE_MIN then "3m"
else
if dStr == aggregationPeriod.TWO_MIN then "2m"
else
if dStr == aggregationPeriod.MIN then "1m"
else "", if dSQ
then Color.RED else Color.GREEN);
```

Last edited by a moderator: