SPX Trading Strategy for ThinkorSwim

Status
Not open for further replies.
Yesterday I started paper trading this strategy. Should have gone live! :p

Was wondering what exit signals you guys used with a slow grind move like that

Also, do you guys take the signal right away as long as there is a gap between zero line and white dot, or do you wait for that 10 minute candle to close?
 
Last edited:
Yesterday I started paper trading this strategy. Should have gone live! :p

Was wondering what exit signals you guys used with a slow grind move like that

Also, do you guys take the signal right away as long as there is a gap between zero line and white dot, or do you wait for that 10 minute candle to close?
Once the dot crosses...over or under....make sure the dot didn't have a sideways direction of movement. You want it to be obvious its either going up or down. Then if you get in immediately.....set your buy limits lower since the price is still trying to "settle in".
 
do you usually use the opening price
Great question....no...use the current price. and you can keep doing this throughout the day....updating the current price to see what the next targets are. I think you'll need to wait to see if it does the first one and then update it again. I'm testing that logic now. Right now I have $3888 in there and it says that if it breaks 3890, the next probability is for it to go to $3904-$3919.
And if it goes below $3875, the next probability is for it to go to $3861-$3845
 
Last edited:
BTW for the SPX strategy, I added the condition of the trigger with SMA 89... if above go long and if below go short... that would have avoided the trade that happened this morning...here is the updated code: it will reduce the number of trades though...

Code:
declare upper;

input price = close;
input SMAFastLength = 3;
input SMASlowLength = 9;
input SMA89 = 89;
input BBlength = 30;
input BBNum_Dev = 0.8;
input BBCrossInBars = 3;
input BBCrossDistance = 1;
input BBCrossDistance1 = -1;
input BBCrossDistance2 = 1;
input MACDfastLength = 8;
input MACDslowLength = 16;
input positionSize = 10000.0;
input entryPrice = close;
input entryPriceOffset = 0;
input MACDLength = 36;
input ERGODICLongLength = 2;
input ERGODICShortLength = 10;
input ERGODICSignalLength = 36;
input ERGODICAverageType = {"SIMPLE", default "EXPONENTIAL", "WEIGHTED", "WILDERS", "HULL"};
input ShowWarnArrows = yes;
input ShowStatistics = yes;
input ProfitDelta = 1.0;


# Check for 10min chart
Assert(GetAggregationPeriod() == AggregationPeriod.TEN_MIN, "Incorrect Chart Time, use 10m");

# MACD
def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);
def MACD_Direction = if MACD_Data > MACD_Data[1] then 1 else -1;
def MACD_Down = if MACD_Data < MACD_Data[1] then 1 else -1;
def MACD_up = if MACD_Data > MACD_DATA[1] then 1 else -1;

# Ergodic
def Ergodic_Data = ErgodicOsc("long length" = ERGODICLongLength, "short length" = ERGODICShortLength, "signal length" = ERGODICSignalLength, "average type" = ERGODICAverageType).ErgodicOsc;

# SMAs
def SMA_Fast = SimpleMovingAvg(price, SMAFastLength);
def SMA_Slow = SimpleMovingAvg(price, SMASlowLength);
def SMA_89 = SimpleMovingAvg(price, SMA89);

# Signals
def buySignal = SMA_Fast > SMA_Slow and close > SMA_89 and Ergodic_Data > 0 and MACD_Direction == 1 and MACD_Data >= BBCrossDistance and MACD_Data crosses above 0 within BBCrossInBars bars;
def sellSignal = SMA_Fast < SMA_Slow and close < SMA_89 and Ergodic_Data < 0 and MACD_Direction == -1 and MACD_Data <= -BBCrossDistance and MACD_Data crosses below 0 within BBCrossInBars bars;

addOrder(OrderType.BUY_To_Open,buySignal and !buySignal[1],  entryPrice[entryPriceOffset], round(positionSize / close, 0), color.gREEN, color.gREEN, name="LE");
addorder(orderType.SELL_to_close,MACD_Direction == -1 , entryPrice[entryPriceOffset], tickColor=color.reD, arrowColor=color.reD, name="LX");

