molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming
http://www.molanis.com/forum/

A few quick fixes I stumbled upon...
http://www.molanis.com/forum/viewtopic.php?f=3&t=1466
Page 1 of 1

Author:  RJo [ Tue Jun 05, 2012 11:08 am ]
Post subject:  A few quick fixes I stumbled upon...

Here are a few things I was recently able to solve (for the most part) in SB 3.15. I thought some other lost soul might like to know.

For reference, I'm using 64 bit Windows7, IBFX (US) MT4, mini (5 digit, "m" suffix), SB Pro.


Issue: Generated EA would not trade on designated symbols (as opposed to current symbol where it would trade). Repetitive error: Not enough margin to trade. I see other users have reported this.

Solution: Hard code the pair symbol suffix(s) in MetaEditor. Note that I still cannot replace the "attached to" chart symbol (current symbol) with a designated symbol--error still occurs. However, in a multi-pair EA, I can add the "m" suffix to the "secondary" pair symbols and the EA will trade all symbols. Also note that this partial solution makes Max Number of Positions count open positions by pair, so if Max = 5, you get 5 pair A plus 5 pair B.


Issue: Mutually exclusive dynamic entries needed (as opposed to fixed pip Martingale).

Solution: Thanks to molanisfx, I was able to copy and paste CalculateOpenPositions (from around line 700 something) as an additional trading condition with slight modification. This can be exploited to enter multiple positions at different levels of the same indicator without fear of entering say... all 5 positions at level -0.00286 during high volatiliity for example:

if ( ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= -0.00236 ) && (CalculateOpenPositions("AUDUSDm",OP_SELL,MagicNumberShort)<=0) )
{ SELL("AUDUSDm",S_AUDUSD_LS_0,S_AUDUSD_TP_0,S_AUDUSD_SL_0,S_AUDUSD_TS_0,"if ( ( iCustom(Symbol(),0,NzdUsdm_AudUsdm,0,0) <= -0.00236 ) && (CalculateOpenPositions(AUDUSDm,OP_SELL,MagicNumberLong)<=0) )") ;}

Not sure how much of this code is superfluous, but it works. I read that another user created OCO (one-cancels-the-other orders, or straddle orders) using the same idea.


Issue: Even after using CalculateOpenPostions, trading every tick would enter all 5 positons immediately.

Solution: Hard code Sleep() from 250 to 5000. I read that RefreshRates() between each count condition is more reliable but I have yet to try it. [update: Apparently RefreshRates() only helps if you're using predefined variables like Bid, Ask, or Digits.]


Finally, I would like to ask what the rules/preferences regarding public posting of mq4 files at OTHER forums are. I bought SB/TIB to make my own EA's and indi's, but I sometimes like to share stuff.

Author:  molanisfx [ Tue Jun 05, 2012 5:19 pm ]
Post subject:  Re: A few quick fixes I stumbled upon...

The software use the 6 letter standard for currency pairs like AUDUSD, the AUDUSDm or similar is created for the broker and is not an international standard, so we do not use it. As you said just changing AUDUSD for AUDUSDm manually will make it work

Here some rules about selling eas and posting them on the internet: You can sell any eas created with molanis and put your own copyright if you only distribute the .ex4 file, you can post them in other sites as long as you do not change the copyright in the ea - it's at the beginnig and in every important function. You cannot sell part of the eas or ea code as a template or script to create eas. You can sell your eas as an ea, to avoid people copying your ea you may want to sell the .ex4 and do not show the code.

Author:  RJo [ Wed Jun 06, 2012 9:09 am ]
Post subject:  Re: A few quick fixes I stumbled upon...

molanisfx wrote:
You can post them in other sites as long as you do not change the copyright in the ea - it's at the beginnig and in every important function.


"Them" meaning the mq4's? I know the software and the terms are written for commercial users, but I do not sell anything. I intend to post the mq4 file free of charge, for the purpose of collaboration with, and potential revision by, the public at large. Thanks.

Author:  admin [ Wed Jun 06, 2012 10:22 am ]
Post subject:  Re: A few quick fixes I stumbled upon...

Meaning the indicators and ea

Author:  RJo [ Wed Jun 06, 2012 1:05 pm ]
Post subject:  Re: A few quick fixes I stumbled upon...

admin wrote:
Meaning the indicators and ea


Ok, but there is an mq4 file and an ex4 file for each indi; and an mq4 file and an ex4 file for each EA. Can I post only the ex4 file, or both the ex4 file and the mq4 file?

Author:  molanisfx [ Wed Jun 06, 2012 4:05 pm ]
Post subject:  Re: A few quick fixes I stumbled upon...

If you post them for free you need to post the mq4 or ex4 the way it is generated by the strategy builder. You cannot change or remove the copyright in the code.

Author:  RJo [ Wed Jun 06, 2012 5:18 pm ]
Post subject:  Re: A few quick fixes I stumbled upon...

No problem there. I don't even put my name in the headers.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/