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.
|