Need help coding moving avg bounce signal

Options Trader

New member
Anyone able to provide code for price bouncing off of moving average? See attached photo

Signal would be when price has retraced to MA50 (touched it) and then crosses the second MA10 and continues in the trend direction. Willing to pay modest fee!

Thanks for all considerations.

@Options Trader :

Let me know if this fits the bill. You were a bit short on some specifics, so I made a few guesses. There is nothing about continuing in the trend direction in this. I code for fun, but if it's what you wanted, feel free to make a donation to the COVID-19 charity of your choice in your area for whatever amount you'd have given me.

Trade Healthy!

I looked at /ES for the last year, and it gives a few good signals, but a fair bit of noise when the market is not trending.

# Moving Average Bounce
# Coded per request on UseThinkScript
# V. 2020-03-23 V1
# by mashume

input fast_length = 10;
input slow_length = 50;
input price = CLOSE;

input MovingAverage = {default "EMA", "SMA", "WMA", "HMA"};

plot fast_MA;
switch (MovingAverage) {
case SMA:
    fast_MA = simpleMovingAvg(price, length = fast_length);
case WMA:
    fast_MA = wma(price, length = fast_length);
case HMA:
    fast_MA = HullMovingAvg(price = price, length = fast_length);
    fast_MA = MovAvgExponential(price, length = fast_length);

plot slow_MA;
switch (MovingAverage) {
case SMA:
    slow_MA = simpleMovingAvg(price, length = slow_length);
case WMA:
    slow_MA = wma(price, length = slow_length);
case HMA:
    slow_MA = HullMovingAvg(price = price, length = slow_length);
    slow_MA = MovAvgExponential(price, length = slow_length);

def phase1 = if low < slow_MA and low[1] > slow_MA[1] then -1 else if high > slow_MA and high[1] < slow_MA[1]  then 1 else double.NaN;
def phase2 = if close > fast_MA and close[1] < fast_MA[1] then 1 else if close < fast_MA and close[1] > fast_MA[1] then -1 else double.NaN;

# turn on these plots if you want to see where each of the phase conditions is true.
# Make them boolean dots or some such
# plot p1 = if phase1 == 1 then high else if phase1 == -1 then low else double.nan;
# plot p2 = if phase2 == 1 then high else if phase2 == -1 then low else double.nan;

plot buy = if (! isnan(phase1[1]) or! isnan( phase1[2]) or ! isnan( phase1[3])) and phase2 == 1 then LOW else Double.NaN;

plot sell = if (! isnan(phase1[1]) or! isnan( phase1[2]) or ! isnan( phase1[3])) and phase2 == -1 then HIGH else Double.NaN;

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

Thank your for your work. I did not expect such a quick response. I am away from being able to test this in my charts but will let you know soon if this is what i was looking for. Regardless, it was very kind of you to take the time on my behalf.
Seeing this for the first time, I like the theory behind this indicator. My go to is the 34EMA on the 5min and 30min so its cool to see the tags marked, but I think for this type of indicator the KAMA should be seriously considered as the "slow" MA. I will tool around with adding it, but if someone is bored they may beat me to it haha

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
340 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.