addOrder(OrderType.SELL_To_Open, sellSignal and !sellSignal[1], entryPrice[entryPriceOffset], round(positionSize / close, 0), color.dark_gREEN, color.dark_gREEN, name="SE");
addorder(orderType.BUY_to_close,MACD_Direction == 1, entryPrice[entryPriceOffset], tickColor=color.dark_reD,arrowColor=color.dark_reD, name="SX");

# Plots
plot buy = buySignal and !buySignal[1];
buy.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buy.setDefaultColor(Color.GREEN);
buy.setLineWeight(3);



plot sell = sellSignal and !sellSignal[1];
sell.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sell.setDefaultColor(Color.RED);
sell.setLineWeight(3);



# Alerts
Alert(buy, "Buy", Alert.BAR, Sound.Ring);
Alert(sell, "Sell", Alert.BAR, Sound.Ring);

# PnL
def entryPrice1 = if (buySignal and !buySignal[1]) or (sellSignal and !sellSignal[1]) then close else entryPrice1[1];
def profitTarget = if buySignal and !buySignal[1] then entryPrice + ProfitDelta else if sellSignal and !sellSignal[1] then entryPrice - ProfitDelta else profitTarget[1];
def orderDir = if BarNumber() == 1 then 0
               else if orderDir[1] == 0 and buySignal and !buySignal[1] then 1
               else if orderDir[1] == 1 and (MACD_Direction != 1 or close crosses above profitTarget) then 0
               else if orderDir[1] == 0 and sellSignal and !sellSignal[1] then -1
               else if orderDir[1] == -1 and (MACD_Direction != -1 or close crosses below profitTarget) then 0
               else orderDir[1];

def isOrder = if IsNaN(orderDir) then no else orderDir crosses 0;
def orderCount = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then orderCount[1] + 1 else orderCount[1], 0);

def orderWinners = if BarNumber() == 1 then 0
                    else if orderDir[1] == 1 and orderDir == 0 then
                        if close >= profitTarget[1] then orderWinners[1] + 1 else orderWinners[1]
                    else if orderDir[1] == -1 and orderDir == 0 then
                        if close <= profitTarget[1] then orderWinners[1] + 1 else orderWinners[1]
            else orderWinners[1];
def winRate = orderWinners / orderCount;

AddLabel(ShowStatistics, "Ergo Strategy", Color.Cyan);
AddLabel(ShowStatistics, "" + orderCount + " Trades | " + AsPercent(winRate), if winRate > 0.5 then Color.GREEN else Color.RED);
 
Last edited:
How did you guys handle this morning? That's a big move in the opposite direction to stomach.
QIdbDdQ.png
 
GANN nailed AMZN this morning. At 10am I used that current price of $3158, it shows that if it goes below $3150 that the next targets are $3137-$3123....well it went below $3150 and then went as low as $3133. :unsure::unsure::unsure:
 
How did you guys handle this morning? That's a big move in the opposite direction to stomach.
QIdbDdQ.png
If you look close, the red dot went below at the open and not at 9:40....I've mentioned in several posts to not get in if it breaks below or above at the open...only get in if it happens 10mins after the open. Prime example was this morning of the 9:30 no go.
 
If you look close, the red dot went below at the open and not at 9:40....I've mentioned in several posts to not get in if it breaks below or above at the open...only get in if it happens 10mins after the open. Prime example was this morning of the 9:30 no go.
I headed your advice and now i do not get in until 940
 
Great question....no...use the current price. and you can keep doing this throughout the day....updating the current price to see what the next targets are. I think you'll need to wait to see if it does the first one and then update it again. I'm testing that logic now. Right now I have $3888 in there and it says that if it breaks 3890, the next probability is for it to go to $3904-$3919.
And if it goes below $3875, the next probability is for it to go to $3861-$3845
Interesting find! Thanks and please keep us posted on the logic.

Also saw there was a put signal @ 0940 EST. Although all criteria was met, this trade required patience and some draw down. Almost bailed with a small loss, but decided to give a little more patience and technical analysis. The SMA's had a "pinch" to slight cross, but trend was down. Opened a 5 minute chart and it appeared a small A,B,C pattern was beginning to form between 0950 and 1030, shortly after the SMA pinch. Was nice seeing the trade go from negative to positive. Took the scalp and moved on. Thanks again!
 
