Jump to content

Forex Magic Machine


Recommended Posts

  • Replies 75
  • Created
  • Last Reply

Top Posters In This Topic

Re: Forex Magic Machine/ Can not do backtest because of errors

 

Hi,

 

I tried to do backtesting of Magic machine robot, but it has error "Ordersend 131" all the times.

 

Could anybody try to double-check and correct the errors of this EA?

 

Thanks and regards,

James

 

I have the same problem. Anyone else?

Link to comment
Share on other sites

Re: Forex Magic Machine/ Can not do backtest because of errors

 

Hi,

 

I tried to do backtesting of Magic machine robot, but it has error "Ordersend 131" all the times.

 

Could anybody try to double-check and correct the errors of this EA?

 

Thanks and regards,

James

 

I have the same problem. Anyone else?

 

The error 131 occurs only with brokers having "incongruent" settings of MinLot & LotStep (eg 0.1 and 0.01). When EA splits orders to 80/20 (80% for fixed TP, the other 20% with no TP), the 20% part sometimes dips below the MinLot value even though the total lot (100%, which already passed the MM lot test) is above MinLot. Testing with brokers like IB, FXDD, etc. (which have both MinLot & LotStep at 0.01) should make the errors go away. Or you can change the MM code to make it more flexible with different settings of MinLot & LotStep.

 

I found the EA not very well written, esp in the OrderSend & OrderModify sections, causing intermittent errors.

Link to comment
Share on other sites

Re: Forex Magic Machine

 

ALL forex magic machine and bonus

 

http://www.4shared.com/file/103378238/25042700/forexmechine.html

[spoiler=stttttt... hey You .. YES you ... let tell me you A SECRET ... click here ... yeah ... click on this button ] II Vocabulary that you should know:

PLON=it mean someting that really bad ... REEEELY BAD like a BLOOD sucker stuff ...

CEMPLON= the PRODUCER OF SOMETHING THAT CLAIM GOOD but IT IS NOT ... and WASTED all YOUR MONEY!

---- make sure Oxford or Cambridge knows it ...--- K =D>

 

Link to comment
Share on other sites

Re: Forex Magic Machine

 

to above 2 guys, the serie code is in the second page of this thread itself.

 

Attached is the tester graphic, from ATC demo account. Why? Because his code has bug, he set seconds to expired in his pending order, and FXCM need to have 0 there. Then there need code to delete pending order. Because this bug, it can not be used in FXCM and ATC real account for backtest. I do not want to change his code in the first place.

 

Code is the original uncompiled code. Setting is default setting, used on EURUSD H1. because atc and fxcm has 6 digits, therefore, I added one more zero after all the pips for stoploss and taking profits. Does not get any other good results on other time frame and other pair, only good at EURUSD H1.

 

My impression: it is above average good logic, his money management and order management need to be improved. There are period like the whole 2009 March, start from 10000USD and up to 21000USD profits and only to loss half of it in the April, 2009. Need to check under which condition it made the loss, and add more code to avoid it. Just to imaging some one start to trade with this EA from April, 2009, then he will loss half of the account and no guts to continue to use this EA.

 

well, I could not succeed in upload the picture here, therefore I linked it here.

Setting is default setting, used on EURUSD H1. because atc and fxcm has 6 digits, therefore, I added one more zero after all the pips for stoploss and taking profits. RiskMM = false, then he is using 0.2 and 0.8 lot at a time.

http://www.formulatrader.com/download/FMMpla_EURUSDH1.jpg

 

below is the same setting as above, with riskMM=true, then it always use 0.16 lot all the time

 

http://www.formulatrader.com/download/FMMpla_EURUSDH1_riskon.jpg

Link to comment
Share on other sites

Re: Forex Magic Machine/ Can not do backtest because of errors

 

 

The error 131 occurs only with brokers having "incongruent" settings of MinLot & LotStep (eg 0.1 and 0.01). When EA splits orders to 80/20 (80% for fixed TP, the other 20% with no TP), the 20% part sometimes dips below the MinLot value even though the total lot (100%, which already passed the MM lot test) is above MinLot. Testing with brokers like IB, FXDD, etc. (which have both MinLot & LotStep at 0.01) should make the errors go away. Or you can change the MM code to make it more flexible with different settings of MinLot & LotStep.

 

I found the EA not very well written, esp in the OrderSend & OrderModify sections, causing intermittent errors.

 

Thanks for this explanation. Maybe we can fix this and make something better?

Link to comment
Share on other sites

Re: Forex Magic Machine

 

hi guys! i'm new here and I like to play around with MQL4 code of commercial bots like this one. Props to Kardel Sharpeye for sharing its decompiled code!!! didn't expect to find Magic Machine out in the open so soon, but what the heck! the Net is simply amazing!

 

