Mimicking "Power X Strategy" by Markus Heitkoetter

Status
Not open for further replies.
In my opinion, we shouldn't try to line them up, but give the alert based on, each of the 3 when they cross their respective mid lines. specially if you are using 3 different instances of studies, each set to RSI, Stoch and MACD respectively.

I use 14 for Stoch K.

-S
I didn't realize the difference in this. I just set two charts side by side with the same ticker and timeframe and noticed some of the signals are cleared up (don't show up). This is good as it helps reduce false signals. I will adjust mine to 14 as well. Good catch guys.
Merry Christmas everyone!
 
I didn't realize the difference in this. I just set two charts side by side with the same ticker and timeframe and noticed some of the signals are cleared up (don't show up). This is good as it helps reduce false signals. I will adjust mine to 14 as well. Good catch guys.
Merry Christmas everyone!
Ok thanks! Merry Christmas to you and your family.
 
Hi @Joseph Patrick 18 Please see the shared grid below. I will apologize up front, I made a few assumptions based on the shading. The shading is based on all 3 conditions being met rather than trying to line then up manually. I also combined the RSI and Stochastic since they are on the same range plot to save space. Hopefully this is along the lines of what you are looking for. Personally I think the shading required of all 3 conditions being met is better since it helps further confirm your trend a bit more definitively. At least that is my first reaction, could be wrong. Take a peak and see what you think. This is my first real attempt at a request from another member please provide constructive criticism/feedback. Thanks.

Edit* - I used this from your post above
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
# Stoch Slow 5(not14) and 3 WILDERS
# MACD 12,26,9 WEIGHTED

https://tos.mx/DJMLB1n

y3R2opN.png
Cos sorry, I deleted my settings so I don't know if you want to update..thanks
 
Thanks SuryaKiranC, I adjusted it back to 14...I didn't realize but now understand what you are saying and appreciate your help! Thanks and Happy Holidays to you and your family! Thanks :) ....I deleted the post...

Dumb question, what do you have for all 3 of your settings for the RSI settings, the Stoch, and MACD settings? Thanks appreciate it...I will adjust once you get back to me.

Sorry Everyone for the miscommunication it was unintentional!
Rest of the settings coded are as per the strategy, only K, is stochastic is misaligned. That's the only change. earlier version of the code had AggrPeriod as a input, this made is not suitable for runtime chart frame adjustments. Current Version fixed it.

So we can use the current version in all timeframes without any user changes to settings.

In my opinion, Set Stoch K to 14, and that is it, everything else is good.

Cosmetic changes, with ADR Levels off, Chart type Set to "Bar" looks good. So you can see the candle open and close clearly, Otherwise Candle for Chart Type. Final changes, the Choppy zone painted White not Dark_Gray.
 
Rest of the settings coded are as per the strategy, only K, is stochastic is misaligned. That's the only change. earlier version of the code had AggrPeriod as a input, this made is not suitable for runtime chart frame adjustments. Current Version fixed it.

So we can use the current version in all timeframes without any user changes to settings.

In my opinion, Set Stoch K to 14, and that is it, everything else is good.

Cosmetic changes, with ADR Levels off, Chart type Set to "Bar" looks good. So you can see the candle open and close clearly, Otherwise Candle for Chart Type. Final changes, the Choppy zone painted White not Dark_Gray.
Okay thanks very much sorry about the confusion.
 
Hello, Does someone know how to convert or code these Thinkscripts in C# for ninjatrader? Are they able to be converted to an API?

Thxs,
 
Hi All.... - so sorry for the delay. I've had a rough go of trying to figure out a few updates for the latest version of the code but I think I have at least a decent working version. There are many additions in this code now and it is getting a little heavy. I apologize if this particular version does not have what you are looking for. I am happy to continue plugging away at further enhancements.

For now here are the updates available in Version 1.4 of the Standard Code (single TF/Tick version) Added the updates to this version as it is the most reliable at this time for quick and easy use.

Link to updated code - https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/post-42978
Again Version 1.4

Updates are as follows
  1. Dynamic ATR/ADR Targets/Plots on the start of an UpTrend or DownTrend
  2. Dynamic Stop Loss at 1x the ATR/ADR
  3. Dynamic Stop Loss adjustment in settings; currently set to 1.0
  4. Shading for ATR/ADR Targets/Plots - can be turned on or off
  5. Extra Targets (4-6) - can be enabled in settings
  6. Option to only show Dynamic Targets for TodayOnly
  7. Ability to plot ATR/ADR and all settings described above for Daily Chart - BUT MUST TURN OFF "showTodayOnly"
  8. Dynamic ATR/ADR Target Labels at top of chart for current trend
  9. Dynamic Trend Labels will display when trend started, at what price and how many bars are in current trend
  10. Debug function - miscellaneous labels that can be used for debug purposes - remove if you like
