Creating a Forex EA - mql4?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Creating a Forex EA - mql4?

Post by PoLyGLoT » Sat Jun 29, 2013 5:12 pm

Hi all,

Is it possible to use livecode to create forex expert advisors? Or to analyze stock or currency charts and send an email when certain conditions are met?

I know this kind of thing is possible with MQL4 code, but I don't know MQL4 code at all so I was wondering if you could do this kind of thing within Livecode.

Thanks.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Creating a Forex EA - mql4?

Post by Simon » Sat Jun 29, 2013 9:07 pm

Hi PoLyGLoT,
More specific question to programming are, can LC:
Retrieve data?
Parse that data?
Perform actions based on the results of the data?
YES!

As far as copying Forex EA, that probably is a pretty big job as you'd have to get into legal stuff about unassisted financial transactions. They do have an API that might take care of that side of things.

But as you said "...send an email..." I'm thinking you want this for personal use? Maybe just read an html page and parse out the info you want then email you when the price is right?
Yes, LC can do that.

It would be a good fulfilling project to mess about with.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Re: Creating a Forex EA - mql4?

Post by PoLyGLoT » Sat Jun 29, 2013 9:45 pm

Hi Simon,

Thank you so much!! You've hit the nail on the head - this would just be for personal use. And instead of entirely automating things, I would love for it to be able to retrieve data and send me an email when certain conditions are met.

This would be truly awesome if I could tinker with this. Could you give me any idea on how LC can retrieve web data? Or how to make it send emails?

Thanks so much,
PoLyGLoT

PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Re: Creating a Forex EA - mql4?

Post by PoLyGLoT » Mon Jul 01, 2013 4:38 pm

Sorry for the shameless bump, but I'm hoping someone can answer these questions before the thread goes cold.

I'm wondering how LC can:

1) Analyze web data (or retrieve data from some other source in general)
2) Set it up to automatically email a specific address when certain conditions are met

I'd be very grateful for some input on these two fronts. I feel I can then tweak the system further once I've got my foot in the door.

Thanks,
PoLy

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7394
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Creating a Forex EA - mql4?

Post by jacque » Mon Jul 01, 2013 5:59 pm

The question is pretty broad which is probably why you aren't getting many responses. But in general, to retrieve a web page, you only need one line of code:

get url "http://www.google.com"

That will return the entire page content to the script. See "get" in the dictionary. Then you'd parse the content to extract the things you want, which will vary for every url. You'll need to examine the page content and figure out what parts of it your script needs. We can help you with that if you ask specific questions about it.

For email, there are several ways. The easiest is the built-in revMail command if you don't mind launching the user's mail client and having them physically send the mail. If you want it all done by script you can call out to shell. Or there are a few mail libraries floating around, though I think shell is a little more reliable.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Creating a Forex EA - mql4?

Post by Simon » Mon Jul 01, 2013 9:37 pm

Hi PoLyGLoT,
Grabbing the data isn't difficult, autosend of emails may be a bit trying for first time SMTP'ers.

OK the easy part:
New main stack with 1 field and 1 button. In the button put

Code: Select all

global gHTML
on mouseUp
put URL "http://www.nasdaq.com/markets/most-active.aspx" into gHTML
put gHTML into fld 1 -- just so you can see it
end mouseUp
That URL is just some stock exchange page with current values http://www.nasdaq.com/markets/most-active.aspx. You will see that it returns some 4000 lines of code you'll want to parse that down to just the stuff you want.
Now add a second button:

Code: Select all

global gHTML
on mouseUp
   put "" into fld 1
   put 0 into tStart
   put 0 into tEnd
   repeat
      if shiftKey() is down then exit repeat --use in case of runaway
      put wordOffset("class='mostactive'",gHTML) into tStart
      if tStart = 0 then exit repeat
      put wordOffset("</tr>",gHTML,tStart) into tEnd
      put word tStart to (tEnd+tStart) of gHTML after fld 1
      delete word 1 to (tEnd+tStart) of gHTML
   end repeat
put fld 1 into gHTML
end mouseUp
You will see that the now only the important stuff is left in gHTML and the fld.
You get to parse out the rest of the data. Look up wordOffset, lineOffset, offset in the dictionary (watch out "lines to skip" works but not how I thought it would).

Once you've completed that and made your value comparisons you'll want to send the alert email.
Here in the forums search on "SMTP".
I just tested using PowerShell on win7 and that worked. google "Send email powershell"
There are plenty of gotchas in any of the methods, just copying scripts didn't work for me because of things like port numbers.
Don't know the shell for Mac.

Have Fun!
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Re: Creating a Forex EA - mql4?

Post by PoLyGLoT » Tue Jul 02, 2013 4:29 pm

You guys rule. This gives me plenty of fodder for my own tinkering.

THANK YOU SO MUCH!

FarhatAltaf
Posts: 1
Joined: Tue Jan 07, 2014 12:35 pm

Re: Creating a Forex EA - mql4?

Post by FarhatAltaf » Tue Jan 07, 2014 12:42 pm

what is this forez ea .. ea stand for?
Last edited by FarhatAltaf on Fri Jan 10, 2014 11:41 am, edited 1 time in total.
http://in.pakbiz.com/India/currency_exchange_rates.aspx

Klaus
Posts: 14212
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Creating a Forex EA - mql4?

Post by Klaus » Tue Jan 07, 2014 7:59 pm

FarhatAltaf wrote:what is this forez ea .. ea stand for?
Is your GOOGLE broken? 8)
It may work, when you enter the correct search string. :D

Post Reply