anyways, i was goin thru the posts and i noticed that quite a few of us (including myself) were receiving the OrderSend error 130. so, i decided to do something about it. i would have to respectfully disagree with Clovelly and Giovaldo about the reasons for the occurance of this error. in the case of this particular bot, the reason is much simpler. whoever wrote the code for this one should've simply added NormalizeDouble within the OrderSend functions. about the Minimum Lot size and all that - if you take a look at the CalculateMM function, the author of this script already took that into consideration. but I added a couple of lines for the same idea, just to be doubly sure.

 

so, here's the corrected code. please test it out and let me know if you're still getting tons of Error 130. you might see one or two of the errors now and then, but not as many as generated by the original code. oh, and one more thing: you might want to optimize the MaxOrders parameter... methinks 100 pending orders is a BIT over the top!! :-D

 

int g_period_76 = 5;
int g_period_80 = 3;
int g_slowing_84 = 3;
int g_period_88 = 2;
int g_period_92 = 12;
double gd_96 = 0.003;
double gd_104 = 0.018;
int g_period_112 = 19;
int g_period_116 = 50;
bool gi_120 = FALSE;
extern double Lots = 0.1;
double gd_132 = 80.0;
double gd_140 = 20.0;
extern bool RiskMM = TRUE;
extern double RiskPercent = 2.0;
extern double MinLots = 0.01;
extern double MaxLots = 100.0;
int gi_176 = 23;
extern int StopLoss = 70;
extern int TakeProfit = 30;
int g_timeframe_188 = PERIOD_M1;
int g_period_192 = 14;
double gd_196 = 7.0;
extern int MaxOrders = 100;
int g_slippage_208 = 3;
int g_magic_212 = 19091;
int g_magic_216 = 19092;
bool gi_220 = FALSE;
int gi_224 = 20160;
datetime g_time_228;
datetime g_time_232;
double gd_unused_252 = 0.0;
double gd_unused_260 = 1.0;
double gd_unused_268 = 1.0;

int init() {
  if(MinLots < MarketInfo(Symbol(), MODE_MINLOT)) MinLots=MarketInfo(Symbol(), MODE_MINLOT);
  if(MaxLots > MarketInfo(Symbol(), MODE_MAXLOT)) MaxLots=MarketInfo(Symbol(), MODE_MAXLOT);
  return (0);
}

int start() {
  double l_istochastic_8;
  double l_istochastic_16;
  double l_istochastic_24;
  double l_istochastic_32;
  double l_irsi_40;
  double l_irsi_48;
  double l_ibearspower_56;
  double l_ibearspower_64;
  double l_isar_72;
  double l_isar_80;
  string ls_88;
  string ls_96;
  string ls_104;
  string ls_112;
  double l_price_120;
  double l_price_128;
  double ld_176;
  double l_lots_184;
  double l_lots_192;
  int l_ticket_200;
  int l_ticket_204;
  if (g_period_192 > 0) MoveTrailingStop();
  int li_0 = 1;
  for (int l_shift_4 = 1; l_shift_4 <= li_0; l_shift_4++) {
     l_istochastic_8 = iStochastic(NULL, 0, g_period_76, g_period_80, g_slowing_84, MODE_SMA, 0, MODE_MAIN, l_shift_4 + 1);
     l_istochastic_16 = iStochastic(NULL, 0, g_period_76, g_period_80, g_slowing_84, MODE_SMA, 0, MODE_SIGNAL, l_shift_4 + 1);
     l_istochastic_24 = iStochastic(NULL, 0, g_period_76, g_period_80, g_slowing_84, MODE_SMA, 0, MODE_MAIN, l_shift_4);
     l_istochastic_32 = iStochastic(NULL, 0, g_period_76, g_period_80, g_slowing_84, MODE_SMA, 0, MODE_SIGNAL, l_shift_4);
     l_irsi_40 = iRSI(NULL, 0, g_period_88, PRICE_CLOSE, l_shift_4 + 1);
     l_irsi_48 = iRSI(NULL, 0, g_period_88, PRICE_CLOSE, l_shift_4);
     l_ibearspower_56 = iBearsPower(NULL, 0, g_period_92, PRICE_CLOSE, l_shift_4 + 1);
     l_ibearspower_64 = iBearsPower(NULL, 0, g_period_92, PRICE_CLOSE, l_shift_4);
     l_isar_72 = iSAR(NULL, 0, gd_96, gd_104, l_shift_4 + 1);
     l_isar_80 = iSAR(NULL, 0, gd_96, gd_104, l_shift_4);
     ls_88 = "false";
     ls_96 = "false";
     if (l_istochastic_24 > l_istochastic_32 && l_irsi_48 > 50.0 && l_ibearspower_64 > 0.0 && Open[l_shift_4] > l_isar_80 && iMA(Symbol(), 0, g_period_112, 0, MODE_SMA, PRICE_CLOSE, l_shift_4) > iMA(Symbol(), 0, g_period_116, 0, MODE_SMA, PRICE_CLOSE, l_shift_4 +
        1) && gi_120 == FALSE || (gi_120 && Close[0] > Open[0])) ls_88 = "true";
     if (l_istochastic_24 > l_istochastic_32 && l_irsi_48 < 50.0 && l_ibearspower_64 < 0.0 && Open[l_shift_4] < l_isar_80 && iMA(Symbol(), 0, g_period_112, 0, MODE_SMA, PRICE_CLOSE, l_shift_4) < iMA(Symbol(), 0, g_period_116, 0, MODE_SMA, PRICE_CLOSE, l_shift_4 +
        1) && gi_120 == FALSE || (gi_120 && Close[0] < Open[0])) ls_96 = "true";
     ls_104 = "false";
     ls_112 = "false";
     if (ls_88 == "true") {
        if (gi_220) ls_112 = "true";
        else ls_104 = "true";
     }
     if (ls_96 == "true") {
        if (gi_220) ls_104 = "true";
        else ls_112 = "true";
     }
  }
  if (RiskMM) CalculateMM();
  int l_datetime_216 = 0;
  if (gi_224 > 0) l_datetime_216 = TimeCurrent() + 60 * gi_224 - 5;
  if (CountOrders(OP_BUY, g_magic_212) + CountOrders(OP_SELL, g_magic_212) + CountOrders(OP_BUY, g_magic_216) + CountOrders(OP_SELL, g_magic_216) < MaxOrders) {
     if (ls_104 == "true" && NewBarBuy()) {
        if (StopLoss > 0) l_price_120 = Low[l_shift_4] - (gi_176 + StopLoss) * Point - NormalizeDouble(iATR(NULL, 0, 14, 1) / 10.0 / 2.0, Digits);
        else l_price_120 = 0;
        if (TakeProfit > 0) l_price_128 = High[l_shift_4] + (gi_176 + TakeProfit) * Point;
        else l_price_128 = 0;
        ld_176 = Lots;
        if (ld_176 < MinLots) ld_176 = MinLots;
        if (ld_176 > MaxLots) ld_176 = MaxLots;
        l_lots_184 = NormalizeDouble(ld_176 * (gd_132 / 100.0), 2);
        l_lots_192 = NormalizeDouble(ld_176 * (gd_140 / 100.0), 2);
        l_ticket_200 = OrderSend(Symbol(), OP_BUYSTOP, l_lots_184, NormalizeDouble(High[l_shift_4] + gi_176 * Point, Digits), g_slippage_208, NormalizeDouble(l_price_120, Digits), NormalizeDouble(l_price_128, Digits), "The Forex Magic Machine Advance Version", g_magic_212, l_datetime_216, Blue);
        l_ticket_204 = OrderSend(Symbol(), OP_BUYSTOP, l_lots_192, NormalizeDouble(High[l_shift_4] + gi_176 * Point, Digits), g_slippage_208, NormalizeDouble(l_price_120, Digits), 0, "The Forex Magic Machine Advance Version", g_magic_216, l_datetime_216, Blue);
     }
     if (ls_112 == "true" && NewBarSell()) {
        if (StopLoss > 0) l_price_120 = High[l_shift_4] + (gi_176 + StopLoss) * Point + NormalizeDouble(iATR(NULL, 0, 14, 1) / 10.0 / 2.0, Digits);
        else l_price_120 = 0;
        if (TakeProfit > 0) l_price_128 = Low[l_shift_4] - (gi_176 + TakeProfit) * Point;
        else l_price_128 = 0;
        ld_176 = Lots;
        if (ld_176 < MinLots) ld_176 = MinLots;
        if (ld_176 > MaxLots) ld_176 = MaxLots;
        l_lots_184 = NormalizeDouble(ld_176 * (gd_132 / 100.0), 2);
        l_lots_192 = NormalizeDouble(ld_176 * (gd_140 / 100.0), 2);
        l_ticket_200 = OrderSend(Symbol(), OP_SELLSTOP, l_lots_184, NormalizeDouble(Low[l_shift_4] - gi_176 * Point, Digits), g_slippage_208, NormalizeDouble(l_price_120, Digits), NormalizeDouble(l_price_128, Digits), "The Forex Magic Machine Advance Version", g_magic_212, l_datetime_216, Red);
        l_ticket_204 = OrderSend(Symbol(), OP_SELLSTOP, l_lots_192, NormalizeDouble(Low[l_shift_4] - gi_176 * Point, Digits), g_slippage_208, NormalizeDouble(l_price_120, Digits), 0, "The Forex Magic Machine Advance Version", g_magic_216, l_datetime_216, Red);
     }
  }
  int li_unused_220 = 0;
  if (l_ticket_200 < 0 && l_ticket_204 < 0) {
     if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) {
        li_unused_220 = 1;
        Print("Not enough money!");
     }
     return (-1);
  }
  return (0);
}

