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

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Fri May 24, 2024 5:03 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: A few quick fixes I stumbled upon...
PostPosted: Tue Jun 05, 2012 11:08 am 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
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.

_________________
I'm not a programmer, but I play one on TV.


Last edited by RJo on Wed Jun 13, 2012 4:26 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: A few quick fixes I stumbled upon...
PostPosted: Tue Jun 05, 2012 5:19 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
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.


Top
 Profile  
 
 Post subject: Re: A few quick fixes I stumbled upon...
PostPosted: Wed Jun 06, 2012 9:09 am 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
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.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: A few quick fixes I stumbled upon...
PostPosted: Wed Jun 06, 2012 10:22 am 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
Meaning the indicators and ea


Top
 Profile  
 
 Post subject: Re: A few quick fixes I stumbled upon...
PostPosted: Wed Jun 06, 2012 1:05 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
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?

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: A few quick fixes I stumbled upon...
PostPosted: Wed Jun 06, 2012 4:05 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
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.


Top
 Profile  
 
 Post subject: Re: A few quick fixes I stumbled upon...
PostPosted: Wed Jun 06, 2012 5:18 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
No problem there. I don't even put my name in the headers.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009