Mimicking "Power X Strategy" by Markus Heitkoetter

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

@Joseph Patrick 18 what @cos251 said. Besides, the indicator already let you put in your values. As individuals we need to understand what the indicators are supposed to do and test before we put in money. I like to read and understand code before I deploy them for trading.

@cos251 Incase I didn't mention, Thank you. One if the best indicators that is out there.
Thanks SuyraKiranC appreciate it...it was all Cos251 I am just along for the ride..thank you tho.
 
@cos251 Here is a different style for Upper MTF Study, you can practically have whatever timeframe you want. without additional coding for each timeframe. I retained your original header, feel free to change how you want it for version info, If you choose to use it.

if you use this and update your post, I will delete this comment to avoid any confusion for others following the thread.

The way to use this is, to add the study multiple times and set each instance to a different timeframe that one desires. Let me know your thoughts.

PS: Please note the change in header about Stoch Slow K. Also, if you think RSI, Stoch and MACD settings should be tunable, we can make it happen and pass as parameters to sub-script. Let me know your thoughts.

Code:
#START OF RSI/Stochastic/MACD Confluence Strategy for ThinkOrSwim
#FVO_RSM_MTF
#
#CHANGELOG
# 2020.12.30 V2.1 @SuryaKiranC - Fork from @cos251 Version, to reduce the number of lines in code and optimize for performance.
#
# 2020.12.11 V1.1 @cos251 - Added 2D, 3D, 4D, 1WK, 1MNTH Agg Period Labels
#
# 2020.12.02 V1.0 @cos251 - Added RSM signal calculation for following timeframes:
#                         - 1m, 2m, 5m, 15m, 30m, 1h, 2h, 4h, D
#                         - Label will be added to top of chart for every allowed TF
#                         - Label will read "TF:L(Long):S(Short):I(Idle)"
#                         - Label Color will be green, red or gray accordingly
#
#                
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
#               Stoch Slow 14 and 3 WILDERS
#               MACD 12,26,9 WEIGHTED
#
#ORIGINAL REQUEST - @Joseph Patrick 18
#                 - Link: https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/
#
#

input period = AggregationPeriod.DAY;

DefineGlobalColor("UpTrend", Color.Green);
DefineGlobalColor("DownTrend", Color.RED);
DefineGlobalColor("NoTrend", Color.GRAY);

script RSM_ {

    input aP = AggregationPeriod.DAY;
    # RSI
    def lengthRSI = 7;
    def averageTypeRSI = AverageType.EXPONENTIAL;
    # Stochastic
    def over_boughtSt = 80;
    def over_soldSt = 20;
    def KPeriod = 14;
    def DPeriod = 3;
    input averageTypeStoch = AverageType.WILDERS;
    # MACD
    def fastLength = 12;
    def slowLength = 26;
    def MACDLength = 9;
    def averageTypeMACD = AverageType.WEIGHTED;

    ###############################################################
    ##########                 RSI                         #########
    ################################################################

    def NetChgAvg = MovingAverage(averageTypeRSI, close(period = aP) - close(period = aP)[1], lengthRSI);
    def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(close(period = aP) - close(period = aP)[1]), lengthRSI);
    def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
    def RSI_ = 50 * (ChgRatio + 1);

    ################################################################
    ##########                 Stochastic Slow             #########
    ################################################################

    def SlowK_ = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  high(period = aP),  low(period = aP),  close(period = aP),  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;
    def SlowD_ = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  high(period = aP),  low(period = aP),  close(period = aP),  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullD;

    ################################################################
    ##########                 MACD                      ###########
    ################################################################

    def Value_ = MovingAverage(averageTypeMACD, close(period = aP), fastLength) - MovingAverage(averageTypeMACD, close(period = aP), slowLength);
    def Avg_ = MovingAverage(averageTypeMACD, Value_, MACDLength);
    def Diff_ = Value_ - Avg_;

    #################################################################
    ##########          Trend  & Labels                   #########
    #################################################################
    def UpTrend_ = if RSI_ >= 50 and SlowK_ >= 50 and Value_ > Avg_ then 1 else 0;
    def DownTrend_ = if RSI_ < 50 and SlowK_ < 50 and Value_ < Avg_ then 1 else 0;
    plot Trend_ = if UpTrend_ then 1 else if DownTrend_ then 0 else -1;
  
}

