- ago
Hopefully I can explain this well enough for folks to understand.

It would be great during live trading and back testing to be able to click on the chart to enter or exit a position. And when that is done the signal values are recorded and become the combinatorial logic for the entry or exit.

After writing it, the entry is more important to get the conditions as the exit can be optimized using the Optimization.

I can see folks using the building blocks wanting this feature. However for complex state machine trading systems I think this can be useful. I’m looking to get away from manually recording the signal levels and checking across many trades to reduce the combinatorial logic code.

0
175
Solved
18 Replies

Reply

Bookmark

Sort
- ago
#1
QUOTE:
during live trading and back testing to be able to click on the chart to enter or exit a position. And when that is done the signal values are recorded...

Isn't that what the Position Metrics Report (Performance Visualizer) is doing now?

Please explain what's missing in the Position Metrics Report. You realize you can add your own metrics to Position objects so they too appear in the Position Metrics Report. And you can use ScottPlot to produce a more detailed Position Metrics plot (in BacktestComplete) with all your desired annotations. What more could you want?

QUOTE:
for complex state machine trading systems

Off topic, but are you a computer engineer or computer scientist? I can tell you're a pattern trader.
0
Cone8
 ( 6.30% )
- ago
#2
Re: And when that is done the signal values are recorded and become the combinatorial logic for the entry or exit.
Nope, I don't understand it. What happens if you do it more than once?

By "signal values", do you mean "indicator values"? If so, context matters - did the values just cross over or under a value or are they relative to another indicator, and if so, which other one?

My feeling is that this idea is a whole new framework for maybe a WealthLab Version 20!
0
- ago
#3
QUOTE:
to click on the chart to enter or exit a position

Wealth-Lab is all about systematic trading. I.e. we look for clear rules (which can be executed by a computer) for our entries and exist.

What you describe is more like discretionary trading: You enter when things "look good". There are some problems with this to begin with:

First: Usually you click in the center of a chart so you see the future price development (of course in realtime trading this future is unknown).

Second: Your brain is a gigantic pattern recognition machine (trained in millions of years to see the tiger in the bushes). It is very, very hard to mimic such a pattern recognition with a computer.

Third: It is not clear if your "signals" are in any way repeatable and profitable in the future. There is no way to check this i.e. to run a backtest on unseen data. So it is very likely that your rules just worked once i.e. are perfectly curve fitted.

QUOTE:
And when that is done the signal values are recorded and become the combinatorial logic for the entry or exit

A computer would need a large number of these "signals". And even then it is hard to imagine how the computer should extract the interesting information:
What are the common properties of your signals?
Any price pattern? What are "similar patterns"?
Any indicator values? (example: RSI(12) is always between 15 and 25)
Any relative values? (ATR increased by 12%)

The search space is huge (there are a lot of things to look for) and it is not very clear how things should be combined.

Looks like a mission impossible.

Suggestion: Do not produce a set of signals for successful trades only, but also a second set of signals for losing trades.
(We cerate a high contrast in the data)
This can be done by either clicking on the chart, writing down dates and symbols and convert this to some entry/exit signals executable by WealthLab.
Or you write a simple strategy that produces some of your trades either winning or losing.

With such a set of winning and losing trades the computer can do interesting things:
Look through all available indicators, some indicator combinations, fundamentals, FRED data and so on.
For all these inputs (lets call them collectively "indicators") we can calculate if there is some kind of correlation which can tell the good trades from the bad trades.

This will give you a list of promising indicators which can be used in a systematic trading strategy and backtested for a larger portfolio and different date ranges.

Sounds Good?

Here comes the best news for you: A tool that does what I described above already exists within Wealth-Lab: It is the finatic.IndicatorSelection extension.

See https://www.wealth-lab.com/extension/detail/finantic.IndicatorSelection for details.

1
- ago
#4
QUOTE:
the finatic.IndicatorSelection extension.

It might be nice if you had a video on all its features.
0
- ago
#5
Well... you're not the only one who asks for such a video.
Looks like I finally have to learn how to create one...
2
- ago
#6
Nice. Looks like I stirred up a hornet nest.

So for each trade I can get the logical or numerical values for the terms I've listed below? That would help. However, I'm also interested in trades I should be executing but don't have a logical statement written for it.

I do this manually now and if the logic is not obvious, then I print out info on the screen to figure it out.

