# Metastock and FX



## MS+Tradesim (17 November 2008)

Anyone else chart FX with MS? I have lots of ideas but difficulty writing the code - my brain isn't wired too well for writing the complexity needed (the ideas are simple but the code is complex for me anyway). Anyways, just thought I'd test the waters and see if anyone is interested in collaboratively developing ideas. For example, I'm working on a trailing stop concept at the moment that adapts based on volatility. Choppier markets, further away...smoother markets, tighter in. See pic: blue line trails longs, red line trails shorts.


----------



## wabbit (17 November 2008)

A couple of pointers?

If trading FX, maybe a better product to code your ideas in is MT4 which uses a much more powerful language than MS.

If you must use MS (for whatever reasons) have a look at some of the many examples of LeBeau Chandelier exits that can be found on the web.  (Google)  Perhaps you might be able to exploit Richard Dale's excellent (and free) trailing stop add-in available from http://www.tradernexus.com/advancedstop/advancedstop.html  If you need some more specific examples get in touch, I might have something which might be useful?

If you are really to extend the complexity of your stops system in MS, I would suggest writing the code as an add-in.  (You will need the MDK and a compiler; you can code in C/C++, PowerBasic, Pascal or any other language with a compiler which can create Win32 DLL)


Hope this helps

wabbit 

(Perhaps you could shed some more light on the system/concept?)


----------



## MS+Tradesim (17 November 2008)

Hi wabbit,

Thanks but it's not specific solutions I'm after, at least at the moment. Rather, I'm looking to see if others are interested in working together on ideas - the trailing stop is just an example of something I'm working on right now. It would be great to see some collaborative work on various ideas, similar to how people are helping each other in the scalping thread. I know you're an MS guru and if you say Metatrader is more powerful, I believe you, but I like MS and I'm comfortable with it for the moment.


----------



## MS+Tradesim (18 November 2008)

Blagh! I'm tired and grumpy...and happy to do it on my own. Just thought there would be a bit more interest in community co-operation. Bah. Humbug.


----------



## wabbit (18 November 2008)

I could join in a collaborative effort, but this will have to be either very quick or wait - - I am off on my annual three month holiday, leaving in less than two weeks.  I will be back at the end of Feb '09 so if you're still looking then, give me a shout.



wabbit


----------



## MS+Tradesim (18 November 2008)

Sounds great. It can wait. Be very happy to have you around.


----------



## MS+Tradesim (18 November 2008)

Anyone interested in the trailing stop code? It can be easily adapted for different instruments.


----------



## wabbit (18 November 2008)

Give me a call.... wabbit.com.au


wabbit


----------



## MS+Tradesim (9 February 2009)

The downside of Metastock is it really doesn't integrate well with trading platforms. But I'm slowly solving that for myself. Here's a screenshot of my current FX trading layout. All entry and stop values generated by MS are written to trade files. The DDE interface in Excel reads those files, calculates position sizes and creates orders. I've reduced it to a few buttons for buy, sell and cancel, which transmit the orders into IB. Buy/sell buttons also submit modifications to current open orders. It would be quite easy to take the next step and have the orders automatically submit rather than needing to press a button, but I have a few more kinks to work out before it's completely functional and safe to automate. Would be easier if I knew C.


Well, I'm excited.... 


Sad, I know.


(BTW, in case someone is wondering, the charts are only indicating entry points. Exits are not shown in this pic.)


----------



## wabbit (9 February 2009)

Hi MS,

Obviously you have the IB TWS API working from Excel (I assume you use VBA, not calling another .dll?) so, it should be a "simple" matter to complete the project for autonomous trading.

Yes learning C/C++ might help out - - but as you seem adept at programming in VisualBasic, you might consider PowerBasic as an alternative as it is very similar to VB but can compile Win32.dlls.  If you write standalone function libraries well, they can be called from any application, alleviating the dependence on just MS and Excel.


wabbit


----------



## MS+Tradesim (9 February 2009)

Hi wabbit,

Alas, I am not even that advanced. I've figured out how the sample DDE file from IB works for the actions I need. I've then used the macro recorder in Excel to copy mouse and keyboard actions which I then assign to the various buttons. I can visually inspect the macro code to ensure it's not doing anything untoward, but I couldn't write it from scratch.

Learning ANY language would be progress on where I currently am. 

Ps. And learning something is now a goal for me. What would you suggest as a good starting place for an absolute beginner?


----------