def currentPeriod = GetAggregationPeriod();
def RSM;

if period >= currentPeriod {
    RSM = RSM_(aP = period);

} else {
    RSM = Double.NaN;

}

AddLabel(!IsNaN(RSM), if period == AggregationPeriod.MONTH then "M"
else if period == AggregationPeriod.WEEK then "W"
else if period == AggregationPeriod.FOUR_DAYS then "4D"
else if period == AggregationPeriod.THREE_DAYS then "3D"
else if period == AggregationPeriod.TWO_DAYS then "2D"
else if period == AggregationPeriod.DAY then "D"
else if period == AggregationPeriod.FOUR_HOURS then "4H"
else if period == AggregationPeriod.TWO_HOURS then "2H"
else if period == AggregationPeriod.HOUR then "60m"
else if period == AggregationPeriod.THIRTY_MIN then "30m"
else if period == AggregationPeriod.TWENTY_MIN then "20m"
else if period == AggregationPeriod.FIFTEEN_MIN then "15m"
else if period == AggregationPeriod.TEN_MIN then "10m"
else if period == AggregationPeriod.FIVE_MIN then "5m"
else if period == AggregationPeriod.FOUR_MIN then "4m"
else if period == AggregationPeriod.THREE_MIN then "3m"
else if period == AggregationPeriod.TWO_MIN then "2m"
else if period == AggregationPeriod.MIN then "1m"
else "", if RSM == 1 then GlobalColor("UpTrend") else if RSM == 0 then GlobalColor("DownTrend") else GlobalColor("NoTrend"));
 
Last edited:
Hi all! After examining this product, and it was an extraordinary amount of work done on this, I have concluded the following after trading with it. This Power X Strategy is the ultimate contrarian indicator many times, as after it has been identified as a play, the second day it tends to gap up and then drop incessantly. Perhaps it is because we are in a very overbought market right now, but this is what I have noticed. There are a few trades that will hit target one, then go idle, and make more gains during the idle period than the Power X period.
 
@cos251 Here is a different style for Upper MTF Study, you can practically have whatever timeframe you want. without additional coding for each timeframe. I retained your original header, feel free to change how you want it for version info, If you choose to use it.

if you use this and update your post, I will delete this comment to avoid any confusion for others following the thread.

The way to use this is, to add the study multiple times and set each instance to a different timeframe that one desires. Let me know your thoughts.

PS: Please note the change in header about Stoch Slow K. Also, if you think RSI, Stoch and MACD settings should be tunable, we can make it happen and pass as parameters to sub-script. Let me know your thoughts.

Code:
#START OF RSI/Stochastic/MACD Confluence Strategy for ThinkOrSwim
#FVO_RSM_MTF
#
#CHANGELOG
# 2020.12.30 V2.1 @SuryaKiranC - Fork from @cos251 Version, to reduce the number of lines in code and optimize for performance.
#
# 2020.12.11 V1.1 @cos251 - Added 2D, 3D, 4D, 1WK, 1MNTH Agg Period Labels
#
# 2020.12.02 V1.0 @cos251 - Added RSM signal calculation for following timeframes:
#                         - 1m, 2m, 5m, 15m, 30m, 1h, 2h, 4h, D
#                         - Label will be added to top of chart for every allowed TF
#                         - Label will read "TF:L(Long):S(Short):I(Idle)"
#                         - Label Color will be green, red or gray accordingly
#
#               
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
#               Stoch Slow 14 and 3 WILDERS
#               MACD 12,26,9 WEIGHTED
#
#ORIGINAL REQUEST - @Joseph Patrick 18
#                 - Link: https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/
#
#

input period = AggregationPeriod.DAY;

DefineGlobalColor("UpTrend", Color.Green);
DefineGlobalColor("DownTrend", Color.RED);
DefineGlobalColor("NoTrend", Color.GRAY);

