Hello, read the original post that is linked in the text you just cited.How does it actually Work? some instructions for the strategy?
Hello, read the original post that is linked in the text you just cited.How does it actually Work? some instructions for the strategy?
Hello, Originally in the book which introduces the strategy it is used at the daily time frame, hence the name "Wide ranging days". However, other users here tried using it in a lower time frame, such as the 5 min chart, and it works beautifully. I suggest you try the 5 min chart.Hey @danB - Thanks for the strat. I think I may be misunderstanding something. It sounds like the recommended timeframe for this is daily with a 2 /4 bar look back/forward. When I load that into ToS and look at FloatingPL its a sea of red. The first bar on the chart is 1/25/21 and I set the start date parameter to the same. Are you able to see what I am misunderstanding? Thank you.
Hey @danB - So I spent a fair amount of time with this today on an ES 5 day/5 min chart and could not find any combination of parameters that resulted in a positive P&L over 5 days. Would you be so kind as to share the settings that you have found to work well on a 5 min chart? TIA.Hello, Originally in the book which introduces the strategy it is used at the daily time frame, hence the name "Wide ranging days". However, other users here tried using it in a lower time frame, such as the 5 min chart, and it works beautifully. I suggest you try the 5 min chart.
Hello, I use 2 days before, 4 after. I am looking at the /ES right now. I have my chart set up with a 30 day period and I see a profit of 7K, see the image attached.Hey @danB - So I spent a fair amount of time with this today on an ES 5 day/5 min chart and could not find any combination of parameters that resulted in a positive P&L over 5 days. Would you be so kind as to share the settings that you have found to work well on a 5 min chart? TIA.
Thanks for taking the time to response @danB. I see the same results on a 30day/5 min chart, though looking at that chart I do also see that the last 5 days of the period show a loss. I'm going to keep playing around with it. I've also ordered the book that this idea came from.Hello, I use 2 days before, 4 after. I am looking at the /ES right now. I have my chart set up with a 30 day period and I see a profit of 7K, see the image attached. I agree the numbers are not impressive. This is an "always-in" strategy, meaning that you either have a long or short position, and just wait for the opposite signal if you are having a losing trade. I have seen other strategies, such as this one that include a stop loss in the code. Maybe adding one here can improve the P&L figures. Hope it helps.
#Wide Ranging Days Strategy - Long Only
#Original code by Svanoy. Modified by Matt Ward Feb 2nd 2022.
#https://usethinkscript.com/threads/futures-strategy-wide-ranging-days-in-thinkorswim.9767
input length = 10;
input averageType = AverageType.WILDERS;
input Days_Before = 1;
input Days_After = 2;
input ExcludeDowntrend = Yes;
input DowntrendEMA1 = 5;
input DowntrendEMA2 = 9;
input DowntrendEMA3 = 14;
input Slippage = 0.25;
input Commission = 0.12;
def WideRangingDay = TrueRange(high, close, low) / ATR(length, averageType) > 1.6;
def Signal = if IsNaN(close[Days_After]) then Signal[Days_After] else WideRangingDay[Days_After];
def ValidBarNumber = if !IsNaN(BarNumber()) then BarNumber() else ValidBarNumber[1];
def WideRangingDayStartBarID = if Signal then ValidBarNumber[Days_After + Days_Before] else WideRangingDayStartBarID[1];
def WideRangingDayEndBarID = if Signal then ValidBarNumber else WideRangingDayEndBarID[1];
def True_High = fold th = ValidBarNumber - WideRangingDayEndBarID
to ValidBarNumber - WideRangingDayStartBarID + 1
with THC = GetValue(high, ValidBarNumber - WideRangingDayEndBarID)
do if THC > GetValue(high, th) then THC else GetValue(high, th);
def True_Low = fold tl = ValidBarNumber - WideRangingDayEndBarID
to ValidBarNumber - WideRangingDayStartBarID + 1
with TLC = GetValue(low, ValidBarNumber - WideRangingDayEndBarID)
do if TLC < GetValue(low, tl) then TLC else GetValue(low, tl);
plot PTRH = True_High;
plot PTRL = True_Low;
plot MidLevel = ((PTRH-PTRL)/2)+PTRL;
input StartDate = 19501201;
def Days = DaysFromDate(StartDate);
def DownTrend = MovingAverage(averageType.EXPONENTIAL, OHLC4[-1], DowntrendEMA1) < MovingAverage(averageType.EXPONENTIAL, OHLC4[-1], DowntrendEMA2) and MovingAverage(averageType.EXPONENTIAL, OHLC4[-1], DowntrendEMA2) < MovingAverage(averageType.EXPONENTIAL, OHLC4[-1], DowntrendEMA3);
def EntryCondition = high crosses above PTRH and Days >= 0 and !(ExcludeDowntrend and DownTrend);
def EntryPrice = PTRH;
def ExitCondition1 = low crosses below ((PTRH-PTRL)/2)+PTRL;
def ExitCondition2 = if SecondsTillTime(1655) == 0 and SecondsFromTime(1655) == 0 then 1 else 0;
def ExitPrice = if ExitCondition1 then ((PTRH-PTRL)/2)+PTRL else if ExitCondition2 then open else 0;
def ExitNow = ExitCondition1 or ExitCondition2;
AddOrder(OrderType.BUY_TO_OPEN, EntryCondition, price = EntryPrice+Slippage+Commission, tradeSize = 1, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "");
AddOrder(OrderType.SELL_TO_CLOSE, ExitNow, price = ExitPrice-Slippage-Commission, tradeSize = 1, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "");
def EntryCondition = close crosses above PTRH and Days >= 0;
def EntryCondition = high crosses above PTRH and Days >= 0;
def EntryCondition = close[1] crosses above PTRH[1] and Days >= 0;
@Adeodatus Can you please link to the combined/modified code?WOW! Svanoy and DanB, and Merchman thanks! And M.Ward, I've a modified Matt-Ward (Ver 1/30/22) run with what i left on the other thread (sorry about that). Note with the latest change, a real solid indicator in low time frames. Surprise, this indicator will kill!
excellent!
Now to make into a scanner, uh, anyone?
I'm uncertain how to link images, tried. anyway, could Mod please fill me in how to post image. Its the same as #26 above, with the last code modification in #27. i won't post the modified TSchaffTrendHull code here, not to take over the thread. Its posted at :@Adeodatus Can you please link to the combined/modified code?
Unsure of how to upload screenshots to the forum, Here are directions.I'm uncertain how to link images, tried. anyway, could Mod please fill me in how to post image.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.