Distribution Testing In ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Jus
@mcdon030 Hello Mcdon... I'm so glad to find this post and your indicator. Like you, I've Six Sigma background but very new to trading and coding. I like your ANOVA and DOE concept. I'll try them out and post results.


I updated it slightly, but the ANOVA code works as-is. Really, the possible combinations within this script didn't produce the desired results, which was to create a CSA. I would suggest just adding other indicators as well.


note: I ran over 200 tests before being comfortable enough to begin paper trading. It is good you have the LSS background as you will understand it more than most.
 
#mcd. I am new here and apologies for these noob questions but a: does the strategy repaint and b: how can I adjust the number of contracts please.


define repaint: It uses an average crossing so the bar after the cross could be used to confirm the signal. If you use the cross itself at that exact bar, then yes. This is main reason testing mean variances with a Combined Signal Analysis seemed appropriate to me - I wanted to see if entering at the cross (not the bar after) could some how be strengthened. if we all could be confident the cross wouldn't reverse at that bar or at least increase that probability, then we become rich knowing that the directional bias is sound :) How many times has everyone seen a cross and wish they entered at the exact moment? you really don't because its too risky.


Personally, I wouldn't trade this indicator at all. The whole purpose/ value isn't the indicator, it is ANOVA code within it. People who jump to trade without a trade plan, hundreds tests, etc. are destined to fail.
 
@mcdon030 Is there an updated version of this? I have one but am not too sure if its the good one. Seem like it when I compare it to other links. I figured I ask to make sure I have the most recent one. I like it.
 
Hello @YungTraderFromMontana Earlier this evening I downloaded the code which @mcdon030 posted in his post #30. Here is the link https://tos.mx/9wrcBOG

My Apology... I believe the latest study is https://tos.mx/P559NHT
He said to change the lines:

From:
BTOA =isopen && angledegrees <bullanglemult&& plot4>Plot3 && bn>=lowestbn && close crosses above Plot3 && isup;
def STCB = isopen && close crosses below entryPricestopu;
def BTCB = isopen && close crosses above entryPricestope;
to:
BTOA =isopen && plot4<Plot3 && bn>=lowestbn && close crosses above Plot3 && isup;
def STCB = isopen && close crosses below entryPricestopu[1];
def BTCB = isopen && close crosses above entryPricestope[1];
 
@mcdon030 I'm no coder but looking at one of the labels ANOVA has, the peak to valley label, looks like you might have a start of possibly being able to code a "Cup With Handle" indicator. just a thought in my mind, thank you for your great scripts.
 
@mcdon030 I'm no coder but looking at one of the labels ANOVA has, the peak to valley label, looks like you might have a start of possibly being able to code a "Cup With Handle" indicator. just a thought in my mind, thank you for your great scripts.

cup and handle is a different beast altogether. I'm better with Pivots and optimizations, but I believe Robert Payne has the best one i've seen...

I may tackle Cup and handle at some point as rounded tops and bottoms are similar. I keep noticing intraday reversals occurring with rounded tops and bottoms.
 
This is very interesting @mcdon030 . Thank you for sharing your work.

Here's a puzzling thing. I have made a few versions and now (I think) I have 2 main ones that I'm testing. First one is what I refer to as a hybrid of early verions "v1" and "v3"code (I only made the hybrid to remove some labels originally, but have since turned them back on) and the second one is your most up to date "Long and Short" version (including the line edits).

So here's what's puzzling me (testABC1 only, tested on /ES, 1 contract, 5m/5day):

1. The hybrid performs admirably! (as is - longs only) +$15,862, 48 trades, success rate 65.7%
2. The "Long and Short" version (selecting longs only) Amazing! +$20,920, 44 trades, (45 wins/3 losses = 102% success??)
3. The "long and short" version (selecting shorts only) +$11,262, 28 trades / 28 wins / 100%
4. The odd thing is that when using the 'long and short' version (selecting long and short), the results were not the same as combining the longs (2 above) and the shorts (3 above). Results: +$22,550, 39 trades / 38 wins / 97.5%
5. On some timeframes (tested 15m), the hybrid (original version) outperformed the 'long and short' version

My questions are:
1. I'm wondering how the entry selection process changed between these two versions that made for more trades (5m) and less profit/success on the early version and less trades/more profit & success rate on the latter version.

2. I'm assuming that selecting 'long and short' to run simultaneously, sometimes the strategy will not take a long trade because it is already in a short trade? Thus making the individual performances of 'long only' and 'short only' greater than a 'long and short' approach?

Thanks again @mcdon030 . Fascinating stuff.
 
Last edited:
thank you. I'm lucky enough to have someone pointing me in the right direction with regard to stats.

To answer to your questions:

1. It has been awhile, but my main concern was the ANOVA analysis piece - meaning, I most likely changed something to strengthen to ANOVA. Given the Anova analysis could be applied to all Combined Signal Analysis's (CSA), it was more important than the actual strategy itself

2. I haven't reviewed the code in along time, but TOS back tests will not take another position if currently in a trade. Concerning individual performance, your right.

