My shell EA code

Post Reply
User avatar
mobthehop
Trader
Posts: 362
Joined: Wed Nov 16, 2011 12:16 am

Re: My shell EA code

Post by mobthehop »

I often see EA users mentioning error codes referring to invalid (too small) SL/TP and adjustments thereof....

Apologies, if I repeat myself but wouldn't this do as general routine check?

http://forum.mql4.com/43812

Cheers
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: My shell EA code

Post by SteveHopwood »

My recent internet downtime provided the opportunity to do some updating, so the latest update is in post 1. I have renamed the shell to reflect what it actually is. At the time I first named the code, I could not think of the word 'shell'. :lol:

I have done some rearranging of the filter coding in LookForTradingOpps and added Georges IBars thingy to int init() for the benefit of newly created platforms.

If anyone wants to save me a job by adding extra checks to all the lot size etc thingies and posting them here, then please feel free.

My attitude to such thingies is different. I mean my Serious Warning at the start of each of my threads. I figure that users unable to figure out such niceties for themselves should not be using trading EA's, so errors generated by their own stupidity are doing them a favour.

I remain able to be convinced otherwise, so do not be afraid to try.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: My shell EA code

Post by gaheitman »

SteveHopwood wrote:My recent internet downtime provided the opportunity to do some updating, so the latest update is in post 1. I have renamed the shell to reflect what it actually is. At the time I first named the code, I could not think of the word 'shell'. :lol:

I have done some rearranging of the filter coding in LookForTradingOpps and added Georges IBars thingy to int init() for the benefit of newly created platforms.

If anyone wants to save me a job by adding extra checks to all the lot size etc thingies and posting them here, then please feel free.

My attitude to such thingies is different. I mean my Serious Warning at the start of each of my threads. I figure that users unable to figure out such niceties for themselves should not be using trading EA's, so errors generated by their own stupidity are doing them a favour.

I remain able to be convinced otherwise, so do not be afraid to try.

:D
I'd rather spend the time now putting in the checks if it means the questions don't make it to the forums. Those sorts of questions destroy the signal|noise ratio of the forum and take up our time when we could be:
  • Coding
  • Trading
  • Sleeping (ahh, I miss that one most of all :>)
  • Any other damned thing in the world but get people started
I'm kidding (mostly). I'm happy to help people, but I'm happier not to have to help them. :D

George
markft
Trader
Posts: 81
Joined: Thu Dec 08, 2011 12:06 pm
Location: Sydney, Australia

Re: My shell EA code

Post by markft »

Hi Steve,

Found an interesting issue when trying to troubleshoot an issue in the swingOne thread.

FXCM offers some CFDs e.g. US30 index and Digits in the broker is set to 0 for these symbols. This has the side effect "multiplier" in the init function being set to 0 therefore making all SL, TP etc zero in turn.

Simplest solution is initialise multipler to 1 in init e.g.:

Code: Select all

int init()
{
//----

   //Adapt to x digit criminals
   int multiplier = 1;
   if(Digits == 2 || Digits == 4) multiplier = 1;
   if(Digits == 3 || Digits == 5) multiplier = 10;
   if(Digits == 6) multiplier = 100;   
   if(Digits == 7) multiplier = 1000;   

This should probably go to the shell EA.

Kind Regards,
Mahmut
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: My shell EA code

Post by SteveHopwood »

markft wrote:Hi Steve,

Found an interesting issue when trying to troubleshoot an issue in the swingOne thread.

FXCM offers some CFDs e.g. US30 index and Digits in the criminal is set to 0 for these symbols. This has the side effect "multiplier" in the init function being set to 0 therefore making all SL, TP etc zero in turn.

Simplest solution is initialise multipler to 1 in init e.g.:

Code: Select all

int init()
{
//----

   //Adapt to x digit criminals
   int multiplier = 1;
   if(Digits == 2 || Digits == 4) multiplier = 1;
   if(Digits == 3 || Digits == 5) multiplier = 10;
   if(Digits == 6) multiplier = 100;   
   if(Digits == 7) multiplier = 1000;   

This should probably go to the shell EA.

Kind Regards,
Mahmut
Fabulous. Will do.

Cheers

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
markft
Trader
Posts: 81
Joined: Thu Dec 08, 2011 12:06 pm
Location: Sydney, Australia

Re: My shell EA code

Post by markft »

Hi George,

I am guessing this thread is the home for DoneForTheDay.

I have been thinking of using DFTD to avoid further trades in the current session (and perhaps the next) session after a big price move in one session.

E.g. if the EU moved 80-100 pips beginning from the start of the FO or London Open, I am planning to use this logic to keep the EAs stay away from the EU until the start of the next session (or perhaps until next London if the move was sufficiently large). This maybe able to filter out some bad trades.

If you feel interested in this AND have the time I would appreciate if you could have a look. Otherwise I am happy to have a go and post the updated version here. Where can I find the latest version of DFTD - I am guessing it is in ChangeTheColour EA?

Cheers mate, :)
Mahmut
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: My shell EA code

Post by gaheitman »

markft wrote:Hi George,

I am guessing this thread is the home for DoneForTheDay.

I have been thinking of using DFTD to avoid further trades in the current session (and perhaps the next) session after a big price move in one session.

E.g. if the EU moved 80-100 pips beginning from the start of the FO or London Open, I am planning to use this logic to keep the EAs stay away from the EU until the start of the next session (or perhaps until next London if the move was sufficiently large). This maybe able to filter out some bad trades.

If you feel interested in this AND have the time I would appreciate if you could have a look. Otherwise I am happy to have a go and post the updated version here. Where can I find the latest version of DFTD - I am guessing it is in ChangeTheColour EA?

Cheers mate, :)
Mahmut
Sounds like a good idea, and I'm more than happy to let you make the magic happen. :D Mike has made the latest changes, so the last version is in ChangeTheColour.

