Try to create a buy signal for equities when the by signal is triggered for /ES (E-mini S&P 500)

rengagopal

Member
VIP
Dear all,

I have a "Current" Buy Scenario with bunch of buy conditions.

Example :
if close > Hull 32 and
Hull 32 > Hull 128 and
Hull 128 > Hull 256 and etc.

I would like to check whether these Buy conditions are true for /ES (E-mini S&P 500) and for the equity (IBM) >>>>>> IN ONE THINKSCRIPT IN "IBM" CHART <<<<<< . If YES then change background color for chart IBM, then I can buy IBM.

I hope I explained this clearly.

Thank your your time . Please help me.
 
Solution
You can reference a different symbol this way:

Code:
declare upper;

input ticker = "/ES";

def ticker_series = close(symbol = ticker);

def HMA32 = HullMovingAvg(price = ticker_series, length = 32);
def HMA64 = HullMovingAvg(price = ticker_series, length = 64);
def HMA128 = HullMovingAvg(price = ticker_series, length = 128);
def HMA256 = HullMovingAvg(price = ticker_series, length = 256);

def CONDITION = if
ticker_series > HMA32 and
HMA32 > HMA128 and
HMA128 > HMA256 then 1 else 0;

addLabel(yes, if CONDITION == 1 then "  HMA Condition MET for " + ticker + "   " else "  HMA Condition NOT met for " + ticker + "   ", if condition == 1 then color.green else color.red);

AddLabel(yes, "  " + ticker + " currently at: " + ticker_series + "...
You can reference a different symbol this way:

Code:
declare upper;

input ticker = "/ES";

def ticker_series = close(symbol = ticker);

def HMA32 = HullMovingAvg(price = ticker_series, length = 32);
def HMA64 = HullMovingAvg(price = ticker_series, length = 64);
def HMA128 = HullMovingAvg(price = ticker_series, length = 128);
def HMA256 = HullMovingAvg(price = ticker_series, length = 256);

def CONDITION = if
ticker_series > HMA32 and
HMA32 > HMA128 and
HMA128 > HMA256 then 1 else 0;

addLabel(yes, if CONDITION == 1 then "  HMA Condition MET for " + ticker + "   " else "  HMA Condition NOT met for " + ticker + "   ", if condition == 1 then color.green else color.red);

AddLabel(yes, "  " + ticker + " currently at: " + ticker_series + ",   HMA32 currently at: " + HMA32 + "   ", color.gray);

note that it is far easier for ToS to create the series and store them as variables than to try to recreate the series each time it needs to do a calculation against it... that's why all of the series and averages are defined before the condition is calculated.

hope that helps,
-mashume

P.S. the second label was a sanity check to make sure that I was getting realistic values in the series and hma variables... you may delete it if you find it unnecessary.

Also, this will only work on time charts. You cannot do this sort of thing on tick or renko charts.
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
503 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.
Back
Top