## AbundantIncome (9 February 2009)

wabbit said:


> I could join in a collaborative effort, but this will have to be either very quick or wait - - I am off on my annual three month holiday, leaving in less than two weeks.  I will be back at the end of Feb '09 so if you're still looking then, give me a shout.
> 
> 
> 
> wabbit




wow ... 3 months ??? i like that lifestyle ... contaminate me with your ability to trade forex and lifestyle


----------



## MS+Tradesim (9 February 2009)

Ps. Wabbit...re: my original reason for this thread - I discovered the Tradesim.dll handles trailing stops way more elegantly than anything I can come up with, so I've simply used it where necessary.

Pps. Hope Tibet is treating you well.


----------



## Stormin_Norman (9 February 2009)

im keen to work on ideas.

i have a computer programmer business partner who's very adept at C and its derivatives. 

i trust metastock uses a C derivative code?


----------



## wabbit (9 February 2009)

AbundantIncome said:


> wow ... 3 months ??? i like that lifestyle ... contaminate me with your ability to trade forex and lifestyle




I have done my time working... now I just study and trade.  We take at least three months off each year to travel; this year we have several shorter trips planned, but we still envisage travelling for at least three or four months.  Of course, if we get contracts then we might have to curtail our holidays somewhat, but then again we don't accept every contract that comes our way.  Fortunately, we can pick and choose what suits us best each time.

As for trading fx:  Last year I was working with IBFX, but I have today opened an account with GO Markets in Melbourne.  I have several expert advisors that work with varying degrees of success.  I believe the key to surviving in the fx market (and indeed any market) is good risk management and trade management.  If you have these things squared away, you could trade by throwing darts at the chart and still make money; I believe specific entries and exits are secondary to the management skills.

A bit of luck also helps.  (I recently read Nassim Nicholas Taleb:- Fooled by Randomness, The Hidden Role of Chance in Life and in the Markets.  I thoroughly recommend this book to everyone.)  I have my lucky EA, that if you are VERY aware that it is possible for the entire account to be wiped out in a single session, you can make a few dollars relatively easily (or lose the lot!)

I hope the new broker works as well for me as the old?  I will be starting from scratch again, with a small test account.  If the broker performs as expected, I shall increase the account; but only time will tell.



MS+Tradesim said:


> Ps. Wabbit...re: my original reason for this thread - I discovered the Tradesim.dll handles trailing stops way more elegantly than anything I can come up with, so I've simply used it where necessary.
> 
> Pps. Hope Tibet is treating you well.




Tradesim does have some nice stuff in it, but it is not as easy to customise as writing your own works.

Tibet was VERY cold.  We didn't have a thermometer with us, but we guessed the temperature at Everest Base Camp (Tibet) to be about -20C, maybe colder?  Although it was cold, the skies were clear and the winds were relatively gentle.  Visibility was awesome at those altitudes.  It beats me why more tourists dont travel to places like that at this time of year - - there are very few other people around (no crowds), everything is cheaper in the off season; you just have to put on some extra layers of clothes to cope with the cold!

Nepal was excellent.  I thoroughly recommend that if you have ever thought of doing any trekking in Nepal that you go sooner than later.  They are building a road around the Annapurna Circuit, and there is speculation that within a year or two there will be a road from Lukla to Everst Base Camp (Nepal).  It's a shame, but they call it "progress"?!  (This from a country which has 19 hours per day of blackout! (NO power) unless you bring your own generators!)



Stormin_Norman said:


> im keen to work on ideas.
> 
> i have a computer programmer business partner who's very adept at C and its derivatives.
> 
> i trust metastock uses a C derivative code?




Metastock has its own built in scripting language; it's nothing like C.  However, if you have MetaStock Developers Kit, you can write and compile Win32.dll libraries of functions to be called from MetaStock (they also work for Bullcharts without modification).  As you are writing Win32.dll files, you can write them in whatever language you like, C/C++, PowerBasic, Delphi Pascal etc, just so long as it's compile as Win32.dll


Hope this helps.

wabbit


----------



## Stormin_Norman (9 February 2009)

wabbit said:


> As for trading fx:  Last year I was working with IBFX, but I have today opened an account with GO Markets in Melbourne.




pretty much the same path ive taken. so far so good. let us know how you get on too.





> (I recently read Nassim Nicholas Taleb:- Fooled by Randomness, The Hidden Role of Chance in Life and in the Markets.  I thoroughly recommend this book to everyone.)




