This article is Part 3 of a forex auto-trading series I am currently undertaking. If you haven’t already done so you want to read through the other two parts before continuing on.
Over the last couple of days I’ve been racking my brain over how best to have WLD read open orders.
Think about this for a second:
If I am long 3 mini lots on the EURUSD, and I place a stop and reverse order to sell 6 minis on the EURUSD how should this order register on WLD?
Now before you contemplate an answer remember than CMS and WLD have two different order types. CMS has only buy and sell, Wealth-Lab on the other hand has Buy, Sell, Cover and Short - therefore our alerts are going to need to be a little more precise.
In answer to my question above though, in Wealth-Lab we will need to show 3 lots as being of the order type “Sell” and 3 lots as being of the type “Short” - as the first lot will see the closing out of an already existing position, whereas the next lot will be the opening of a new short position.
Okay, several other things I noticed about CMS’s order types is that they signal whether a position is attached to an already open position. In other words, if you attach a stop or limit order to a trade these stop and limit orders will be different to a limit or stop order that isn’t attached to another order.
CMS do this by simply denoting attached orders as “L” (limit) or “S” (stop) and unattached orders as “EL” (entry limit) or “ES” (entry stop).
This does help as we now know that every order that is denoted by an L or an S is one that is attached to an already existing position, therefore, it can only be a “Sell” order type or a “Cover” order type.
While this seems so much easier in print it ended up being quite a pain trying to get it down into code for orders that are unattached as we still needed to find out whether there were any orders that were open and didn’t have attached orders.
Anyway, here is the new code that you should paste over your existing VC# CMSAPI project.
Don’t forget to change the username and password fields in the script to your demo account’s username and password.
Hit F6 (or Build > Build Solution) and before you open up Wealth-Lab open up your VT platform and login to your demo account and place a few trades (otherwise nothing will register in your alerts screen in WLD).
Enter into a currency at market and then place a stop order for a lesser, or more quantity than the amount you just went at market with.
Try this for other currencies before opening up Wealth-Lab, maybe even place a few stop and limit entry orders with attached stops/limits.
Write down what Wealth-Lab will need to show - don’t forget that WLD uses Buy, Sell, Short and Cover so you may really need to nut out what will happen if you’ve put some complex orders on.
You should notice that when you open WLD and login to your broker that the orders display as your answers should.
You may also notice that attached stop and limit orders to entry stop and limit orders aren’t shown. There’s a good reason for this: these orders aren’t active - they’re an If-Done type of order, meaning that they will only become active if the entry stop or limit order turns into an open position.