@cos251 I appreciate the update; any chance you can do the same for ADR Upper?
@cos251 I appreciate the update; any chance you can do the same for ADR Upper?
VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.
Hi Cos,Got it. I'll send you the code to add that finds the beginning in a bit.
Similar to this?
Hi SuryaKiranC:@cos251, is there a consolidated outstanding requests on this? with holidays coming, I can working on this for a bit.
-Surya
# Code for Average Range Scan - User selects Percentage of Range covered by changing the ScanRange
# original code provided by autolox
# modified by jox51 to add Power X Strategy Stop and Targets
#Hint: Displays labels for Stops and Targets of the Power X Strategt. AVR is the today's Daily Range Percentage compared with the Average Daily Range
# The number of days you'd like average
input RangePeriod = 7; #hint RangePeriod: Original Power X Strategy uses a period of 7 to compute the daily range. Feel free to change it here as you please.
input ShowLongLabel = yes; #hint ShowLongLabel: Display stops and targets when going long
input ShowShortLabel = yes; #hint ShowShortLabel: Displays stops and targets when going short
# ScanRange = .25 (25%) .50 (50%) .75 (75%) 1 (100%)
#input ScanRange = 1;
def DayRange = high-low;
def AvgRange = average(DayRange,RangePeriod);
# How to address seeing what % of daily range has been achieved
def TodayAgainstAvgRange = (high-low)/AvgRange;
def round_todayrange = roundDown(TodayAgainstAvgRange, 3);
# Power Stops and Targets
def StopOne = AvgRange * 1.5;
def TargetOne = AvgRange * 3;
#PowerX Long StopLoss Exit 1
def PowerEntry = high + 0.01;
def StopPrice = roundDown(PowerEntry-StopOne,2);
#PowerX Long Profit Target
def TargetPrice = roundDown(PowerEntry + TargetOne,2);
#PowerX Short StopLoss
def SellPowerEntry = low - 0.01;
def SellStopPrice = roundDown(SellPowerEntry + StopOne,2);
#Sell Power Short Profit Target
def SellTarget = roundDown(SellPowerEntry - TargetOne,2);
AddLabel(yes,"ADR Percentage: "+round_todayrange*100+"% ",color.yellow);
AddLabel(ShowLongLabel,"Power Stop: "+ StopPrice + " ",color.ORANGE);
AddLabel(ShowLongLabel,"Power Profit Target: "+TargetPrice+" ",color.GREEN);
AddLabel(ShowShortLabel,"Short Stop Loss: "+SellStopPrice+" ",color.RED);
AddLabel(ShowShortLabel,"Short Target: "+SellTarget+" ",color.DaRK_ORANGE);
Use this SCANS version for your back testing. the UpTrendJustStarted & DownTrendJustStarted Variables are set to find the beginning of a trend.Hi SuryaKiranC:
I tried to create a backtest for the POX strategy, when there is a green bar(Indicator paint fill) start the long position and exit at the end of the green bar, same thing on the short side based on red bars.
Used the extract from the scan code
plot UpTrend = if calcRSI >= 50 and calcSlowK >= 50 and calcValue > calcAvg then 1 else 0;
plot DownTrend = if calcRSI < 50 and calcSlowK < 50 and calcValue < calcAvg then 1 else 0;
and leveraged the Uptrend and DownTrend variables to trigger long open, long exit, short open & Short exits in the backtest order.
The order entry and exits plotted are not accurate to match the signals. Not sure why?
The bigger ask: Is it even possible to include and factor in theta decay in backtest strategy orders for option positions?
If we run the strategy on a weekly or daily, with a normal back test, it shows lots of historic gains! but in reality that is not the case when you factor in Theta and sideways movement for swing positions that is a month or 40 days long. The Theta input should be adjustable, so we can try for ATM, ITM & OTM choices. Perhaps we can approximately calculate option price using Delta increments like in real world and calculate backtest report? Experts can weigh in here, Please.
I hope I'm not asking for a replica of Analysis tab/Profitability analysis with Bjerksund-Stensland model
Just thought to ask Appreciate all the help you and Cos251 have put in so far.
Hi Surya@cos251, is there a consolidated outstanding requests on this? with holidays coming, I can working on this for a bit.
-Surya
Still working on this - haven't forgotHi @trendr - let me see what I can do about fixing that. I've been working on a few other things but want to get back to a couple of outstanding requests on this thread.
This my development version. I've not made it available yet as I need to finish up a few modifications.@cos251 , The picture shown in post # 215 above, which version is it?
Just tried, its not working. Should I put it as a lower study? it didn't make sense to be a lower study, but please let me knowUse this SCANS version for your back testing. the UpTrendJustStarted & DownTrendJustStarted Variables
Hmm. Ok, I'll take a look.Just tried, its not working
########### my additions to PowerX #########
# Big Kudos to Cos251 for the main code without which this would not be possible. To Welkin for the Horizontal Line and Cloud code. To Dublin_Capital for the number counting.
def ADR = Average(High(period = AggregationPeriod.DAY) - Low(period = AggregationPeriod.DAY), 7);
def Target = close(period = AggregationPeriod.DAY) + (ADR * 3);
def StopLoss = close(period = AggregationPeriod.DAY) - (ADR * 1.5);
def EntryPoint = close(period = AggregationPeriod.DAY);
AddLabel(yes, "Profit_X Target = +" +ADR * 3+ "", color.cyan);
AddLabel(yes, "(" +(close(period = AggregationPeriod.DAY) + (ADR * 3))+ ")", color.cyan);
AddLabel(yes, " : Stop_X Loss = -" +ADR * 1.5+ "", color.Pink);
AddLabel(yes, "(" +(close(period = AggregationPeriod.DAY) - (ADR * 1.5))+ ")", color.Pink);
#number counting during UpTrend
def longSignal = UpTrend == 1;
def barNumberLong = CompoundValue(1, if LongSignal == 1 then barNumberLong[1] + 1 else 0, 0);
plot barsUp = if barNumberLong > 0 then barNumberLong else Double.NaN;
barsUp.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barsUp.SetDefaultColor(Color.GREEN);
# Long Mode only so far
input crossingType = {default above, below}; # for Long / Short
plot UT = UpTrend;
UT.Hide();
plot DT = DownTrend;
DT.Hide();
def TrendTest;
switch(crossingType) {
case above:
TrendTest = UT crosses above DT;
case below:
TrendTest = DT crosses above UT;
}
#--Entry, actually Daily Close
def Entryline = if TrendTest then EntryPoint else if TrendTest[1] and !TrendTest then EntryPoint[1] else Entryline[1];
plot EntrySig = if UpTrend == 1 then Entryline else Double.NaN;
EntrySig.DefineColor("Above", GetColor(7));
EntrySig.DefineColor("Below", GetColor(7));
EntrySig.AssignValueColor(if crossingType == crossingType.above then EntrySig.Color("Above") else EntrySig.Color("Below"));
EntrySig.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
EntrySig.Hide(); # Add a # in front if you want a solid line displayed
#--Profit Target point
def TargetLine = if TrendTest then Target else if TrendTest[1] and !TrendTest then Target[1] else TargetLine[1];
plot TargetSig = if UpTrend == 1 then TargetLine else Double.NaN;
TargetSig.DefineColor("Above", GetColor(6));
TargetSig.DefineColor("Below", GetColor(7));
TargetSig.AssignValueColor(if crossingType == crossingType.above then TargetSig.Color("Above") else TargetSig.Color("Below"));
TargetSig.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TargetSig.Hide(); # Add a # in front if you want a solid line displayed
#--Stop Loss point
def StopLine = if TrendTest then StopLoss else if TrendTest[1] and !TrendTest then StopLoss[1] else StopLine[1];
plot StopSig = if UpTrend == 1 then StopLine else Double.NaN;
StopSig.DefineColor("Above", GetColor(2));
StopSig.DefineColor("Below", GetColor(5));
StopSig.AssignValueColor(if crossingType == crossingType.above then StopSig.Color("Above") else StopSig.Color("Below"));
StopSig.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
StopSig.Hide(); # Add a # in front if you want a solid line displayed
#--Clouds
AddCloud( if UpTrend == 1 then TargetSig else Double.NaN, EntrySig, Color.Light_Green, Color.Light_Green);
AddCloud(if UpTrend == 1 then EntrySig else Double.NaN, StopSig, Color.Pink, Color.Pink);
#-- extra ADR test
plot Targ2 = if UpTrend == 1 then TargetLine*1.25 else Double.NAN;
#-- end code
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.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
C | Bull Bear Power VOID Oscillator For ThinkOrSwim | Indicators | 21 | |
I | PMF (Power Momentum Formula) for ThinkorSwim | Indicators | 10 | |
Balance of Power Trend Indicator for ThinkorSwim | Indicators | 34 | ||
Hima Reddy RSI Power Zones Indicator for ThinkorSwim | Indicators | 7 | ||
Power Earnings Gaps (PEG) Scanner for ThinkorSwim | Indicators | 14 |
Start a new thread and receive assistance from our community.
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.
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.