Mimicking "Power X Strategy" by Markus Heitkoetter

Status
Not open for further replies.
@cos251:

I tried to create a scan with the study code of post #151. But, I am getting an error message.
"Script.Runtime. ToolComplexException. The complexity of the expression that it may not be reliable with real-time data. "

How can I generate a scan from your latest script providing me the stocks with a Long Signal (changing from downtrend to uptrend)?
That's pretty self-explanatory... I haven't looked into the code provided in this topic but that error is usually generated when there is recursion or excessive moving averages or other functions that increase complexity that slows or overwhelms the scanner... Many studies require gutting excess code in order to have scans work properly... Remember, scans don't display anything on a chart, and only return one result, so any excess code doesn't need to be in a scan...
 

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

@cos251:

I tried to create a scan with the study code of post #151. But, I am getting an error message.
"Script.Runtime. ToolComplexException. The complexity of the expression that it may not be reliable with real-time data. "

How can I generate a scan from your latest script providing me the stocks with a Long Signal (changing from downtrend to uptrend)?
Good question. I was actually thinking about creating a scan only version of the script. There is one I posted on this thread already but it also included all the other code. I'll clean up a version and post it for scan use. Hopefully this weekend.
 
  • Like
Reactions: ALV
First off Amazing work @cos251 and thank you for putting in the work! I do have a quick question, how can I add an arrow to indicate when the bars are gray? For me keeping the bars clean helps me with my strategy so I have Red and Green arrows turned on for your script so I know when the market is in up trend or down but since I don't have color to my bars it would help me to see when the market is turning "choppy" or sideways.

Thank you so much once again
Hi. I will include that as an option for upcoming updates.
 
Nice bit of coding, cos251. Thanks.

Here is my crude attempt at a label for the Target / Loss as mentioned in the .pdf

Code:
# Average Daily Range
def ADR = Average(High(period = AggregationPeriod.DAY) - Low(period = AggregationPeriod.DAY), 7);

AddLabel(yes, "Profit Target = +" +ADR * 3+ "", color.GREEN);
AddLabel(yes, " : Stop Loss =  -" +ADR * 1.5+ "", color.PINK);
AddLabel(yes, " : ADR daily = " +ADR+ "", color.GRAY);

plot ADRa = ADR; # uncheckmark the box in settings to hide this.

updated 11-29-20 below to show price as well. This is a label for the points of the current day.

def ADR = Average(High(period = AggregationPeriod.DAY) - Low(period = AggregationPeriod.DAY), 7);

AddLabel(yes, "Profit_X Target = +" +ADR * 3+ "", color.GREEN);
AddLabel(yes, "(" +(close(period = AggregationPeriod.DAY) + (ADR * 3))+ ")", color.GREEN);
AddLabel(yes, " : Stop_X Loss = -" +ADR * 1.5+ "", color.Pink);
AddLabel(yes, "(" +(close(period = AggregationPeriod.DAY) - (ADR * 1.5))+ ")", color.Pink);
#AddLabel(yes, " : ADR_X daily = " +ADR+ "", color.GRAY);


#plot ADRa = ADR; # uncheckmark in settings to hide
Hi RickAns,
I appreciate the profit target label. One question, however, does the price target update after each day once the signal has been given?
 
Hi @newbie19760123 - sure thing. Just to make sure you are referring to the Ready Aim Fire replica we have going in thread you linked to correct?
@cos251 Yes, The Ready Aim Fire Replica. I had been using your fvo_Daily_4Grid import from before. I was wondering if you can share the latest in grid form. Thanks again for the reply. Really appreciate it. Yes, the other thread is locked for some reason.
 
@andre.muhammad - Yes, the label does update each day. I do not know (yet) how to set it so it displays only the data for the day the buy / sell signal is generated. I am trying to figure that out. When I do I will update things. Thanks.
 
Last edited by a moderator:
@cos251 Yes, The Ready Aim Fire Replica. I had been using your fvo_Daily_4Grid import from before. I was wondering if you can share the latest in grid form. Thanks again for the reply. Really appreciate it. Yes, the other thread is locked for some reason.
We are not allowed to share that any longer per site administrator. Sorry.
 
Sorry for the delay. The following code can be used for SCANS
Available PLOTS are as follows:

1. UpTrend - Scan for underlying currently in up trend
2. DownTrend - Scan for underlying currently in down trend
3. UpTrendJustStarted - Scan for underlying that just started up trend - will be first bar of given TF
4. DownTrendJustStarted - Scan for underlying that just started down trend- will be first bar of given TF

You'll want to scan for "True" or "False" conditions.
You can also scan for underlyings that are not in either trend by scanning for both false conditions (up & down trends)

Feel free to tweak or let me know if you would like me to add additional plots. I've tested all plots on multiple timeframes for accuracy, let me know if you find any issues.

Lastly, I recommend using the default RSI, Stochastic and MACD studies for scans involving only those indicators for efficiency of scanning.