script RMS_ {

    input aP = AggregationPeriod.DAY;
    # RSI
    def lengthRSI = 7;
    def averageTypeRSI = AverageType.EXPONENTIAL;
    # Stochastic
    def over_boughtSt = 80;
    def over_soldSt = 20;
    def KPeriod = 14;
    def DPeriod = 3;
    input averageTypeStoch = AverageType.WILDERS;
    # MACD
    def fastLength = 12;
    def slowLength = 26;
    def MACDLength = 9;
    def averageTypeMACD = AverageType.WEIGHTED;

    ###############################################################
    ##########                 RSI                         #########
    ################################################################

    def NetChgAvg = MovingAverage(averageTypeRSI, close(period = aP) - close(period = aP)[1], lengthRSI);
    def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(close(period = aP) - close(period = aP)[1]), lengthRSI);
    def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
    def RSI_ = 50 * (ChgRatio + 1);

    ################################################################
    ##########                 Stochastic Slow             #########
    ################################################################

    def SlowK_ = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  high(period = aP),  low(period = aP),  close(period = aP),  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;
    def SlowD_ = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  high(period = aP),  low(period = aP),  close(period = aP),  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullD;

    ################################################################
    ##########                 MACD                      ###########
    ################################################################

    def Value_ = MovingAverage(averageTypeMACD, close(period = aP), fastLength) - MovingAverage(averageTypeMACD, close(period = aP), slowLength);
    def Avg_ = MovingAverage(averageTypeMACD, Value_, MACDLength);
    def Diff_ = Value_ - Avg_;

    #################################################################
    ##########          Trend  & Labels                   #########
    #################################################################
    def UpTrend_ = if RSI_ >= 50 and SlowK_ >= 50 and Value_ > Avg_ then 1 else 0;
    def DownTrend_ = if RSI_ < 50 and SlowK_ < 50 and Value_ < Avg_ then 1 else 0;
    plot Trend_ = if UpTrend_ then 1 else if DownTrend_ then 0 else -1;
 
}

def currentPeriod = GetAggregationPeriod();
def RMS;

if period >= currentPeriod {
    RMS = RMS_(aP = period);

} else {
    RMS = Double.NaN;

}

AddLabel(!IsNaN(RMS), if period == AggregationPeriod.MONTH then "M"
else if period == AggregationPeriod.WEEK then "W"
else if period == AggregationPeriod.FOUR_DAYS then "4D"
else if period == AggregationPeriod.THREE_DAYS then "3D"
else if period == AggregationPeriod.TWO_DAYS then "2D"
else if period == AggregationPeriod.DAY then "D"
else if period == AggregationPeriod.FOUR_HOURS then "4H"
else if period == AggregationPeriod.TWO_HOURS then "2H"
else if period == AggregationPeriod.HOUR then "60m"
else if period == AggregationPeriod.THIRTY_MIN then "30m"
else if period == AggregationPeriod.TWENTY_MIN then "20m"
else if period == AggregationPeriod.FIFTEEN_MIN then "15m"
else if period == AggregationPeriod.TEN_MIN then "10m"
else if period == AggregationPeriod.FIVE_MIN then "5m"
else if period == AggregationPeriod.FOUR_MIN then "4m"
else if period == AggregationPeriod.THREE_MIN then "3m"
else if period == AggregationPeriod.TWO_MIN then "2m"
else if period == AggregationPeriod.MIN then "1m"
else "", if RMS == 1 then GlobalColor("UpTrend") else if RMS == 0 then GlobalColor("DownTrend") else GlobalColor("NoTrend"));
@SuryaKiranC - I like this very much. If you are loading a chart with several tickers this is a good option. I am also running a dev version with very limited options (but not MTF). Nice work. I will download and tinker with it on my multi-ticker chart. Much appreciated!
 
Last edited:
Hi all! After examining this product, and it was an extraordinary amount of work done on this, I have concluded the following after trading with it. This Power X Strategy is the ultimate contrarian indicator many times, as after it has been identified as a play, the second day it tends to gap up and then drop incessantly. Perhaps it is because we are in a very overbought market right now, but this is what I have noticed. There are a few trades that will hit target one, then go idle, and make more gains during the idle period than the Power X period.
What time frames are you working with? DAY? I've noticed this on a few tickers as well. I am still a novice in the trading world, but I feel like the market conditions are just different these days. We see crazy gap ups on some of these tickers then they just come back down for a reality check. I personally like to use other indicators along with PX to find the trend and trade with it. Also looking at RVOL & ATR helps for me as well.
 