While you didn't ask, I would like to respond to point 5. Using trend analysis in a chart aggregation under 10-15 minutes is almost impossible in my opinion. Intraday price movement is random. Using a higher time of 10-15 or higher for trend is almost required unless you know something I don't. If you do, lets chat :) That being said, using ORB may assist your intraday trend analysis as well.


PS: Chasing profits was my downfall in the beginning. if I were you, I would look into trade management vice determining best entry signal. There are some indicators which out perform others; however, scaling exists and/or letting runners run will help you outperform back tests. This can be proven if you create a code which tracks percentage change while in a trade then compare whatever exit your using. It will create reasonable estimates/targets unless you already use ORB targets.

Good luck.

-mcdon030
 
@mcdon030 , thanks for your reply. Answers and advice are greatly appreciated.

I definitely don't know something you don't. :) I just like to be in and out of trades as quickly as possible due to fear factor. That's why I scalp small timeframes and look for strategies that seem to be profitable on small timeframes with very little drawdown and exits designed to provide manageable losses. That being said, as I watch the indicator in action I sometimes see where an order has been triggered on a specific candle, only to be rescinded on that same candle. I don't know what percentage of the time this happens, but it could make it problematic for someone simply taking entries when they see that the indicator is displaying one.

I really like this indicator/strategy. I don't understand how it makes it trade signals as I don't know much about thinkscript other than to make small modifications and sometimes patch other people's work together. Speaking of which, I tried to add the following alert. I don't get an error, but I don't get any alerts either. Your thoughts are appreciated.

The AddOrder command (going back to ANOVA v1) is:

Code:
AddOrder(OrderType.BUY_TO_OPEN,BTOsig[-1], tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "ABC_LE");
AddOrder(OrderType.SELL_TO_CLOSE,STCsig[-1],tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "ABC_lx");

I tried both of the following Alert commands, but neither worked:

Code:
Alert(BTOsig[-1], "BUY ", Alert.Bar, Sound.ring);

Code:
Alert(BTOsig, "BUY", Alert.Bar, Sound.ring);

I've never taken a good look at ORB, other than to have a decent idea of what it is. I definitely don't know the strategies though. I will definitely give it a look.

Thanks again!
 
Hi @mcdon030 ,

Are you done updating this? The concept sounded very interesting & I'm down to help if you are still interested in continuing it.

You spoke of trade management, would mind explaining some of your thoughts on it? I'm currently building a system ( nothing crazy so far, but I started to realize it all about trade management that can make it or break a strategy) Should you be interested in working together, my discord is adiich#7527.

looking into this rn, have you looked into order flow pivots? Areas of Block volume can usually cause some reaction.
 
I was trying to figure out why signals are not given from 15:45-16:00 and found this code:
def errorout = if !daily && secondsFromTime(1545)>=0 and secondstillTime(1559)>=0 then 1 else 0;

What is the purpose of this? Is it possible to get signals during these 15 minutes?
 
I was trying to figure out why signals are not given from 15:45-16:00 and found this code:
def errorout = if !daily && secondsFromTime(1545)>=0 and secondstillTime(1559)>=0 then 1 else 0;

What is the purpose of this? Is it possible to get signals during these 15 minutes?

Good Question. The isopen and error out function operates differently since it is dependent on time frames. Basically, you want to take trades within a range and exit before market closes. Most would start with:

Code:
input opentime=0945;  ## risky to set at open
input closetime=1540;
def errorout = if !daily && secondsFromTime(1555)>=0 and secondstillTime(1600)>=0 then 1  else 0;

This will automatically get you out of trades so your not holding overnight. These functions will not apply to daily. You definitely want to have it align with your chart frame from my experience such as:

Code:
## 4  minute
input opentime=0945;
input closetime=1544;
def AP=getaggregationperiod();
def daily=if AP>=aggregationPeriod.DAY then 1 else 0;
def isopen=if daily then 1 else if secondsFromTime(opentime)>=0 and secondstillTime(closetime)>=0 then 1 else 0;
def errorout = if !daily && secondsFromTime(1556)>=0 and secondstillTime(1600)>=0 then 1  else 0;

It may make sense just take make a label to alert you to exit just in case
 
@mcdon030 Thanks for the response. I have tested the latest version of your indicator that was posted here and I like it a lot. The main issue is that it gets eaten up during ranges and the backtest results indicated in the lower profit/loss study are impossible to actually achieve. Do you use this indicator in your trading? I would love to know how you do it and if you use any other indicators to complement this one or identify potential problem areas where you would stay out of trades. Any updated version of this indicator by the way?
 
@mcdon030 Thanks for the response. I have tested the latest version of your indicator that was posted here and I like it a lot. The main issue is that it gets eaten up during ranges and the backtest results indicated in the lower profit/loss study are impossible to actually achieve. Do you use this indicator in your trading? I would love to know how you do it and if you use any other indicators to complement this one or identify potential problem areas where you would stay out of trades. Any updated version of this indicator by the way?

I don't use this indicator. The reason for the thread is distribution testing. If your combining signals, simply use some type of volume, trend analysis averages of some sort) and pivot script with 3 higher time frames using all 3 for intraday. Look for confluence. You can account for win smart moves price, but proper risk management helps in those events
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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