BTC USD 79,899.5 Gold USD 4,349.40
Time now: Jun 1, 12:00 AM

Belajar Coding EA (mql) asas

bro camne nak adjust ea stealth kepada ea yg boleh buat PO ye?

Simple sangat soalan bro, dan terlalu umum, EA ada macam2 style. Kalau EA yang entry menggunakan signal/indi tak boleh nak jadikan PO.
Kalau EA style direct martingale atau pun EA style grid boleh, sebab entry pada setiap price adalah tetap.

Syntax "OrderSend()". rujuk link bawah ni

http://www.carigold.com/portal/forums/showpost.php?p=13194369&postcount=398

Sekiranya nak buy atau sell, kita akan menggunakan price "Ask" atau "Bid". tetapi untuk PO, kita kena specify price kat mana nak letak PO tersebut.

Contoh PO buy limit:-

OrderSend(Symbol(),OP_BUYLIMIT,0.1,Ask-100*Point,5,0,0,"Comment",0,0,CLR_NONE);

Ask-100*Point <-- price diletakkan 100 pips di bawah price "Ask".

kalau nak setkan setiap 50 pips, jadilah macam bawah ni.

OrderSend(Symbol(),OP_BUYLIMIT,0.1,Ask-50*Point,5,0,0,"Comment",0,0,CLR_NONE);
OrderSend(Symbol(),OP_BUYLIMIT,0.1,Ask-100*Point,5,0,0,"Comment",0,0,CLR_NONE);
OrderSend(Symbol(),OP_BUYLIMIT,0.1,Ask-150*Point,5,0,0,"Comment",0,0,CLR_NONE);

Waktu bila nak set kan buy limit tu pun kena tahu juga, sebab price "Ask" ni berubah-ubah. Bergantung kepada teknik EA/programmer tu lah macammana caranya nak entry
 
Ni EA bro buat sendiri?

//+------------------------------------------------------------------+
//| Martingale 2012.mq4 |
//| Copyright © 2011, NubieFX Software Corp. |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, NubieFX Software Corp."
#property link "[email protected]"
#define buy -2
#define sell 2
extern string Hak_Milik ="[email protected]";
extern string Nama_EA = "Martingale 2012";
extern string Please_Enter_Password = "0";
extern int magic =333;
extern bool Gunakan_Daily_Profit=true;
extern double Daily_TargetProfit=50;
extern double multiplier =2.0;
extern double start_lot =0.01;
extern double jarak_OP =20;
extern double layer =6;
extern double Money =2.0;
double tp =30;
double sl =60;
 
Saya tak check sangat, mungkin ada typo error mana2
Secara kasar saya rasa bro faham code saya bawah ni.

Code:
int TotalBuy ()
{
   int total=0;
   for(int i=0; i<OrdersTotal(); i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
      if(OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT) total++;
   }
   return(total);
} 

int TotalSell ()
{
   int total=0;
   for(int i=0; i<OrdersTotal(); i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
      if(OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT) total++;
   }
   return(total);
} 

double PricePoBuy ()
{
   double price=0;
   for(int i=0; i<OrdersTotal(); i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
      if(OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT)
      {
         if (price==0) price=OrderOpenPrice();
         else price = MathMin(price, OrderOpenPrice());
      }
   }
   return(price-jarak_OP*pt);
} 

double PricePoSell ()
{
   double price=0;
   for(int i=0; i<OrdersTotal(); i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
      if(OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT)
      {
         if (price==0) price=OrderOpenPrice();
         else price = MathMax(price, OrderOpenPrice());
      }
   }
   return(price+jarak_OP*pt);
} 

double LotPoBuy ()
{
   double nlot=0;
   for(int i=0; i<OrdersTotal(); i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
      if(OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT)
      {
         if (nlot==0) nlot=OrderLots();
         else nlot = MathMax(nlot, OrderLots());
      }
   }
   return(NormalizeDouble(nlot*multiplier,prec));
}

double LotPoSell ()
{
   double nlot=0;
   for(int i=0; i<OrdersTotal(); i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
      if(OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT)
      {
         if (nlot==0) nlot=OrderLots();
         else nlot = MathMax(nlot, OrderLots());
      }
   }
   return(NormalizeDouble(nlot*multiplier,prec));
}
kemudian dalam start

Code:
if(TotalBuy()>0 && TotalBuy()<layer)
{
   OrderSend(Symbol(),OP_BUYLIMIT,LotPoBuy(),PricePoBuy(),3,0,0,"Martingale 2012",magic,0,Blue);
}

if(TotalSell()>0 && TotalSell()<layer)
{
   OrderSend(Symbol(),OP_SELLLIMIT,LotPoSell(),PricePoSell(),3,0,0,"Martingale 2012",magic,0,Red);
}
 
Ni EA bro buat sendiri?

ea tu sy upah org buat tapi dia dah xde dlm duania online lg dah..skang ni ea tu x stabil sbb entry dia dlm stealh bermaksud martingale dia buka bila sampai di price tertentu tapi jika berlaku spike habis semua entry tu x kena tp yg kita target jadinya boleh MC..so boleh x bro adjustkan ea tu supaya boleh dia buka PO buy/sell?
 
Spike Detector..

