My shell EA code

Post Reply
Bruster400
Trader
Posts: 192
Joined: Tue Sep 24, 2013 3:19 pm

My shell EA code

Post by Bruster400 »

Steve,

I've had a go with the new BareBones and the only thing I've spotted is that in OnTick() you've left

Code: Select all

 if (TicketNo == -1)
rather than the

Code: Select all

 if (OpenTrades < MaxTradesAllowed)
that you'd suggested to me in an earlier post. No big deal, and you do comment that it should be removed for multi-traders but just thought I'd mention it so that people coding for multi-trades don't have to hunt it down.

Bruce

EDIT - just found another minor change that people might want to make. In GetTimeFrameDisplay(int tf) (line 676 BareBones) there are two entries for M15 and both return "M1" rather than "M15". Again, not a big deal and doesn't affect the EA's trading. I'm not trying to pick holes in the code - just trying to help.
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

My shell EA code

Post by SteveHopwood »

Latest versions of the three usual suspects are in post 1.

I decided to do something for our FIFO-blighted US cousins. Ok, so the closure code as was would eventually close out all the trades but it needed calling as many times as there were trades.

Load Bugger All Included into the editor and follow the bookmarks to see what I have done.

I assumed that lower ticket numbers would be older trades, so I declared an array to hold the ticket numbers of all the trades, then sort them in descending order so that the furthest back in time would be at the top of the array, and so on down.

Originally, all this code was within a user input IfLunaticFifoRulesApply and the code was redirected to a dedicated FIFO trade closure function. I realised later that we do not need a separate function because iterating through the array of ticket numbers is going to be more efficient that iterating through all the trades on the platform.

Usage will throw up anything that I have broken during this process.

:xm:
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. pianodoodler@hotmail.com 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
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

My shell EA code

Post by SteveHopwood »

I have uploaded the latest versions of my shells. There are a few amendments, and I have added extra variables for building up a picture of an open position - variables I was finding were needed in addition to those already in place.

semafor looks as though it offers a way of managing basket and hedged positions, so I have added the "Retro-fitting semafor-managed grid hedging.mq4" file to show you how to add this functionality to your own EA's created using my shells.

:xm:
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. pianodoodler@hotmail.com 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
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

My shell EA code

Post by SteveHopwood »

Latest versions of the shells are in post 1.

It looks as though grid trading, hedging and semafor are going to be oft-used features, so I have added them to the shells. Updated user guides are attached as well, along with "3 level". I will re-code the semafor stuff at some point; all the indi does is highlight the hilo of the previous x candles, so it is not rocket science.

I am finding myself increasingly needing to know the highest and lowest prices of baskets of trades, along with open times etc, so I have created groups of variables the CountOpenTrades() will populate automatically - you will see them lined up like little soldiers at the bottom of General Inputs.

:xm:
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. pianodoodler@hotmail.com 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
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

My shell EA code

Post by SteveHopwood »

I just added the lot size calculation from HGB'nG to the shells and updated the user guides.

:xm:
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. pianodoodler@hotmail.com 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
retireme
Trader
Posts: 131
Joined: Fri May 11, 2012 6:37 am

My shell EA code

Post by retireme »

Thanks Steve, awesome job indeed...

RM
To raise new questions, new possibilities, to regard old problems from a new angle, requires creative imagination and marks real advance in science. - Albert Einstein
Jagg

My shell EA code

Post by Jagg »

Steve, thank you very much for your shells :good:

What I don't understand are these two lines in the SendSingleTrade() function (line 890 in ShellAutoTradingRobotCode_BareBones_6xx.mq4 for example)

Code: Select all

      if(type == OP_BUY) price = MarketInfo(symbol, MODE_ASK);
      if(type == OP_SELL) price = MarketInfo(symbol, MODE_BID);
When I use the SendSingleTrade function I give my (calculated) price parameter with it. But above two lines "destroys" the given price parameter and set it always back to ask/bid?

Shouldn't it be

Code: Select all

      if((price == 0) && (type == OP_BUY)) price = MarketInfo(symbol, MODE_ASK);
      if((price == 0) && (type == OP_SELL)) price = MarketInfo(symbol, MODE_BID);
or something like that...

ok, forget what I wrote :arrrg: (when price is not at ask/bid we have to use other order types for that...)
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

My shell EA code

Post by SteveHopwood »

Latest versions of the three main shells are in post 1, with fixes for thingies that came up with use.

:xm:
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. pianodoodler@hotmail.com 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
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

My shell EA code

Post by SteveHopwood »

Updates to the three shells that I regularly use are in post 1, with the full offsetting code I am developing elsewhere. I have updated the Shell User Guide. This is an OpenOffice document. This is free and open source software, so do a Google search if yours does not provide the facility to convert documents to pdf format.
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. pianodoodler@hotmail.com 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.
zaguy
Trader
Posts: 43
Joined: Wed Feb 03, 2016 7:42 am

My shell EA code

Post by zaguy »

Thank you Steve. Much appreciated.
Post Reply

Return to “Coders Hangout”