How to determine biggest EMA difference of the trading day

Hello. I have been doing ongoing research with the Exponential Moving Average. (Accidentally wrote Expected)

Is there a way to determine what point of the day had the biggest difference between specific averages? I have been doing this manually and wanted to see if I could make it any quicker.

@generic was nice enough to share a EMA distance indicator, but I am trying to evolve my theory and have moved to studying this a little more deeply.
 
Last edited:

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

first define your EMA difference as a variable.Ex:
def EMADiff = EMA1 - EMA2;
and then set the days on your chart to 1D or Today(end of last trading session to current (I think lol)).
Then make use of the function HighestAll(EMADIff) which will return the value of the highest EMADiff in the available data.

Hope this helps :)
 
I know this is way off, but this is where I am at. Really new at this, but giving it a shot.

Code:
input price = close;
input length_1 = 3;
input length_2 = 9;
input AverageType = AverageType.EXPONENTIAL;

def MA_1 = MovingAverage(AverageType, price, length_1);
def MA_2 = MovingAverage(AverageType, price, length_2);

def MA_delta = Round(MA_1 - MA_2, 2);

def HighestAll = MA_delta

AddLabel(yes, HighestAll, if HighestAll > 0 then Color.GREEN else Color.RED);
 
@ProfessorAR15 Combined 1 and 3. New high and low are plotted as histograms and they only show for the current day and during RTH. 2) The original script already had average type as a input so just change it but I separated them into if you wanted different types for both.

Code:
declare lower;

input price = close;
input length_1 = 3;
input length_2 = 9;
input AverageType1 = AverageType.EXPONENTIAL;
input AverageType2 = AverageType.EXPONENTIAL;

def nan = Double.NaN;
def RTH_start = 0930;
def RTH_end = 1600;
def RTH = SecondsFromTime(RTH_start) >= 0 and
          SecondsTillTime(RTH_end) >=0;
def today = getday() == getlastDay();
def MA_1 = MovingAverage(AverageType1, price, length_1);
def MA_2 = MovingAverage(AverageType2, price, length_2);

plot zero = if !isNaN(close) then 0 else nan;
zero.HideBubble();
zero.HideTitle();
plot MA_delta = MA_1 - MA_2;

rec delta_high = compoundValue(1, if((MA_delta > delta_high[1] and RTH and today), MA_delta, delta_high[1]), MA_delta);
rec delta_low = compoundValue(1, if((MA_delta < delta_low[1] and RTH and today), MA_delta, delta_low[1]), MA_delta);

def high = delta_high > delta_high[1];
def low = delta_low < delta_low[1];

plot newhigh = if high then delta_high else nan;
newhigh.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot newlow = if low then delta_low else nan;
newlow.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

AddLabel(yes, Round(delta_high, 2), color.GREEN);
AddLabel(yes, Round(delta_low, 2), color.RED);
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
466 Online
Create Post

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