Open Forex4you Account

Server รัน EA 1000 / ปี

สั่งชื้อคู่มือการโปรแรกม MQL4

Author Topic: EA matingel ปิด order หลายคู่อยากให้ปิดแค่คู่เดียว  (Read 9518 times)

jack

  • Newbie
  • *
  • Posts: 3
รบกวนช่วยดู code หน่อย ว่าผมทำผิดตรงไหนครับ คือ ผมเขียน ea แล้วใส่ matingel เข้าไป ผลที่ได้คือ ถ้าราคาผิดทางจะเปิดไม้แก้ให้ จากนั้นถ้า กำไร กลับมาเป็นบวก จะสั่งปิด order แต่กลายเป็นว่า มันปิด order ของทุกคู่เลยครับ อยากให้ปิดแค่คู่เดียว  คือเวลาเล่นจะเปิดกราฟหลายคู่ครับ


//+------------------------------------------------------------------+
//--Martingale
//+------------------------------------------------------------------+

void Martin()
{
  if(Martingale)
  {
  if(CountBuy ()>0 && PriceAsk-Ask > Distance*Point && CountBuy()  < Maxorder) OpenBuy();
  if(CountSell()>0 && Bid-PriceBid > Distance*Point && CountSell() < Maxorder) OpenSell();
  }

}

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

int CountBuy()
{
  int Count=0;
  for(int i =OrdersTotal()-1;i>=0;i--)
  {
    bool res = OrderSelect(i,SELECT_BY_POS);
    if(OrderType()==OP_BUY)
    {
      Count++;
   
    }
    }
   return Count;
}

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

int CountSell()
{
  int Count=0;
  for(int i =OrdersTotal()-1;i>=0;i--)
  {
    bool res = OrderSelect(i,SELECT_BY_POS);
    if(OrderType()==OP_SELL)
    {
      Count++;
   
    }
    }
   return Count;
}

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

double NewLots()
{
  double NewLots=Lotsize;
  for(int i = OrdersTotal()-1;i>=0;i--)
  {
    bool res = OrderSelect(i,SELECT_BY_POS);
    NewLots=NewLots*Multiple;
   }
   return NewLots;
   }
   
//+------------------------------------------------------------------+   
   
   
void CloseByProfit()   
  {
  int ticket;
 
   if(AccountProfit() >= profit)
   {
      for(int i = OrdersTotal()-1;i>=0;i--)
      {
       bool res = OrderSelect(i,SELECT_BY_POS);
         ticket = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),50,clrBlack);
       
     
      }
   
   
   }
   
  }

mece50

  • Newbie
  • *
  • Posts: 1
ถ้าทำได้แล้วช่วยแชร์หน่อยได้ไหมครับ อยากรู้ด้วยครับ

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ก็ต้องกำหนดให้มันสนใจแค่คู่เดียวที่อยู่บนกราฟครับ


OrderSymbol() == Symbol()

ufa959s

  • Newbie
  • *
  • Posts: 1
    • ufa959s
ขอบคุณสำหรับแนวทางครับ