George
markft
Trader
Posts: 81
Joined: Thu Dec 08, 2011 12:06 pm
Location: Sydney, Australia

Re: My shell EA code

Post by markft »

gaheitman wrote:
markft wrote:Hi George,

I am guessing this thread is the home for DoneForTheDay.

I have been thinking of using DFTD to avoid further trades in the current session (and perhaps the next) session after a big price move in one session.

E.g. if the EU moved 80-100 pips beginning from the start of the FO or London Open, I am planning to use this logic to keep the EAs stay away from the EU until the start of the next session (or perhaps until next London if the move was sufficiently large). This maybe able to filter out some bad trades.

If you feel interested in this AND have the time I would appreciate if you could have a look. Otherwise I am happy to have a go and post the updated version here. Where can I find the latest version of DFTD - I am guessing it is in ChangeTheColour EA?

Cheers mate, :)
Mahmut
Sounds like a good idea, and I'm more than happy to let you make the magic happen. :D Mike has made the latest changes, so the last version is in ChangeTheColour.

George
Sounds good! I will look into it. It might take a while e.g. 1-2 weeks before I get onto this - will post it here when done.

I will look into adding stuff such as auto calculate session times (taking into account daylight savings) as well if this is OK. This DST stuff always confuses me when setting manually so if I can just figure it out once during coding this should save pain afterwards. :)

Thanks again for preparing such a useful module.
User avatar
lhDT
Trader
Posts: 198
Joined: Tue Nov 15, 2011 9:52 pm
Location: Brussels/Belgium

Re: My shell EA code

Post by lhDT »

Maybe a dumb question, I used to shell to test a simple EA.
I used ReadIndicatorsValues() to setup the conditions but what function do I need to use to launch a trade ? And what function do I need to use to close that trade ?
I would like to do 1 trade at a time (a long or a short, then waiting to close).

Second question, what function should I use to close the running trade (also based on some other conditions) ?

In a prevous version of the shell I used a var to do this, but seems on the latest one, it doesn't work. I'm probably missing something ?
markft
Trader
Posts: 81
Joined: Thu Dec 08, 2011 12:06 pm
Location: Sydney, Australia

Re: My shell EA code

Post by markft »

Hi Steve, George, Mike and others who might be interested,

While working on an update to the swingONE EA I decided to build what I feel is an easier framework for building EAs that I think may interest you as well.

This is primarily based on the shell EA and I have incorporated other parts such as the DFTD and lock trading thread from Mike's CTC EA.

My primary motivations for this were:
- Easier to update all EAs based on this framework when there is a new bug fix or feature.
- The framework does not need to be edited for each EA based on it but instead it is intended to grow to accommodate all bug fixes and improvements.
- The framework does not include any trading logic at all - this logic is stored separately.
- Have everything stored under a source control system so it is easy for all to see differences between versions
- Even though the code is stored as multiple files a single .mq4 file should be created for easier installation.

I setup the following repositories to host this code:
https://bitbucket.org/mahmut/ct4-eabase
https://bitbucket.org/mahmut/ct4-eas

I have done this primarily for the EAs I will work on personally however if you like the idea I don't see why it cannot be used by all of us.

I have not documented it well yet so if there is anything not obvious I will be happy to clarify.

Please have a look if you have the time and I would very much appreciate your feedback. Also please keep in mind this is still a work in progress.

Kind Regards,
Mahmut
Post Reply

Return to “Coders Hangout”