ill second that recommendation.




> Metastock has its own built in scripting language; it's nothing like C.  However, if you have MetaStock Developers Kit, you can write and compile Win32.dll libraries of functions to be called from MetaStock (they also work for Bullcharts without modification).  As you are writing Win32.dll files, you can write them in whatever language you like, C/C++, PowerBasic, Delphi Pascal etc, just so long as it's compile as Win32.dll




ill forward that onto him and get his response. it went slightly over my head.

thanks for the post wabbit.


----------



## nizar (9 February 2009)

wabbit said:


> (I recently read Nassim Nicholas Taleb:- Fooled by Randomness, The Hidden Role of Chance in Life and in the Markets.  I thoroughly recommend this book to everyone.)




You should read the follow up as well (The Black Swan). Its just as good.


----------



## wabbit (9 February 2009)

Nizar,

Personally, I didn't enjoy the second book as much as the first. A lot of the stories, anecdotes and information was repeated and the author's smugness (for want of a better word) got worse in his second instalment.

The message though, is still loud and clear; well presented in both issues from Taleb.


wabbit


----------



## MS+Tradesim (9 February 2009)

Hey wabbit, seeing you're still on now....

What's a good programming language to learn first for someone who's never really done any (beyond the basic MS and Excel scripts)?

Tibet and Nepal sound nice. I like the cold but I'd never get my wife there. 

Cheers.


----------



## wabbit (9 February 2009)

MS+Tradesim said:


> What's a good programming language to learn first for someone who's never really done any (beyond the basic MS and Excel scripts)?




One of the most powerful languages is C++.  It's relatively easy to learn; start with one of those "teach yourself in 24 hours" type books and download a free compiler (there are dozens).  Start simply with some command line applications like the ubiquitous "hello world" and work your way up from there.  For the majority of instances, you wont be writing applications with its own graphical user interface, so you should be able to concentrate on "number-crunching" and algorithmic applications required to support trading.

Once you have a grip on a high-level programming language, it is quite easy to apply this knowledge and learn just about any other programming language by understanding the syntax of the new language. e.g. to do a loop in C/C++

for(int i=0; i=10; i++)
{
//do something
}

in Visual Basic
For i = 0 To 10 Step 1
//do something
Next i

in matlab
for i = (0:10)
//do something
end

All you have to know is the what you want to achieve and the syntax required to achieve that goal in the current environment.

Another reason to learn C/C++ is because it will give an introduction to a vital concept of memory management called "pointers"  (You'll learn about them when you need them, so don't worry too much for now).


Hope this helps.

wabbit


----------



## MS+Tradesim (9 February 2009)

Thanks mate. Will have a look at those "Dummy/Idiot"  books.  That will be an auspicious start.


----------



## wabbit (9 February 2009)

