Implementing Trader into PAM

As a follow up from the previous post, I made quite a few errors designing Pam's feature input and have now fixed them.  In addition I introduced Pam two new features:

Body Length ratio between current candle and last candle

Body Length to Wick Ratio of current candle

I retrained Pam with a very high lambda and less amount of nodes () .  The model overall had a better Validation and Testing fit.  I also skipped out on adding polynomial features for now and only relational (ex: ) features.

I decided to bring it to the test set of EUR/USD 4hr chart.  I saved the theta from USDJPY training into a file and loaded that along with the Trading test set of features and OHLC prices for the trader to reference to.   To test for overall confidence level, I first forwardfed the thetas and features and plotted the resulting 2363 confidence results.

1
2
3
4
5
theta_1 = reshape(t_theta(1:n*j),n,j); %n = num nodes, j = num features (bias added manually)
theta_2 = reshape(t_theta(n*j+1:end),1,n+1);
p = forwardPropagate(X, theta_1);
p = forwardPropagate(p, theta_2);
hist(p);
Pam's not very sure
Pam's not very sure

 

It didn't surprise me that the confidence level is range around the 50s.  She only learned so much off one small data set from one currency pair and now I'm applying it on a different pair.  Now it was time to implement the trader.  I experimented with threshold >=  0.508 with majority of the confidence level and threshold >= 0.51 which yields less trades.  In addition, I set these trade rules:

 

- Starting capital of $50,000

- Enter a trade with 100% capital

- Close position on next candle's Close

- Stop loss set at the low wick of the current candle

 

The stop loss and no stop loss method has been tested and no stop loss method seem to yield a better return but for now, I will keep it in the trader.  The results for the two threshold are below:

 

Threshold >= 0.508

Ending Capital: $48,690.85

Number of Trades: 351

Standard Deviation: 581.307

Threshold >= 0.51

Ending Capital: $50,172.57

Number of Trades: 33

Standard Deviation: 166.26

Trader's historical capital

 

As we see, the higher the confidence level, the better the performance of the trader and less risk as well.  However, we would be susceptible to sampling bias if we are to conclude that having higher marginal confidence level would create more wealth.  More samples will need to be taken as well as further work training the neural network.  My github project for Pam is hosted here, feel free to work with that and improve the fit.

Leave a Reply

Your email address will not be published. Required fields are marked *