EDIT
See link below for latest code
https://usethinkscript.com/threads/rsm-indicator-for-thinkorswim.5407/
 
Last edited:
Sorry for the delay. The following code can be used for SCANS
Available PLOTS are as follows:

1. UpTrend - Scan for underlying currently in up trend
2. DownTrend - Scan for underlying currently in down trend
3. UpTrendJustStarted - Scan for underlying that just started up trend - will be first bar of given TF
4. DownTrendJustStarted - Scan for underlying that just started down trend- will be first bar of given TF

You'll want to scan for "True" or "False" conditions.
You can also scan for underlyings that are not in either trend by scanning for both false conditions (up & down trends)

Feel free to tweak or let me know if you would like me to add additional plots. I've tested all plots on multiple timeframes for accuracy, let me know if you find any issues.

Lastly, I recommend using the default RSI, Stochastic and MACD studies for scans involving only those indicators for efficiency of scanning.

Code:
#START OF RSI/Stochastic/MACD Confluence combo for ThinkOrSwim
#
# FVO_RSM_SCANS
#
#CHANGELOG
# 2020.12.05 - V1.0 @cos251 - RSM SCANS study - to be used to scan for following conditions:
#            - Stocks currently in UpTrend
#            - Stocks currently in DownTrend
#            - Stocks where UpTrendJustSarted - first bar of UpTrend for scanend TF
#            - Stocks where DownTrendJustStarted - first bar of DownTrend for scanned TF
#            - Recommend using default studies for SCANS of RSI, Stochastics or MACD for efficiency
#                  
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
#               Stoch Slow 5(not14) and 3 WILDERS
#               MACD 12,26,9 WEIGHTED
#
#
#CREDITS
# requesed by "@Joseph Patrick 18"
#
#LINK
# https://rockwell-files.s3.amazonaws.com/PXCompanionGuide2ndEd_cover.pdf
# Markus Heikoetter who is the author of the Power X Strategy
# https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/
#
#USAGE
#
declare lower;

plot fiftyLine = 50;
################################################################
##########                 RSI                         #########
################################################################

input lengthRSI = 7;
input over_BoughtRSI = 70;
input over_SoldRSI = 30;
input price = close;
input averageTypeRSI = AverageType.EXPONENTIAL;
def NetChgAvg = MovingAverage(averageTypeRSI, price - price[1], lengthRSI);
def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(price - price[1]), lengthRSI);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);


################################################################
##########                 Stochastic Slow             #########
################################################################
input over_boughtSt = 80;
input over_soldSt = 20;
input KPeriod = 5;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeStoch = AverageType.WILDERS;
def SlowK = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullK;
def SlowD = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullD;


#################################################################
############           MACD Calculation                 #########
#################################################################
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.WEIGHTED;
def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def Diff = Value - Avg;


#################################################################
############          SCAN Variables                    #########
#################################################################

# If you want to scan for stocks that are not in either trend you can add two filters and scan for false for both conditions

# The UpTrend and DownTrend plots can be used to scan for stocks that are currently in that trend
plot UpTrend = if RSI > 50 and SlowK > 50 and Value > Avg then 1 else Double.NaN;
plot DownTrend = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else Double.NaN;
UpTrend.Hide();
DownTrend.Hide();

# The UpTrendJustStarted and DownTrendJustStarted plots can be used to find stocks that have just started
# a trend in either direction
def UpTrendJustStartedBool = if RSI > 50 and SlowK > 50 and Value > Avg then 1 else 0;
def DownTrendJustStartedBool = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else 0;
plot UpTrendJustStarted = if UpTrendJustStartedBool == 1 and UpTrendJustStartedBool[1] == 0 then 1 else Double.NaN;
plot DownTrendJustStarted = if DownTrendJustStartedBool == 1 and DownTrendJustStartedBool[1] == 0 then 1 else Double.NaN;
UpTrendJustStarted.Hide();
DownTrendJustStarted.Hide();
This chain started has been nothing short of miracle. However, with expert coders and chartist we need a summary now. Can someone sum up which code to use as final agreed one & which all indicator and it setting we must employ for best results. This summary will be very helpful for all the advanced investors (traders) and/or newbees.
 
Thanks a lot for the Scan. It works perfectly. I have scanned for the Uptrend signal and went through all the scan results. I found that you programmed in such a way that the signal is mostly triggered when a grey bar is followed with a green bar. In this way, the long signal comes quite late and also provides a few false signals. I would like to have the option to get the long signal when the first grey or green bar appears after a series of red bars.
 
This chain started has been nothing short of miracle. However, with expert coders and chartist we need a summary now. Can someone sum up which code to use as final agreed one & which all indicator and it setting we must employ for best results. This summary will be very helpful for all the advanced investors (traders) and/or newbees.
 
@cos251 It's funny, but I was able to get the older versions to work too. It appears that I had to make some changes to the settings. I'm learning. Thanks for the hard work on this, as I have incorporated the three targets chart.
 
Status
Not open for further replies.

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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