NexusFi: Find Your Edge


Home Menu

 





Combining discretionary trading, risk management and ML as an art


Discussion in Emini and Emicro Index

Updated
      Top Posters
    1. looks_one aquarian1 with 40 posts (39 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 TheTradeSlinger with 1 posts (1 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 8,492 views
    2. thumb_up 40 thanks given
    3. group 14 followers
    1. forum 41 posts
    2. attach_file 18 attachments




 
Search this Thread

Combining discretionary trading, risk management and ML as an art

  #31 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

(In relation to the prior post - I may have not needed to go back to the spreadsheet)


Today I worked with weka again.

I found that if I first changed the relationship to:
(no class)
unsupervised discretized the attribute I wanted, then made it the class attribute I could then use the supervised discretization which included information gain in the binning.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Quant vue
Trading Reviews and Vendors
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #32 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

I've still been working with the ML.

Most I have been using Apriori which has no class attribute (unsupervised) and looks for associations.

At first, I was thinking I wasn't using it correctly and then I drop the minimum confidence level from the default 90% downwards and then I got some rules. (BTW you can't have numeric attributes - it will tell you this in the Log -so you want to use the filter "Numeric to Nominal" to process any numeric attributes.)


I had thought the using the discretization filter would be the way to bin, but I didn't think the results were very good for data with wide narrow tails - though perhaps it is - something to learn about later.

I wanted to create an example for readers to apply these ideas to, so I have chosen the overnight gap.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #33 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593


As most traders know there is an overnight gap fill idea.

The o/n gap is the difference between yesterday's close and today's open (RTH).

So for Dec 08 the gap was 7.00 (Close=2639.75 Dec 7 to Open=2646.75 Dec 8)

temp1.png

The idea in the gap fill is that most of the time the price will usually return to close the gap at some time during the day - that is at some point close the 7pt gap by falling to 2639.75.

Now a variation on the gap-fill setup is the progap. This is where it "gaps and goes" meaning on days with a "large" gap the gap fill trade won't work. So in the example above is +7 is a "large" gap it won't come back to Yclose of 2639.75.

So what is "large"? You can:
get all the gaps for past days (remembering to eliminate contract roll-over days)
bin the gaps
look for results with binned data.

So you might create bins of:
>+7.0 =very large up gap
+4 to +7.0 = large up gap
+0.0 to 3.75 = up gap
-0.25 to -3.75 = down gap
-4.0 to -7.0 = large down gap
<-7.0 = very large down gap

Here I've made 6 bins.
Bins do not need to be equal size.
You can also choose equal frequency binning (with the bin edges such that there are the same number of instances (observations) in each bin.

So we are taking a semi-continuous numeric series and nominalizing it into 6 types of gaps.

It depends on what you are trying to do (or for us trade).

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #34 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

Once you have your set of rules then you need to decide how to trade that info.

Will you wait for an up move and then sell? If yes how much of an up move?
Will you sell 1 at open, and a second at +3.75 to the open, and a third at +4.50 to the open - should it get there?
Will you use indicators for the timing of the sell?

Of course your stop limits on trades will come into play - too wide a stop and you suffer on a bad trade and too tight and it pushes trough and then reverses to win with you no longer on board.

If you're a Goldman Sachs (https://en.wikipedia.org/wiki/Goldman_Sachs) and can toss $100 mil into the experiment and take a good size drawdown.

If you're tiny retail almost any drawdown is "down and out." :-)

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #35 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

I've been working with my database and ML

(Below are examples only. I didn't use these i.e. -daytype, Y%ClsChg)

Let's say you are predicting daytype: if it is an up day, down day or flat day as measured by close-to-close.
So you might decide an up day is C:C of +3 or greater, down -3 of less and flat -3 to +3.

It seems the binning doesn't work the way I want (or at least I don't know how to make it work the way I want)
Consider a potential continuous variable e.g. the percentage change in the close.
-so values could be -15%, -6.8%, 0%, +5.4% etc


To use association ML such at J48, you need nominal values - not numeric.
A filter will nominalize these giving '-15%", '-6.8", etc

I was hoping the discretize would bin them - eg into ten bins. but it doesn't seem to work -except for equal frequency binning.

As with all things perhaps a difficulty is an opportunity.

So I work on binning (frequency distribution) within the spreadsheet - my database.


------------- on the next bit I'm not sure if I'm breaking some statistical rule or not ------------------
First I counted up, down, flat - so perhaps out of 750 instances you might have: 200 down, 300 flat, 250 up.
Then I would take my predictive attribute, yesterday's %chg in close (Y%ClsChg) and sort it eg ascending and use the vlookup function to give me the bin edges that would be approximately the same distribution 200,300 and 250.

I used these bin edges with a formula to discretize Y%ClsChg into -1,0,+1
(You could have a different number of bins, e.g. instead of 3 bins 5bins: -2,-1,0,1,+2)

------------- end of next bit ---------------------------

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #36 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

I thought I would post a summary of my findings so far. (Please understand I am not an expert with statistics in reading the below.)

1. There is a strong limitation in the understanding of trading by those who are experts in ML algos. For example, a common example is predicting the close of a stock and the forecasting lagging and so on are done for that. For futures trading for the retail trader the predictions of the close are next to useless.

2. For numeric data generally the ML experts look at it as a regression problem. However, at least in my approach, it it not. Looking at forecasting as classification problem becomes much more difficult as you must discretize your data and nominalize it. The choice of binning of your class attribute will greatly impact the usefulness of your final model(s).

As an example, if you have one bin for your class attribute you would be 100% accurate even if you are using the height of pine trees in Washington state as your predictor. If you have only two classes -e.g. "up day" and "down day" your accuracy will be at minimum the size of your largest class (using ZeroR). So if your data has 60% up days and 40% down days, simply predicting every day as an up day gives you a 60% accuracy.

So you need several classes for your class attribute (the thing you are trying to predict).

What is the correct number?
The answer lies in your trading and your data and the compromise of the two.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #37 (permalink)
 
TheTradeSlinger's Avatar
 TheTradeSlinger 
Huntington WV
 
Experience: Advanced
Platform: TradeStation
Trading: ES, CL
Posts: 483 since Jun 2015
Thanks Given: 877
Thanks Received: 682

@aquarian1,

Fantastic thread!

I've always thought about this but have never been able to test it: what if you "showed" the ML algo your winning trades and somehow had it identify/classify why they were winners, then have it look for more opportunities like your winning trades?

I probably butchered that explanation in terms of ML lingo, but do you see what I am saying?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #38 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593


TheTradeSlinger View Post
@aquarian1,

Fantastic thread!

I've always thought about this but have never been able to test it: what if you "showed" the ML algo your winning trades and somehow had it identify/classify why they were winners, then have it look for more opportunities like your winning trades?

I probably butchered that explanation in terms of ML lingo, but do you see what I am saying?

I understand your question.

So there are ML algos that they simply tell it to win. E.g. a video game and you just let it play tons of games and it will soon (like overnight) play perfectly, starting from terrible.

Another case is that they they let it play "Go" against itself and it beat a (the) world champion.
Of course there are limited dimensions to these games.
(I don't know how to do this ML BTW).


The thing about your question is the information has to be in what you show it.

That is we as humans might think that such and such combination of indicators contains the information that produced the successful trade and we may have made the trade and won, yet the reason we won wasn't in the indicator setup but was something else.

It (the ML) needs lots of data and the data must have the answer hidden in the data that you give it for it the ML to find the patterns.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #39 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

One thing I should mention was something I saw in a video about the dangers of ML.
The example given was an image classification ML.

The speaker showed a picture of a wolf and said - "why might you label this as a picture of a wolf?"
The shape of the snout perhaps?
the eyes?

The programers added some lines and ask the ML why it classified it as a wolf.
It showed the snow.

All the images it was trained on of wolves showed snow in the background.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #40 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593


I wanted to test is the surpervised discretization would break the same if I reduced the instances of the greatest count in the class attribute to equal the average count of the class attribute

I had 755 instances and 3 distinct classes giving 252 per class average.
Initially I had count of:
260=-1
165=0
330=+1
in the class attribute. I deleted 78 of the +1's bringing its count to 252.

The attribute I was testing for supervised discretization was initially broken at
-21.5 and 5.63 into 3 groups
and showed correctly classified at the top group +5.63 to +infinity of 67% accuracy.

Then (at the reduced count of 252) the attribute I was testing for supervised discretization was broken at
-21.5 and 5.75 into 3 groups
and showed correctly classified at the top group +5.75 to +infinity of 60.5% accuracy.

Conclusion
It works better when there is more variance in the dominant count of the class attribute (e.g. 330) then if all counts are about the same size (e.g.252). I think this makes sense as the supervised discretization is trying to maximize the information. However, it seems to be somewhat of an over-fitted giving a sense of greater predictive power than is really the case.

I think my rule of thumb is to have enough distinct classes in the class attribute to be meaningful broken into approximately equal bins. (Depending on what you are trying to predict and I think 5 distinct classes to be about correct balance in workable rules for the current class I am examining).

With 5 distinct classes I believe equal binning into 5 bins (of the predictive attributes) works well.

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:




Last Updated on March 31, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts