Download MetaTrader 5
To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
vosy
22
vosy 2014.04.13 14:51 

I'm tring to test my EA into MT4.

But when I try EA "Pokus3" with text "Moje EA" and MagicNumber 1003, i can se EA "Pokus" with text "Moje prvni strategie" with MN 1001, viz IMG.

how is it possible??? Some cache or what?? thx

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.14 01:11  
Show us the code then. Someone will look into it if they have their spare time.
Ali Akcaagac
169
Ali Akcaagac 2014.04.14 05:55  

I find it impressive how people publicly post their "strategies" or ask why their "strategy" won't work. As in a normal business, you don't make your "strategy" public. It's your capital to keep things for yourself, hidden from public and as far as possible hidden from your broker. A "strategy" that doesn't work is no "strategy". A "strategy" that has been hacked together first and thought out how it might work afterwards is no "strategy". First ist the "strategy" (may it be written on a sheet of paper) and then you can start to automate it if necessary. It is your capital that's laying on the table so know what you are doing. The "strategy" from someone else is not your "strategy".

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.14 06:10  
It is a learning process. Usually once they grasp the basic ... they disappear. So, I would not take it seriously.
vosy
22
vosy 2014.04.14 13:01  

my code

//+------------------------------------------------------------------+

//| Pokus3.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict



extern double StopLoss_v_pipech=1000;

extern double Profit_target_v_pipech=200;

extern double Velikost_pozice=0.01;



int D,m,h,ticket,p,close;

double SL,PT;



bool obchodovat = true;

int Magic_number=1003;

string Text="Moje EA";

//+------------------------------------------------------------------+

//| Expert initialization function |

//+------------------------------------------------------------------+

int OnInit()

{

//---



//---

return(INIT_SUCCEEDED);

}

//+------------------------------------------------------------------+

//| Expert deinitialization function |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

//---



}

//+------------------------------------------------------------------+

//| Expert tick function |

//+------------------------------------------------------------------+

void OnTick()

{

D=DayOfWeek();

m = TimeMinute(TimeCurrent());

h = TimeHour(TimeCurrent());

SL = StopLoss_v_pipech*Point;

PT = Profit_target_v_pipech*Point;

//---

if(D==1 && h<02 && m<10)

{

obchodovat=true;

}



for(p=0; p<OrdersTotal(); p++)

{

if(OrderSelect(p,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==Magic_number)

{

if(D>=5 && h==23 && m>=30)

{

zavritPoziceNaKonciTydne();

}

}

}



for(p=0; p<OrdersTotal(); p++)

{

if(OrderSelect(p,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==Magic_number)

{

return;

}

}



otevritObchod();



}

//+------------------------------------------------------------------+



void zavritPoziceNaKonciTydne()

{

obchodovat=false;



if(OrderType()==OP_BUY)

{

close=OrderClose(OrderTicket(),

Velikost_pozice,

Bid,

2,

Yellow);

}



if(OrderType()==OP_SELL)

{

close=OrderClose(OrderTicket(),

Velikost_pozice,

Ask,

2,

Yellow);

}



return;

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+



void otevritObchod()

{

if(obchodovat)

{

bool letsBuy;

int k1,k2,k3,k4;

string v1,v2,lastOrderFinal,lastOrderSmer;



k1 = MathRand()%6+1;

k2 = MathRand()%6+1;

k3 = MathRand()%6+1;

k4 = MathRand()%6+1;



if((k1%2==0 && k2%2==0) || (k1%2==1 && k2%2==1))

{

v1="s";

}

else

{

v1="l";

}



if((k3%2==0 && k4%2==0) || (k3%2==1 && k4%2==1))

{

v2="s";

}

else

{

v2="l";

}



if(v1==v2)

{

letsBuy=true;

}

else

{

letsBuy=false;

}

Print("letsBuy - "+string(letsBuy));

lastOrderFinal= jakZkoncilPosledniObchod();

lastOrderSmer = smerPoslednihoObchodu();

Print(lastOrderFinal+" "+lastOrderSmer);



if(lastOrderFinal=="loss")

{

if(lastOrderSmer=="buy")

{

letsBuy=false;

}

else

{

letsBuy=true;

}

}

else if(lastOrderFinal=="profit")

{

if(lastOrderSmer=="buy")

{

letsBuy=true;

}

else

{

letsBuy=false;

}

}

Print("letsBuy2 - "+string(letsBuy));



if(letsBuy)

{

ticket=OrderSend(Symbol(),

OP_BUY,

Velikost_pozice,

Ask,

0,

Ask-SL,

Ask+PT,

Text,

Magic_number,

0,

clrAqua);

}

else

{

ticket=OrderSend(Symbol(),

OP_SELL,

Velikost_pozice,

Bid,

0,

Bid+SL,

Bid-PT,

Text,

Magic_number,

0,

clrRed);

}

}

return;

}

//+------------------------------------------------------------------+

string smerPoslednihoObchodu()

{

string smer="";



for(int i=(OrdersHistoryTotal()-1); i>=0; i--)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_number)

{

if(OrderType()==OP_BUY)

{

smer="buy";

}



if(OrderType()==OP_SELL)

{

smer="sell";

}

Print("#### "+string(i)+" - "+string(OrderMagicNumber())+" - "+string(OrderType()));

break;

}

}



return smer;

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

string jakZkoncilPosledniObchod()

{

string last="X";



for(int i=(OrdersHistoryTotal()-1); i>=0; i--)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_number)

{

if(OrderProfit()>0) last="profit";

if(OrderProfit()<0) last="loss";



Print("NUMBER: "+string(i+1)+" "+string(OrderOpenPrice())+" "+string(OrderType()));

Print("Ukonceno na: "+last+" "+string(OrderProfit()));

Print("----");

break;

}

}



return last;

}

//+------------------------------------------------------------------+
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.14 14:21  
Please edit and use SRC ...
vosy
22
vosy 2014.04.14 21:02  

I create new empty EA with code

//+------------------------------------------------------------------+
//|                                                           Pa.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Tester function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//---
   double ret=0.0;
//---

//---
   return(ret);
  }
//+------------------------------------------------------------------+

and result is 

is possible that I have some EA on the backgroud or cache of the Tester?

/
To add comments, please log in or register