if ((Bull_Bull_pMacd_pHist_Cycle || Bull_Bear_pMacd_pHist_Cycle) && _ConsecUp_signalLine[idx] > 0 && _ConsecUp_signalLine[idx] < 23 && _ConsecUp_NNP_Close[idx] < 3 && _sma20[idx-1] < _sma20[idx] && Long_Position_Counter < 3 && _ConsecUp[idx] < 21)
... .... Place trade if above statement is true

else if (Bear_Bear_nMacd_pHist_Cycle && _ConsecDown_NNP_Close[idx-2] > 0 &&_ConsecUp_NNP_Close[idx] == 2 && (Last_Long_PriceMove < L_Last_Long_PriceMove || _sma20mHC[idx - 1] < _sma20mHC[idx]))
.... Place trade if above statement is true

Now there are other signals and variables that may not be in the above statements, but I may be interested in knowing the values.

Anyway, I'm working on a auto-trading system that supposedly generates 1217% (SPY Sectors) return vs. 140% SPY return.

Now given we need to pay taxes each year Is there a way to simulate tax rate when running a simulation over multiple years?

The below image shows extreme compounding when no taxes are paid.





0
- ago
#7
I must admit: I love this discussion forum!

Someone comes along and poses a seemingly stupid question. And in an effort to explain why this question is dump and by giving it a second thought, you discover that behind that seemingly stupid question there lurks a brilliant idea, which is really valuable, a missing link, something I was looking for since years.

Where this enthusiasm comes from? let me explain step by step.
0
- ago
#8
dowen started this thread with the question:
QUOTE:
...click on the chart to enter or exit a position

And the idea to "teach your PC well" by showing the computer these "example trades".

This idea is way out of the box.: As a systematic trader I hate manual interaction, I immediately see that it peeks into the future, and this "teach the PC" thing is science fiction.

On the other hand (here comes the second thought) for any machine learning (this is the technical term for "teach your PC well") we need good "target data" i.e. the "thing" the computer should learn. The better this data, the better the results, and we need a lot of such data.

So lets modify this idea a bit:

First: We need good examples and bad examples. The computer is too stupid to learn only from the good trades. We must tell him how a bad trade looks like also.

Second: To produce such example trades it is way too tedious to look at the chart and extract the good (and bad) trades manually. There is a computer that can do this silly work for us.

Summary: Write a Wealth-Lab strategy that finds the "best" and "worst" trades by peeking into the future. Then use these trades to "train" the computer - brilliant.
0
- ago
#9
First thing: We come to some primary decisions about our "Ideal Strategy":

As a retail trader I want to use market orders entered before market open and not too many of them (lets say about 10 entries per day which enables manual order entry).
We (arbitrarily) choose a holding time of 4 days (Example: Enter Monday morning, exit Friday morning). We choose to work on the S&P500 portfolio, this allows us to publish the resulting strategy in WL's public strategy ranking and hopefully show up in the top5.

Summary:
Enter Market on Open
Exit after 4 bars Market on Open
DataSet: WealthData S&P 500
10 entries per day