Code:
int SpikeDetector() {
   int l_highest_8;
   int l_lowest_12;
   double l_ihigh_16;
   double l_ilow_24;
   int l_datetime_32;
   int l_datetime_36;
   double ld_40;
   int li_ret_0 = 0;
   int li_4 = iBars(Symbol(), PERIOD_M1);
   if (li_4 > SpikeMinute) {
      l_highest_8 = iHighest(Symbol(), PERIOD_M1, MODE_HIGH, SpikeMinute, 0);
      l_lowest_12 = iLowest(Symbol(), PERIOD_M1, MODE_LOW, SpikeMinute, 0);
      l_ihigh_16 = iHigh(Symbol(), PERIOD_M1, l_highest_8);
      l_ilow_24 = iLow(Symbol(), PERIOD_M1, l_lowest_12);
      l_datetime_32 = iTime(Symbol(), PERIOD_M1, l_highest_8);
      l_datetime_36 = iTime(Symbol(), PERIOD_M1, l_lowest_12);
      ld_40 = MathAbs(l_ihigh_16 - l_ilow_24);
      if (ld_40 >= SpikePips * Point) {
         if (l_datetime_32 > l_datetime_36) {
            li_ret_0 = 1;
            Print("SPIKE UP diff= ", ld_40, " hi= ", l_ihigh_16, " lo= ", l_ilow_24);
         } else {
            li_ret_0 = -1;
            Print("SPIKE DOWN diff= ", ld_40, " hi= ", l_ihigh_16, " lo= ", l_ilow_24);
         }
      }
   }
   return (li_ret_0);
}
 
Spike Detector..

Code:
int SpikeDetector() {
   int l_highest_8;
   int l_lowest_12;
   double l_ihigh_16;
   double l_ilow_24;
   int l_datetime_32;
   int l_datetime_36;
   double ld_40;
   int li_ret_0 = 0;
   int li_4 = iBars(Symbol(), PERIOD_M1);
   if (li_4 > SpikeMinute) {
      l_highest_8 = iHighest(Symbol(), PERIOD_M1, MODE_HIGH, SpikeMinute, 0);
      l_lowest_12 = iLowest(Symbol(), PERIOD_M1, MODE_LOW, SpikeMinute, 0);
      l_ihigh_16 = iHigh(Symbol(), PERIOD_M1, l_highest_8);
      l_ilow_24 = iLow(Symbol(), PERIOD_M1, l_lowest_12);
      l_datetime_32 = iTime(Symbol(), PERIOD_M1, l_highest_8);
      l_datetime_36 = iTime(Symbol(), PERIOD_M1, l_lowest_12);
      ld_40 = MathAbs(l_ihigh_16 - l_ilow_24);
      if (ld_40 >= SpikePips * Point) {
         if (l_datetime_32 > l_datetime_36) {
            li_ret_0 = 1;
            Print("SPIKE UP diff= ", ld_40, " hi= ", l_ihigh_16, " lo= ", l_ilow_24);
         } else {
            li_ret_0 = -1;
            Print("SPIKE DOWN diff= ", ld_40, " hi= ", l_ihigh_16, " lo= ", l_ilow_24);
         }
      }
   }
   return (li_ret_0);
}

nak letak kat mana dlm ea tu bro?
 
ea tu sy upah org buat tapi dia dah xde dlm duania online lg dah..skang ni ea tu x stabil sbb entry dia dlm stealh bermaksud martingale dia buka bila sampai di price tertentu tapi jika berlaku spike habis semua entry tu x kena tp yg kita target jadinya boleh MC..so boleh x bro adjustkan ea tu supaya boleh dia buka PO buy/sell?

Code saya dah kasi atas tu, cuba bro masukkan ke dalam EA.
 
salam. aku nak tanya sapa arif ni. cemana nak tukar ex4 kepada mq4. ataupun senangnya cemana nak modify file ex4.
 
salam bro...

lama try buat code ni...tk menjadi2 gk..

-NAK SEMAK ORPHAN ORDERS-

Cam ne kita nk kira ordercomment yg sama..bila kurang atau lebih...dia akan close pasanga ganjil..


cth:

post1 buy gbp: OrderComment 1.
post2 sell eur: OrderComment 1.

post3 sell gbp: OrderComment 2.
post4 buy eur: OrderComment 2.

post5 buy gbp: OrderComment 3.
post6 sell eur: OrderComment 3.


bila ada masalah connection..satu pasangan ni akan menjadi tidak sempurna iaitu 1 pair sahaja yg wujud...sepatutnya dua pair bagi sepasang..











cth code..
Code:
      if (TickDelay == 15 && CloseOrphanedOrders)
   {
      for (int l_pos_1 = 0; l_pos_1 < 500; l_pos_1++)
      {
         
         int li_ret_4 = 0;
         for (int i=OrdersTotal()-1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
            {
               if (OrderSymbol() == Pair1 || OrderSymbol() == Pair2) 
               {
                  if (OrderMagicNumber() == MagicNo){
                   
                     li_16 = GetLastTicketBuy(Pair1, MagicNo);
                     li_20 = GetLastTicketSell(Pair2, MagicNo);
                     
                     li_ret_4 = li_16 + li_20;
                     li_ret_4++;
               }
            }
         }
         
         }
         
         if (li_ret_4 == 1 && li_16 == TRUE && OrderSymbol() == Pair1){ 
         CloseLastBuy(li_16, Pair1);
      
         
         if (li_ret_4 == 1 && li_20 == TRUE && OrderSymbol() == Pair2){ 
         CloseLastSell(li_20, Pair2);
         
         }
         
         }
       
      }
      TickDelay = 0;
   } 
   
   
   
   TickDelay++;
 

Live Forex Chart

Currency
Rates
EUR / USD
1.14617
USD / JPY
157.871
GBP / USD
1.33605
USD / CHF
0.82512
USD / CAD
1.40084
EUR / JPY
180.458
AUD / USD
0.71084
Back
Top
Log in Register