If you look close, the red dot went below at the open and not at 9:40....I've mentioned in several posts to not get in if it breaks below or above at the open...only get in if it happens 10mins after the open. Prime example was this morning of the 9:30 no go.
Got it. I will update the study to reflect that. Any rules for EOD as well?
 
Got it. I will update the study to reflect that. Any rules for EOD as well?
Since January 4th....There haven't been many successful looking trades that begins after 3:00ET...way too choppy or short. I only get in if its prior to 3:00 and will stay, if need be, if it carries into the 3:00 hour. after 3:00 is very chancy since you don't have much time to wait it out to see if it recovers before close.
 
Interesting find! Thanks and please keep us posted on the logic.

Also saw there was a put signal @ 0940 EST. Although all criteria was met, this trade required patience and some draw down. Almost bailed with a small loss, but decided to give a little more patience and technical analysis. The SMA's had a "pinch" to slight cross, but trend was down. Opened a 5 minute chart and it appeared a small A,B,C pattern was beginning to form between 0950 and 1030, shortly after the SMA pinch. Was nice seeing the trade go from negative to positive. Took the scalp and moved on. Thanks again!
the red dot crossed below at 9:30....not 9:40. Thats why there was a struggle...its best to only get in one if it breaks above or below at 9:40. Look back in time and you'll see what I'm speaking of. Its a rare successful trade if it breaks at 9:30.
 
BTW for the SPX strategy, I added the condition of the trigger with SMA 89... if above go long and if below go short... that would have avoided the trade that happened this morning...here is the updated code: it will reduce the number of trades though...

declare upper;

input price = close;
input SMAFastLength = 3;
input SMASlowLength = 9;
input SMA89 = 89;
input BBlength = 30;
input BBNum_Dev = 0.8;
input BBCrossInBars = 3;
input BBCrossDistance = 1;
input BBCrossDistance1 = -1;
input BBCrossDistance2 = 1;
input MACDfastLength = 8;
input MACDslowLength = 16;
input positionSize = 10000.0;
input entryPrice = close;
input entryPriceOffset = 0;
input MACDLength = 36;
input ERGODICLongLength = 2;
input ERGODICShortLength = 10;
input ERGODICSignalLength = 36;
input ERGODICAverageType = {"SIMPLE", default "EXPONENTIAL", "WEIGHTED", "WILDERS", "HULL"};
input ShowWarnArrows = yes;
input ShowStatistics = yes;
input ProfitDelta = 1.0;


# Check for 10min chart
Assert(GetAggregationPeriod() == AggregationPeriod.TEN_MIN, "Incorrect Chart Time, use 10m");

# MACD
def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);
def MACD_Direction = if MACD_Data > MACD_Data[1] then 1 else -1;
def MACD_Down = if MACD_Data < MACD_Data[1] then 1 else -1;
def MACD_up = if MACD_Data > MACD_DATA[1] then 1 else -1;

# Ergodic
def Ergodic_Data = ErgodicOsc("long length" = ERGODICLongLength, "short length" = ERGODICShortLength, "signal length" = ERGODICSignalLength, "average type" = ERGODICAverageType).ErgodicOsc;

# SMAs
def SMA_Fast = SimpleMovingAvg(price, SMAFastLength);
def SMA_Slow = SimpleMovingAvg(price, SMASlowLength);
def SMA_89 = SimpleMovingAvg(price, SMA89);

# Signals
def buySignal = SMA_Fast > SMA_Slow and close > SMA_89 and Ergodic_Data > 0 and MACD_Direction == 1 and MACD_Data >= BBCrossDistance and MACD_Data crosses above 0 within BBCrossInBars bars;
def sellSignal = SMA_Fast < SMA_Slow and close < SMA_89 and Ergodic_Data < 0 and MACD_Direction == -1 and MACD_Data <= -BBCrossDistance and MACD_Data crosses below 0 within BBCrossInBars bars;

addOrder(OrderType.BUY_To_Open,buySignal and !buySignal[1], entryPrice[entryPriceOffset], round(positionSize / close, 0), color.gREEN, color.gREEN, name="LE");
addorder(orderType.SELL_to_close,MACD_Direction == -1 , entryPrice[entryPriceOffset], tickColor=color.reD, arrowColor=color.reD, name="LX");