It has taken me a good while to get all these plots down correctly but I think this is a good point

Now I will say this can makes the chart look a little messy depending on your taste. I'll let you guys be the judge. I also have the same copy in MTF version but there is an issue with the Target Plots once the trend starts. It does not plot correctly but eventually straightens out. I'll see if I can figure out how to adjust it.

The ATR/ADR calculations are also pretty standard, if you see issues with them please let me know so I can adjust the script and ensure accurate calculation for all.
I'll add edits below as I think of them. For now see fresh version of code with link above and screenshots for reference below.
Thanks so much for your patience.

MSFT Today on 5m TF with "showTodayOnly" set to "yes"
FjbmNJJ.png


MSFT on Daily Chart with "showTodayOnly" set to "no" (Must be set to "no" so plots will work on daily)
Trend Labels set to "yes" for example purposes
0WEc2RO.png
@cos251 can you provide a share link for the chart you posted? Thx!
 
I am having a difficult time with the scans. For some reason, I can't figure out how to get the scan code to run. I get a generic alphabetical return of stocks. Can someone point me to a step by step to get the scan codes running for this version. Is there a shared import code such as with the above grid? I am a newbie to the Thinkscript, but you guys are awesome! Thanks in advance.
 
I am attributing my issues with the scanner as user error and lack of knowhow. Here is what I have attempted. I copied code from previous post, attempted to insert it in the-SCAN tab, Custom study, using thinkscript editor. I first receive a message "Exactly one plot expected". When this message is received I can't save the scanner. In the "Scan Variables" I see 6 "Plot" commands, am I supposed to edit those to only have one plot command? Somehow, I was able to create a scanner, but I don't believe any of the actual code made it in the scanner, thus returning a generic alphabetized list of all stocks.

I shared the link to my scanner or lack thereof, since I also can't seem to share a screen shot...?! I can take a screen shot, just not able to post it here.

https://tos.mx/j4avVik

I feel like such a juvenile with this issue. Appreciate your hand holding!

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
#            - Stocks where UpTredJustEnded - first NO Trend bar after UpTrend
#            - Stocks where DownTrendJustEnded - first NO Trend bar after DownTrend
#            - 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();
plot UpTrendJustEnded= if UpTrendJustStartedBool[1] == 1 and UpTrendJustStartedBool == 0 then 1 else Double.NaN;
plot DownTrendJustEnded= if DownTrendJustStartedBool[1] == 1 and DownTrendJustStartedBool == 0 then 1 else Double.NaN;
UpTrendJustEnded.Hide();
DownTrendJustEnded.Hide();
 
@Bugman Yes, you can edit the code so all but one plot, the one you need, are changed to a def and then see if you have better luck... That way, if the results of the plot are required further down in the code, the code won't be broken...
 
@Bugman

I think you are in the right place with custom script, what is your scan query? it should be like this, Please not my SCAN script is saved as FVO_RSM_SCAN not FVO_RSM_SCANS you need to adjust the first part of the query to match your script name.

FVO_RSM_Scan().UpTrendJustStarted
FVO_RSM_Scan().DownTrendJustStarted
 
@Bugman

I think you are in the right place with custom script, what is your scan query? it should be like this, Please not my SCAN script is saved as FVO_RSM_SCAN not FVO_RSM_SCANS you need to adjust the first part of the query to match your script name.

FVO_RSM_Scan().UpTrendJustStarted
FVO_RSM_Scan().DownTrendJustStarted
@SuryaKiranC I changed the scan name which helped to a degree, but I don't know what to do with FVO_RSM_Scan().UpTrendJustStarted,
FVO_RSM_Scan().DownTrendJustStarted and what the functions mean. Where do I insert them in the code?

@rad14733 I changed all of the "plot" to "def" except the one i was trying to utilize. That helped. I had to insert "#" in front of each line that was referenced by the "plot" to get the scanner to accept the code.

The end result=scanner was able to be saved, ran with 20-50 returned stocks with about 50% of those at the start of the uptrend with green arrow indicator. Not sure if that is the expected result or not. Also did the start of a downtrend with about 10-15 returned stocks with about 5 of those with the down arrow indicator.

As you can tell, I am not a coder and am doing trail and error, with mainly error. But I would bet that most ThinkorSwim users are in the same boat as far as understanding the thinkscript. You guys are definitely the few and proud!

On the upside the charting functions seem to be working like a charm!
 
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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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