| / | Forum |
|
criss73
2006.07.19 17:38
Hi, does anyone have an EA for a 2 line exp m/a crossover entry and exit signals?
thnx |
|
Secrets of MetaTrader 4 Client Terminal: File Library in MetaEditor When creating custom programs, code editor is of great importance. The more functions are available in the editor, the faster and more convenient is creation of the program. Many programs are created on basis of an already existing code. Do you use an indicator or a script that does not fully suit your purposes? Download the code of this program from our website and customize it for yourselves. |
5198 |
stringo
2006.07.19 19:47
//+------------------------------------------------------------------+ //| MA8-13 cross.mq4 | //| Copyright © 2006, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" extern int ExtPeriod1=8; extern int ExtPeriod2=13; //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { static datetime PrevTime=0; double Ma8Current, Ma8Previous, Ma8Previous2; double Ma13Current, Ma13Previous, Ma13Previous2; bool IsCrossDown, IsCrossUp; //---- если на текущем баре предыдущий бар уже обработан, выходим. if (PrevTime==Time[0]) return(0); PrevTime=Time[0]; //---- возьмём значения мувингов Ma8Current=iMA(NULL,0,ExtPeriod1,0,MODE_EMA,PRICE_CLOSE,1); Ma8Previous=iMA(NULL,0,ExtPeriod1,0,MODE_EMA,PRICE_CLOSE,2); Ma8Previous2=iMA(NULL,0,ExtPeriod1,0,MODE_EMA,PRICE_CLOSE,3); Ma13Current=iMA(NULL,0,ExtPeriod2,0,MODE_EMA,PRICE_CLOSE,1); Ma13Previous=iMA(NULL,0,ExtPeriod2,0,MODE_EMA,PRICE_CLOSE,2); Ma13Previous2=iMA(NULL,0,ExtPeriod2,0,MODE_EMA,PRICE_CLOSE,3); //---- и проверим условие пересечения IsCrossDown=(Ma8Current<Ma13Current && Ma8Previous>=Ma13Previous && Ma8Previous2>Ma13Previous2); IsCrossUp =(Ma8Current>Ma13Current && Ma8Previous<=Ma13Previous && Ma8Previous2<Ma13Previous2); //---- if(IsCrossDown) { for(int i=OrdersTotal()-1; i>=0; i--) { //---- exit longs OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol() && OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3); } //---- entry short OrderSend(Symbol(),OP_SELL,1.0,Bid,3,0.0,0.0); } //---- if(IsCrossUp) { for(i=OrdersTotal()-1; i>=0; i--) { //---- exit shorts OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3); } //---- entry long OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0.0,0.0); } //---- return(0); } //+------------------------------------------------------------------+ |
|
criss73
2006.07.20 01:14
hey stringo, thnx but i dont know how to program this. can you please guide me somehow?
thnx |
5198 |
stringo
2006.07.20 11:11
First read our documentation and articles
|
|
criss73
2006.07.20 16:50
hey stringo, within the codes there's stuff in Russian. i dont know if it matters
but do i need to know what it says?
thnx |
|
criss73
2006.07.20 17:02
another thing stringo, i opened the metaeditor and do i start the coding where it
says "expert start function'' or ''expert deintialization function"?
thnx |
5198 |
stringo
2006.07.20 18:22
there are simple comments
|
5198 |
stringo
2006.07.20 18:23
criss73 wrote: another thing stringo, i opened the metaeditor and do i start the coding where it says "expert start function'' or ''expert deintialization function"? thnx http://docs.mql4.com/basis/functions/special |
|
criss73
2006.07.20 18:38
ok stringo, i managed to write in the codes and compile them but i want to be able
to add lots. in the "input" all i can do is change the
ema values.
|
|
criss73
2006.07.20 21:03
another thing stringo, i want to add Gridsize,Gridstep and Extendgrid!
thnx |
|
criss73
2006.07.21 06:30
hey stringo, forget about the Gridsize, Gridstep, and Extendgrid. i still want to
know how to code the lots but, also, say the trend is up and i open my charts and
turn on the EA, i want it to automatically enter me in the trade in the direction
of the ema average; which is in this ex., up. do you know what i mean?
thnx |