Not that you wont learn from the "Dummies" series, but I think the "Teach Yourself C++ in 24 Hours" from SAMS publishing (http://vig.pearsoned.com/store/product/1,1207,store-15080_id-4230_isbn-0672329417,00.html) or the Wrox Press books (http://www.wrox.com/WileyCDA/WroxTi...nning-Visual-C-2008.productCd-0470225904.html) are the better ones to learn from, and they also provide a handy reference for later.

wabbit


----------



## Stormin_Norman (9 February 2009)

might have to get myself that 21 lessons one. i can pretty much read the code now. the next step is to learn how to program it.

howd u learn c ?


----------



## wabbit (9 February 2009)

I have been writing computer programs and algorithms since I was 10.  I never got into the graphics side of things, but always maintained an interest in computing through my working career.  I quit working and went to Uni and received formal recognition of my skills (and learned a few new ones too).

I learned most from having a project in my mind.  You start working on it, and each time you come across a hurdle you go out and find the knowledge required to get over the hurdle or solve the problem.  You could, for example, start learning a language by writing (over time) the automated trading system interfacing MS with IB TWS through their API.  You might not know how to go about it right away, but over time, with some dedication, study and google, you should end up with a working product.  Programming is harder to learn if you don't have an objective in mind.


wabbit


----------



## MS+Tradesim (9 February 2009)

wabbit said:


> I learned most from having a project in my mind.  You start working on it, and each time you come across a hurdle you go out and find the knowledge required to get over the hurdle or solve the problem.  You could, for example, start learning a language by writing (over time) the automated trading system interfacing MS with IB TWS through their API.  You might not know how to go about it right away, but over time, with some dedication, study and google, you should end up with a working product.  Programming is harder to learn if you don't have an objective in mind.




This whole paragraph sums up what I'm trying to do at the moment.  100% agree with being objective guided. I figure out what I want to do and then look around in Excel help and google until I find the answers. So I may as well take the next step and learn to do stuff in code rather than limiting myself to excel scripts.

Thanks for the book recommendations.


----------



## AbundantIncome (9 February 2009)

wabbit said:


> I have done my time working... now I just study and trade.  We take at least three months off each year to travel; this year we have several shorter trips planned, but we still envisage travelling for at least three or four months.  Of course, if we get contracts then we might have to curtail our holidays somewhat, but then again we don't accept every contract that comes our way.  Fortunately, we can pick and choose what suits us best each time.
> 
> As for trading fx:  Last year I was working with IBFX, but I have today opened an account with GO Markets in Melbourne.  I have several expert advisors that work with varying degrees of success.  I believe the key to surviving in the fx market (and indeed any market) is good risk management and trade management.  If you have these things squared away, you could trade by throwing darts at the chart and still make money; I believe specific entries and exits are secondary to the management skills.
> 
> ...


----------



## Stormin_Norman (9 February 2009)

AbundantIncome said:


> Now, what is with changing from IBFX ??? I have read so many bad comments about it... the reason I am tyring their demo is because my brother overseas is demoing an EA and thought i might want to do the same ... :d two is better than one hehehe




i dont know about others, but i never have had a problem with IBFX. always paid, never had any major problems with slippage or stop hunting.

only reason i changed was because gomarkets were australian. i am running my EAs on both system simultaneously to spot any differences, if none ill shift all my Ea funds across.

IBFX arent the best broker, but i did my research and couldnt find any better MT4 retail broker.


----------



## nizar (9 February 2009)

wabbit said:


> Not that you wont learn from the "Dummies" series, but I think the "Teach Yourself C++ in 24 Hours" from SAMS publishing (http://vig.pearsoned.com/store/product/1,1207,store-15080_id-4230_isbn-0672329417,00.html) or the Wrox Press books (http://www.wrox.com/WileyCDA/WroxTi...nning-Visual-C-2008.productCd-0470225904.html) are the better ones to learn from, and they also provide a handy reference for later.
> 
> wabbit




Thanks for those links wabbit.
But do you think its better to go for those books or the ones that are more trading specific?
Eg.
http://www.amazon.com/Financial-Tra...r_1_10?ie=UTF8&s=books&qid=1233930460&sr=8-10

http://www.amazon.com/Modeling-Maxi...=sr_1_6?ie=UTF8&s=books&qid=1233930460&sr=8-6


----------



## wabbit (9 February 2009)

For somebody wanting to learn to program, I'd recommend the "Learn" books.  The system design books (I imagine) are for those who already know something about programming (I don't have these books myself, and am not going to fork hundreds of dollars to find out! The "modelling" book appears to be focussing more on methods of modelling than programming anyway.)

wabbit


----------



## wabbit (10 February 2009)

Stormin_Norman said:


> i dont know about others, but i never have had a problem with IBFX. always paid, never had any major problems with slippage or stop hunting.
> 
> only reason i changed was because gomarkets were australian. i am running my EAs on both system simultaneously to spot any differences, if none ill shift all my Ea funds across.
> 
> IBFX arent the best broker, but i did my research and couldnt find any better MT4 retail broker.




Same here.  No problems with IBFX, but I just like to have my money a little closer to home, and getting phone support from GO is easier than phoning the USA.  The folks at IBFX were always helpful and quite knowledgeable, their services were (nearly) always top-quality (no-one scores 100%).  Although most of my trading was with pending orders, I never had re-quotes when I was using immediate orders; my stops were always executed fairly and within expectation of the market events at the time.

My demos have been running well on GO servers for months, so (as I have previously posted) its time to run a real-funds test.  I hope GO will perform at least as well as IBFX.

The only reason there is so much negative sentiment posted about IBFX is because they have a large customer base; as there are so many people, some will be less than satisfied with the services they receive (and some (most?) try to blame their losses on someone else rather than accept their own greed/stupidity) and it is these people whom you see post on the internet.  It's rare to ever see people post out-of-the-blue about an excellent service, but it seems to be human nature that when someone is pi55ed off by something, we hear about it immediately.  As I said, I never had a problem with them.

I will let you how things go with GO (good or bad).


wabbit


----------