What time frames are you working with? DAY? I've noticed this on a few tickers as well. I am still a novice in the trading world, but I feel like the market conditions are just different these days. We see crazy gap ups on some of these tickers then they just come back down for a reality check. I personally like to use other indicators along with PX to find the trend and trade with it. Also looking at RVOL & ATR helps for me as well.
I will say; it is a chore to identify the right or optimal conditions. See image below. Start of trend (kinda in the middle) with yellow arrow is a good spot. RAF shows start of upward trend and fire signal.
Other indicators on the chart:
  1. Key level (148) broken
  2. 9SMA cross above 19SMA
  3. Volume comes in
  4. RAF is providing a good indication of upward trend

The latest PX Signal (from yesterday) is provided when the stock is nearing over extended at least somewhat in relation to the SMA's.
Just my thoughts on the PX indicator.
BuBsk6k.png
 
@SuryaKiranC I am in the custom filter screen with pencil icon, clicked thinkscript editor and replaced code with string. The editor gives these error messages. I tried to reload/reopen both the powerx grid and scanner, renamed them as indicated.

No such function: FVO_RSM_Scan at 1:1
No such function: FVO_RSM_Scan at 1:1
Invalid statement: Unexpected part of function call at 1:16
No such function: FVO_RSM_Scan at 1:1
No such function: FVO_RSM_Scan at 1:1
Invalid statement: Unexpected part of function call at 1:16
I take it you are good with the setup? @Bugman
-S
 
Surya,

Should we add the script you provided yesterday to the bottom of a particular script, or should we make it into a separate study an add it to a study set just like any other study to get it to work? Using it as a stand alone study on a new chart makes almost no visible changes to the chart, except for adding a single small box to the upper left corner of the chart. Thanks.
 
@SuryaKiranC I am in the custom filter screen with pencil icon, clicked thinkscript editor and replaced code with string. The editor gives these error messages. I tried to reload/reopen both the powerx grid and scanner, renamed them as indicated.

No such function: FVO_RSM_Scan at 1:1
No such function: FVO_RSM_Scan at 1:1
Invalid statement: Unexpected part of function call at 1:16
No such function: FVO_RSM_Scan at 1:1
No such function: FVO_RSM_Scan at 1:1
Invalid statement: Unexpected part of function call at 1:16
Hey bud, i had the same issue until just now.

Please do as per below and it will work like a charm. (FYI this is based on Surya's reply).
  • Go to comment 273 (https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/post-46060) Copy everything under code.
  • Go to ThinkorSwim, Click on Edit Study and Strategy Icon.
  • Click Create (Create New Study)
  • Remove the default plot statement and past the code you copied.
  • Save the study with name "FVO_RSM_SCANS", make sure it is not loaded into your studies on the right, if it is loaded by default when you saved it, please remove we don't need this on chart study.
  • Go to Scan, Remove all the filters and add a new filter, select "Study" as a filter, Default study selected will be "ADXCrossOver", Click on Pencil Icon next to Default TimeFrame "D" and click "ThinkScript Editor".
  • Here you can past one of the scan query FVO_RSM_SCANS().UpTrendJustStarted or FVO_RSM_SCANS().DownTrendJustStarted.
  • You can even limit the scan results, by selecting a default narrowed down list as "S&P 500" under "Scan In" on the scan tab itself.
  • Finally you can save the scan query with a name, I saved it as "FVO_RSM_SCANS"
  • Repeat the process again for the 2nd scan query.
  • I have added some condition from Joseph post - Post 49. (https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/post-40256)
Let me know if works for you as it did for me.
 
@cos251 I saw where a guy added a study to Ben’s BTD study. Using the time frame that you are on, it counted the number of profitable entries with win and loss percentages. I noticed that the Power X has that same data. Is it possible that can be added to this?
 
@cos251 Changed the MACD histogram colors, purely from a usability point of view. Green on Green in the lower studies a bit hard to see.

Diff.DefineColor("Positive and Up", Color.CYAN);
Diff.DefineColor("Positive and Down", Color.BLUE);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.YELLOW);
In which script?
 
@cos251 I saw where a guy added a study to Ben’s BTD study. Using the time frame that you are on, it counted the number of profitable entries with win and loss percentages. I noticed that the Power X has that same data. Is it possible that can be added to this?
Can you share a screenshot of what you are looking for?
 
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
318 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