These choices are for demonstration purposes only. Of course you could start with other hold times, even dynamic ones. Or a completely different portfolio like an ETF selection, Cryptos, futures, etc...
0
- ago
#10
A C# Coded Strategy that produces example trades with the constraints mentioned above looks like this:
CODE:
public override void Initialize(BarHistory bars) {          indicator = new ROC(bars.Open,4);          PlotIndicator(indicator,new WLColor(0,0,255));          } public override void Execute(BarHistory bars, int idx) {          // Exit after 4 bars          foreach (Position foundPosition0 in OpenPositions)          {             if (idx - foundPosition0.EntryBar + 1 >= 4)                ClosePosition(foundPosition0, OrderType.Market, 0, "Sell after 4 bars");          }          // entry: very good trade or vary bad trade          string signal = "";          if (idx + 5 < bars.Count)          {             if (indicator[idx + 5] < -9.20) signal = "BAD";             if (indicator[idx + 5] > 9.30) signal = "GOOD";          }          if (signal != "")           PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0, signal); }       private IndicatorBase indicator;

0
- ago
#11
The same as a Building Block strategy:
0
- ago
#12
The same with an FxCondition (part of finantic.Eval extension) and a plot added (see build3 of finantic.InteractiveGraphics):


The condition reads:
CODE:
OffsetInd(bars, ROC(open,4),-5) < -9.2 || OffsetInd(bars, ROC(open,4),-5) > 9.3

For me this looks more elegant than these 3 condition building blocks shown above.
0
- ago
#13
When run on the last 20 years of WealthData S&P 500 we get:
Positon Count 49855 (as expected)
Profitable Position Count: 25799
Unprofitable Positions Count: 24056

APR: 15%
(this shows the upward bias in the market, we expected 0% without that bias)
Average Profit per Trade: 0.62%

The performance of this strategy is not worth looking at. We wanted something very different. Look here:

This is a histogram that counts the number of trades within a certain range of profits.
For example, there are 6072 positions which had a profit around 10 percent.

This distribution is quite unusual: It contains only very good and very bad trades.
Exactly what we wanted!
0
- ago
#14
QUOTE:
Now given we need to pay taxes each year Is there a way to simulate tax rate when running a simulation over multiple years?


This is off-topic. Please start another thread with this question.
0
- ago
#15
QUOTE:
Now there are other signals and variables that may not be in the above statements, but I may be interested in knowing the values.


This is the basic question behind all we did so far: What are the best indicators to tell the good trades from the bad trades?

Now that we have a very valuable list of "ideal trades" it is time to "teach your PC well"...
0
- ago
#16
I forgot to explain this one:
QUOTE:
Positon Count 49855 (as expected)

In our "Design-Wishlist" we had: "10 entries per day."

With a backtest over the last 20 years (20 * 250 trading days) this means
10 * 20 * 250 = 50000 entries.

In our trading strategy that produces the example trades the number of entries can be adjusted by asking for trades with a certain positive (or negative) profit. The higher the limit, the lower the trade number. (See also the distribution in Post #13).

This time I adjusted the limits to +9.3% and -9.2% by a two step trial end error "procedure".

Next time I'll use the histogram as shown in Post #13, adjust the resolution (width of bars) in Plot Composer (see finantic.IneractiveGraphics extension) to count the trades with a certain profit and adjust the limits accordingly.
0
- ago
#17
Just one last comment. This is better for an idea blog. I need to get back to trading and developing.

I will say Collective2 is great for publishing and tracking performance.

Is auto trading different than robo taxi? How does a robo taxi know an object is blocked by a car?

I like to think out of the box.

My approach given C code constraint evolves around state machines. However I do use a simple NN signal.

If our car is driving backwards, then why do we consider what is in front of us or above us.

There are reasons. To avoid to many rules our programing needs to understand the current state and what possible next states exist.

Now Elon has deem this not an acceptable approach and is using a super computer to come up with complex neural network based on vision. This is basically what humans do and then have rules developed in their energy efficient neural network.

However even though this neural network work is not written as a state machine, it will behave like a self modifying state machine which has been around for a long time.

Just hopefully it does not self modify into a state of hallucinations and if it does it needs to detect and go into a recovery state.

1
- ago
#18
I forgot about the ability to copy chart data to clip board. This should help in developing the logic for the state sequence.

Thanks.

Date/Time Open High Low Close Volume ConsecDown(NNPredictor(ND_Close_Direction_HP",0),1)" ConsecDown(SMA(MACD(Close,12,26),9),1) ConsecUp(NNPredictor(ND_Close_Direction_HP",0),1)" ConsecUp(SMA(MACD(Close,12,26),9),1) MACD(Close,12,26) MACDHist(Close,12,26,9) NNPredictor(ND_Close_Direction_HP",0)" SMA(Close,20) SMA(Close,200) SMA(Close,50) SMA(MACD(Close,12,26),9)
10/23/2024 37.86 38.08 37.09 37.81 25771162.00 2.00 0.00 0.00 7.00 0.97 0.18 3.07 36.61 NaN 35.06 0.73
10/24/2024 38.47 38.92 38.30 38.87 27015528.00 0.00 0.00 1.00 8.00 1.01 0.17 3.14 36.71 NaN 35.17 0.82
10/25/2024 38.72 39.20 37.47 38.01 51745568.00 0.00 0.00 2.00 9.00 0.96 0.10 3.14 36.74 34.79 35.28 0.89
10/28/2024 39.25 39.84 38.95 39.67 54652311.00 0.00 0.00 3.00 10.00 1.04 0.14 3.33 36.92 34.86 35.39 0.94
10/29/2024 40.56 41.96 40.36 41.33 81566346.00 0.00 0.00 4.00 11.00 1.22 0.26 3.60 37.23 34.94 35.55 0.99
10/30/2024 40.88 41.28 40.62 40.88 32004733.00 1.00 0.00 0.00 12.00 1.32 0.29 3.57 37.56 35.02 35.69 1.05
10/31/2024 40.98 41.01 39.73 39.78 48039769.00 2.00 0.00 0.00 13.00 1.29 0.21 3.50 37.82 35.10 35.78 1.09
11/1/2024 39.93 40.80 39.10 39.37 49930218.00 3.00 0.00 0.00 14.00 1.22 0.11 3.29 38.01 35.18 35.88 1.12
11/4/2024 39.03 39.12 38.17 38.25 35781986.00 4.00 0.00 0.00 15.00 1.06 -0.04 3.12 38.12 35.25 35.92 1.12
11/5/2024 39.43 40.13 39.11 39.51 36660442.00 0.00 0.00 1.00 16.00 1.03 -0.06 3.32 38.32 35.33 35.99 1.13
11/6/2024 42.32 43.63 41.86 43.40 96025021.00 0.00 0.00 2.00 17.00 1.30 0.17 3.86 38.76 35.44 36.15 1.16
11/7/2024 42.71 43.84 42.47 43.60 40670192.00 0.00 0.00 3.00 18.00 1.51 0.31 4.03 39.24 35.54 36.35 1.22
11/8/2024 43.44 44.09 43.10 43.69 44183719.00 0.00 0.00 4.00 19.00 1.67 0.37 4.13 39.63 35.65 36.55 1.29
11/11/2024 46.66 49.89 46.53 49.57 96319189.00 0.00 0.00 5.00 20.00 2.24 0.76 4.76 40.23 35.77 36.87 1.41
11/12/2024 49.02 51.26 48.52 51.05 77294935.00 0.00 0.00 6.00 21.00 2.78 1.04 5.10 40.87 35.91 37.24 1.57
11/13/2024 51.24 53.26 50.86 51.04 103319316.00 0.00 0.00 7.00 22.00 3.18 1.14 5.46 41.50 36.04 37.60 1.78
11/14/2024 51.99 52.30 49.70 49.73 60782759.00 1.00 0.00 0.00 23.00 3.34 1.05 5.28 42.08 36.16 37.95 2.01
11/15/2024 50.84 52.17 49.93 52.13 46939425.00 0.00 0.00 1.00 24.00 3.63 1.07 5.29 42.73 36.30 38.39 2.30
11/18/2024 51.50 52.81 51.04 52.13 61429321.00 0.00 0.00 2.00 25.00 3.81 1.00 5.54 43.41 36.44 38.78 2.61
11/19/2024 52.16 53.66 51.91 52.70 80331048.00 0.00 0.00 3.00 26.00 3.95 0.91 5.68 44.13 36.58 39.17 2.90
11/20/2024 53.88 54.17 53.06 53.72 70154542.00 0.00 0.00 4.00 27.00 4.10 0.85 5.89 44.92 36.73 39.59 3.19
11/21/2024 55.41 56.51 54.41 55.90 93957586.00 0.00 0.00 5.00 28.00 4.34 0.87 6.12 45.77 36.88 40.05 3.49
11/22/2024 55.64 56.86 55.31 56.49 65319602.00 0.00 0.00 6.00 29.00 4.53 0.85 6.38 46.70 37.03 40.49 3.74
11/25/2024 55.41 55.49 53.67 54.02 67058209.00 1.00 0.00 0.00 30.00 4.43 0.60 6.07 47.41 37.17 40.92 3.92
11/26/2024 52.44 54.00 51.54 51.70 67423310.00 2.00 0.00 0.00 31.00 4.12 0.23 5.65 47.93 37.28 41.27 4.03
11/27/2024 53.83 55.49 53.66 55.03 61783541.00 0.00 0.00 1.00 32.00 4.09 0.16 5.92 48.64 37.42 41.69 4.11
11/29/2024 55.48 56.36 55.21 55.21 29730878.00 0.00 0.00 2.00 33.00 4.04 0.08 6.15 49.41 37.55 42.07 4.16
0
Best Answer

Reply

Bookmark

Sort