int CountOrders(int a_cmd_0, int a_magic_4) {
  int l_count_8 = 0;
  for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) {
     OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
     if (OrderSymbol() == Symbol())
        if (OrderType() == a_cmd_0 && OrderMagicNumber() == a_magic_4 || a_magic_4 == 0) l_count_8++;
  }
  return (l_count_8);
}

void MoveTrailingStop() {
  int l_ord_total_4 = OrdersTotal();
  for (int l_pos_0 = 0; l_pos_0 < l_ord_total_4; l_pos_0++) {
     OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
     if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_216) {
        if (OrderType() == OP_BUY && NormalizeDouble(Ask - OrderOpenPrice(), Digits) > NormalizeDouble(iATR(NULL, g_timeframe_188, g_period_192, 1) * gd_196, Digits)) {
           if (g_period_192 > 0 && Ask > NormalizeDouble(OrderOpenPrice(), Digits)) {
              if (NormalizeDouble(OrderStopLoss(), Digits) < NormalizeDouble(Bid - NormalizeDouble(iATR(NULL, g_timeframe_188, g_period_192, 1) * gd_196, Digits), Digits) || OrderStopLoss() == 0.0) {
                 OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - NormalizeDouble(iATR(NULL, g_timeframe_188, g_period_192, 1) * gd_196, Digits), Digits), OrderTakeProfit(), 0, Blue);
                 return;
              }
           }
        }
        if (OrderType() == OP_SELL && NormalizeDouble(OrderOpenPrice() - Bid, Digits) > NormalizeDouble(iATR(NULL, g_timeframe_188, g_period_192, 1) * gd_196, Digits)) {
           if (g_period_192 > 0 && Bid < NormalizeDouble(OrderOpenPrice(), Digits)) {
              if (NormalizeDouble(OrderStopLoss(), Digits) > NormalizeDouble(Ask + NormalizeDouble(iATR(NULL, g_timeframe_188, g_period_192, 1) * gd_196, Digits), Digits) || OrderStopLoss() == 0.0) {
                 OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + NormalizeDouble(iATR(NULL, g_timeframe_188, g_period_192, 1) * gd_196, Digits), Digits), OrderTakeProfit(), 0, Red);
                 return;
              }
           }
        }
     }
  }
}

int NewBarBuy() {
  if (g_time_228 < Time[0]) {
     g_time_228 = Time[0];
     return (1);
  }
  return (0);
}

int NewBarSell() {
  if (g_time_232 < Time[0]) {
     g_time_232 = Time[0];
     return (1);
  }
  return (0);
}

void CalculateMM() {
  double l_minlot_0 = MarketInfo(Symbol(), MODE_MINLOT);
  double l_maxlot_8 = MarketInfo(Symbol(), MODE_MAXLOT);
  Lots = AccountFreeMargin() / 100000.0 * RiskPercent;
  Lots = MathMin(l_maxlot_8, MathMax(l_minlot_0, Lots));
  if (l_minlot_0 < 0.1) Lots = NormalizeDouble(Lots, 2);
  else {
     if (l_minlot_0 < 1.0) Lots = NormalizeDouble(Lots, 1);
     else Lots = NormalizeDouble(Lots, 0);
  }
  if (Lots < l_minlot_0) Lots = l_minlot_0;
  if (Lots > l_maxlot_8) Lots = l_maxlot_8;
}

Link to comment
Share on other sites

Re: Forex Magic Machine

 

well of course for the ordersend function to compatible with the new ecn type brokers the ordersend should have TP and SL set to 0.. then right after the ordersend you should do an ordermodify..

 

This is one of the FIRST things I look at when scanning any ea code.. I also see how they do the 3, 4, 5 digit stuff.. Most dont do it right...

 

And this guy has lotsize fixed at 100,000 units which is not true for all currency pairs depending on full/micro/mini.. There are so many cut and paste kids out there it is fun watching the stuff thats gets put out there... you can see the same bad code get used over and over and over..........

Link to comment
Share on other sites

Re: Forex Magic Machine

 

Hi guys,

The only part of code that is usable is the part about all the indicator to generate signals.

Rest of code is purely rubbish.

 

error in his code, the time for expirate for his pending orders, shall be set to 0, otherwise, you will get error 147.

so, just grab the indicator and signal part from the Magic EA first, and paste it to this Amazing EA.

 

http://www.earnforex.com/mt4_expert_advisors/AmazingEA.mq4

this one manages pending order much better than magic EA.

 

Magic EA trailstop part is also bad. need to reconstructed big time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...