Reference SPY condition as a different Ticker condition

EP_Trader

New member
I am trying to put totether a an arrow up to buy which works fine with all my other condition, however what I would like to add is when spy 1 min 8EMA > 21 Spy 1 min EMA then that condition is satisifed which I have defined as 'spybullish'. Every time I try to add the condition I don't get an error but just no signal ever once I add that conditoin, when clearly the SPY 8EMA SPY 21 EMA. Any help I can get here with this? THis below is what I have. Would greatly appreciate.

Input ticker = “SPY”;
input spylength1 = 8;
input spylength2 = 21;
input aggr = AggregationPeriod.min;
def c = close(ticker,period = aggr);

def SPYFast = ExpAverage(c, spylength1);

def SPYSlow = ExpAverage(c, spylength2);

Def spybearish = SPYFast < SPYslow;

Def spybullish = SPYFast >SPYslow;

#then a bunch of other code that works

plot crossUP = if spybullish and ATRTrailready and SlowStochReady and macdready then plotLow else double.NaN ;
 
Solution
I am trying to put totether a an arrow up to buy which works fine with all my other condition, however what I would like to add is when spy 1 min 8EMA > 21 Spy 1 min EMA then that condition is satisifed which I have defined as 'spybullish'. Every time I try to add the condition I don't get an error but just no signal ever once I add that conditoin, when clearly the SPY 8EMA SPY 21 EMA. Any help I can get here with this? THis below is what I have. Would greatly appreciate.

Input ticker = “SPY”;
input spylength1 = 8;
input spylength2 = 21;
input aggr = AggregationPeriod.min;
def c = close(ticker,period = aggr);

def SPYFast = ExpAverage(c, spylength1);

def SPYSlow = ExpAverage(c, spylength2);

Def spybearish = SPYFast < SPYslow...
I am trying to put totether a an arrow up to buy which works fine with all my other condition, however what I would like to add is when spy 1 min 8EMA > 21 Spy 1 min EMA then that condition is satisifed which I have defined as 'spybullish'. Every time I try to add the condition I don't get an error but just no signal ever once I add that conditoin, when clearly the SPY 8EMA SPY 21 EMA. Any help I can get here with this? THis below is what I have. Would greatly appreciate.

Input ticker = “SPY”;
input spylength1 = 8;
input spylength2 = 21;
input aggr = AggregationPeriod.min;
def c = close(ticker,period = aggr);

def SPYFast = ExpAverage(c, spylength1);

def SPYSlow = ExpAverage(c, spylength2);

Def spybearish = SPYFast < SPYslow;

Def spybullish = SPYFast >SPYslow;

#then a bunch of other code that works

plot crossUP = if spybullish and ATRTrailready and SlowStochReady and macdready then plotLow else double.NaN ;

is your chart set to 1 minute?
can't specify a 2nd agg time smaller than the chart time.

there is no need to specify 1 minute 2nd aggregation. 1 minute is the smallest time interval.

add this to the end of your code to verify spy formulas.
if bullish, then green bubble above candle.
if bearish, then red bubble below candle.

Code:
def na = double.nan;
input test_bubble1 = yes;

addchartbubble(
 test_bubble1 and (spybullish or spybearish),
(if spybullish then high*1.002 else if spybearish then low*0.998 else close),
(if spybullish then "bull" else if spybearish then "bear" else "-"),
(if spybullish then color.green else if spybearish then color.red else color.gray), 
(if spybullish then "yes" else if spybearish then "no" else "no")
 );
 
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
416 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