addOrder(OrderType.SELL_To_Open, sellSignal and !sellSignal[1], entryPrice[entryPriceOffset], round(positionSize / close, 0), color.dark_gREEN, color.dark_gREEN, name="SE");
addorder(orderType.BUY_to_close,MACD_Direction == 1, entryPrice[entryPriceOffset], tickColor=color.dark_reD,arrowColor=color.dark_reD, name="SX");

# Plots
plot buy = buySignal and !buySignal[1];
buy.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buy.setDefaultColor(Color.GREEN);
buy.setLineWeight(3);



plot sell = sellSignal and !sellSignal[1];
sell.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sell.setDefaultColor(Color.RED);
sell.setLineWeight(3);



# Alerts
Alert(buy, "Buy", Alert.BAR, Sound.Ring);
Alert(sell, "Sell", Alert.BAR, Sound.Ring);

# PnL
def entryPrice1 = if (buySignal and !buySignal[1]) or (sellSignal and !sellSignal[1]) then close else entryPrice1[1];
def profitTarget = if buySignal and !buySignal[1] then entryPrice + ProfitDelta else if sellSignal and !sellSignal[1] then entryPrice - ProfitDelta else profitTarget[1];
def orderDir = if BarNumber() == 1 then 0
else if orderDir[1] == 0 and buySignal and !buySignal[1] then 1
else if orderDir[1] == 1 and (MACD_Direction != 1 or close crosses above profitTarget) then 0
else if orderDir[1] == 0 and sellSignal and !sellSignal[1] then -1
else if orderDir[1] == -1 and (MACD_Direction != -1 or close crosses below profitTarget) then 0
else orderDir[1];

def isOrder = if IsNaN(orderDir) then no else orderDir crosses 0;
def orderCount = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then orderCount[1] + 1 else orderCount[1], 0);

def orderWinners = if BarNumber() == 1 then 0
else if orderDir[1] == 1 and orderDir == 0 then
if close >= profitTarget[1] then orderWinners[1] + 1 else orderWinners[1]
else if orderDir[1] == -1 and orderDir == 0 then
if close <= profitTarget[1] then orderWinners[1] + 1 else orderWinners[1]
else orderWinners[1];
def winRate = orderWinners / orderCount;

AddLabel(ShowStatistics, "Ergo Strategy", Color.Cyan);
AddLabel(ShowStatistics, "" + orderCount + " Trades | " + AsPercent(winRate), if winRate > 0.5 then Color.GREEN else Color.RED);
Can you share a picture of your chart with the above settings? I tried to copy the script into a new chart, but am only getting a standard chart with no indicators.
The original chart that Hypoluxa published works just as fine.
Thanks
 
Hey everyone! New to the forum and impressed with the community so far. Also love this strategy! Had a few great trades using it last week.

I wanted to ask everyone about specific entry strategies. I have struggled a little bit with when to enter trades. In general the strategy makes sense to wait for a decisive closing dot in a direction above or below the zero line and then enter, but are people watching and entering at the open of the "trade bar"? Waiting a minute or two, what has worked best? For the last 3 trades I took, I entered at around the :09 mark of the "confirmation dot" bar thinking the last minute is not going to destroy the trend and make me not take the trade. That puts me essentially at the open of the next bar. So far that has worked out and looking back it seems like it works but curious what others are doing.

Thanks again for all the great info everyone posts!
 
Hey everyone! New to the forum and impressed with the community so far. Also love this strategy! Had a few great trades using it last week.

I wanted to ask everyone about specific entry strategies. I have struggled a little bit with when to enter trades. In general the strategy makes sense to wait for a decisive closing dot in a direction above or below the zero line and then enter, but are people watching and entering at the open of the "trade bar"? Waiting a minute or two, what has worked best? For the last 3 trades I took, I entered at around the :09 mark of the "confirmation dot" bar thinking the last minute is not going to destroy the trend and make me not take the trade. That puts me essentially at the open of the next bar. So far that has worked out and looking back it seems like it works but curious what others are doing.

Thanks again for all the great info everyone posts!
I always wait for the candle to confirm and close.
 
Status
Not open for further replies.

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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