You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter JJP
- Start date

I Have 6 EMA, I'm trying to get the highest EMA and Lowest EMA) and subtract the two. Hope this helps you understand better.

Thanks

Thanks

why dont you just grab the highest MA and lowest MA and use the middle? example 1MA and 100MA so just use the 50MA.

@JJP Here are indicators and a scan, based on what you described.

Upper arrows -

Code:

```
input n1 = 3;
input n2 = 35;
def EMAdiff = (ExpAverage(close, n1) - ExpAverage(close, n2)) / close;
plot CrossAbove = EMAdiff crosses above 0;
CrossAbove.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
plot CrossBelow = EMAdiff crosses below 0;
CrossBelow.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
```

Lower histogram -

Code:

```
input n1 = 3;
input n2 = 35;
plot EMAdiff = (ExpAverage(close, n1) - ExpAverage(close, n2)) / close;
EMAdiff.AssignValueColor(if EMAdiff > 0 then Color.GREEN else Color.RED);
EMAdiff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
```

Scan for arrow signal -

Code:

```
# uncomment the plot you want to scan for
input n1 = 3;
input n2 = 35;
def EMAdiff = (ExpAverage(close, n1) - ExpAverage(close, n2)) / close;
#plot CrossAbove = EMAdiff crosses above 0;
plot CrossBelow = EMAdiff crosses below 0;
```

Good trading to you!

input n1 = 3

input n1 = 5

input n1 = 8

input n1 = 10

input n1 = 12

input n1 = 15

input n1 = 30

input n1 = 35

I'm trying to get the moving avg with the highest value and the lowest value, not the highest and lowest moving avg if that make sense. What I'm asking for may not be possible or very complicated. I figured I would give it a try.

Hope I'm not working you all to death I wish I was a fast learner.

Please forgive my ignorance,

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/Min

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/Max

This what I have come up with. I'm no pro at this, just a baby trying to learn how to crawl.@JJP Don't really understand what plot a symbol means but you can try using lowest() and compare with current value.

Code:

```
#EMA
declare upper;
PLOT EMA1 = ExpAverage(CLOSE,3);
PLOT EMA2 = ExpAverage(CLOSE,5);
PLOT EMA3 = ExpAverage(CLOSE,8);
PLOT EMA4 = ExpAverage(CLOSE,10);
PLOT EMA5 = ExpAverage(CLOSE,12);
PLOT EMA6 = ExpAverage(CLOSE,15);
PLOT EMA7 = ExpAverage(CLOSE,30);
PLOT EMA8 = ExpAverage(CLOSE,35);
PLOT EMA9 = ExpAverage(CLOSE,40);
PLOT EMA10 = ExpAverage(CLOSE,45);
PLOT EMA11 = ExpAverage(CLOSE,50);
PLOT EMA12 = ExpAverage(CLOSE,60);
# finds max EMA out of the plot
def MAX12 = max(EMA1,EMA2);
def MAX34 = max(EMA3,EMA4);
def MAX56 = max(EMA5,EMA6);
def MAX78 = max(EMA7,EMA8);
def MAX910 = max(EMA9,EMA10);
def MAX1112 = max(EMA11,EMA12);
def MAX1234 = max(MAX12,MAX34);
def MAX5678 = max(MAX56,MAX78);
def MAX9101112 = max(MAX910,MAX1112);
def MAX12345678 = max(MAX1234,MAX5678);
def HMA = max(MAX9101112,MAX12345678);
## finds min EMA out of the plot
def MIN12 = min(EMA1,EMA2);
def MIN34 = min(EMA3,EMA4);
def MIN56 = min(EMA5,EMA6);
def MIN78 = min(EMA7,EMA8);
def MIN910 = min(EMA9,EMA10);
def MIN1112 = min(EMA11,EMA12);
def MIN1234 = min(MIN12,MIN34);
def MIN5678 = min(MIN56, MIN78);
def MIN9101112 = min(MIN910,MIN1112);
def MIN12345678 = min(MIN1234,MIN5678);
def LMA = min(MIN9101112,MIN12345678);
# Calculate the Compression Ratio
def pressRatio =(HMA-LMA)/close;
#Finds Lowest pressRatio over last 1008 days
input length = 1008;
def lowpressRatio = GetMinValueOffset (pressRatio, length);
# If lowpressRatio lowest out of 1008 show symbol
plot FourYearLow = lowpressRatio is true;
FourYearLow.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
```

Code:`#PressRatio #Joriginal by JP-modified by Sleepyz declare upper; #EMA def EMA1 = ExpAverage(close, 3); def EMA2 = ExpAverage(close, 5); def EMA3 = ExpAverage(close, 8); def EMA4 = ExpAverage(close, 10); def EMA5 = ExpAverage(close, 12); def EMA6 = ExpAverage(close, 15); def EMA7 = ExpAverage(close, 30); def EMA8 = ExpAverage(close, 35); def EMA9 = ExpAverage(close, 40); def EMA10 = ExpAverage(close, 45); def EMA11 = ExpAverage(close, 50); def EMA12 = ExpAverage(close, 60); # finds max EMA out of the plot def HMA = Max(EMA1, Max(EMA2, Max(EMA3, Max(EMA4, Max(EMA5, Max(EMA6, Max(EMA7, Max(EMA8, Max(EMA9, Max(EMA10, Max(EMA11, EMA12))))))))))); ## finds min EMA out of the plot def LMA = Min(EMA1, Min(EMA2, Min(EMA3, Min(EMA4, Min(EMA5, Min(EMA6, Min(EMA7, Min(EMA8, Min(EMA9, Min(EMA10, Min(EMA11, EMA12))))))))))); input show_debug = yes; AddLabel(show_debug, "HMA: " + HMA); AddLabel(show_debug, "LMA: " + LMA); AddLabel(show_debug, "EMAs: " + EMA1 + " " + EMA2 + " " + EMA3 + " " + EMA4 + " " + EMA5 + " " + EMA6 + " " + EMA7 + " " + EMA8 + " " + EMA9 + " " + EMA10 + " " + EMA11 + " " + EMA12); # Calculate the Compression Ratio def pressRatio = (HMA - LMA) / close; #Finds Lowest pressRatio over last 1008 days or length input length = 1008; def lastbar = (if !isnan(close) and IsNaN(close[-1]) then BarNumber() else Double.NaN); AddLabel(show_debug, lastbar + " " + (HighestAll(lastbar)-length)); def lowpressRatio = compoundvalue(1, if barnumber()<HighestAll(lastbar) - length then double.nan else if barnumber()>=HighestAll(lastbar) - length then pressRatio else if !isnan(lowpressratio[1]) and pressRatio < lowpressRatio[1] then pressRatio else lowpressRatio[1], pressratio); # If lowpressRatio lowest out of 1008 or length plot FourYearLow = pressRatio == LowestAll(lowpressRatio) ; FourYearLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);`

It just another way to find a squeeze.looks pretty good, i dont know what your doing but looks good

Both, but Looks like sleepyz fix all the bugs and it's working correctly now. Now I'm going to have to study "@JJP Did you want help with the code or are you posting it so other people can use it?

Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|

Create labels with high & low price of current candle | Questions | 4 | ||

F | Calculate the cost from High to Low by volume? | Questions | 0 | |

High Low Bubble in Chart programatically | Questions | 4 | ||

N | Help with a daily high low watchlist column | Questions | 3 | |

K | Script for (open=high) and (open=low) | Questions | 11 |