Showing posts with label Projects. Show all posts
Showing posts with label Projects. Show all posts

Saturday, August 22, 2009

Virtual order manager

Time to develop a virtual order manager.  This will potentially be useful now for the FIFO rules in the US, and also will help me to go through the thought processes needed to build one eventually in MQL5.

Although I've seen quite a few VOMs, the reason they have usually been developed is to avoid stop-hunting.  Many have the incredibly risky approach of eliminating broker stops entirely, which means you have no risk control if your internet connection or PC goes down.  Nonetheless, I should do a search for anything out there that might be useful first.

The VOM that I would like to see, or develop, goes like this:
  • Real orders at the broker reflect total position for that pair, but the VOM also maintains a virtual set of orders on the MT4/MT5 platform.  So you could be virtual long EURUSD 0.2 lots and virtual short EURUSD 0.3 lots, and the real position showing in the open orders display would be short 0.1 lots.
  • Virtual stops and virtual takeprofits are maintained as pending virtual orders in the opposite direction.
  • Maintain all the usual virtual Magic numbers and comments etc
  • Option to display virtual open prices, SLs & TPs on the chart
  • Lastly, the most important and the thing missing from most VOMs I've seen: maintain a real broker stoploss.  This will ensure that disaster protection is there, but under normal conditions should never be hit, ie shouldn't get in the way of the virtual stops.
[update 20/11/2009] a new post on Virtual Order Manager development

Friday, August 21, 2009

Neural Networks

Years ago, I developed a neural network in C++ for a share trading system. It never succeeded because it either wouldn't learn anything, or when it did I couldn't get it to stop curve fitting. Recently after re-reading about early stopping in neural networks (and also remembering the success of Better in the 2007 MT4 championships) I decided to give it a go on forex, and have been immediately encouraged.

Behind the science of neural networks is craft: by trial and error the neural network environment needs to be massaged until it yields some promise. Here's what I have come up with so far.
  • Start with a simple non-NN entry strategy which is not profitable and yields large numbers of trades, then use the NN to filter these in much the same way as a more traditional long term moving average would be used. This idea came from http://articles.mql4.com/777. Right now I am using a cross 4 bar high for long and cross 4 bar low for short, and both Stoploss and Takeprofit of 100 pips.
  • Use a series of inputs to the NN which are the close price differences from the bars with shift 1,2,3,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324. This is simply a gradually lengthening time between each close. Divide the difference by the square root of the time difference. This idea comes from Mark Jurik
  • Normalise the input vector
  • Use a standard simply connected 19-10-1 neural network
  • Here's the key new idea: early stopping -- run the learning backpropagation against factset 1 (say three months of 15 minute data), and select the NN which delivers the best equity curve on the following 3 months of data. Typically, and in agreement with many NN texts, the NN will continue to train past the point that it generalises
So here's what has happened so far in a short forward test from 7th August to 21st August - the equity has risen 700 pips with a max drawdown of 300 pips
Update on 26 August - I'm now running a forward test on my new virtual host