Open Forex4you Account

Server รัน EA 1000 / ปี

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

Author Topic: รบกวนถามเรื่องโค๊ดการเปิดออร์เดอร์ครับ  (Read 6735 times)

sophon

  • Newbie
  • *
  • Posts: 2
สวัสดีครับ ผมเพิ่งหัดเขียน ea เลยลองใช้ indicator ตัวนึงมาลองแก้ดู พอเสร็จแล้ว มันเปิดออร์เดอร์ไม่หยุดเลยครับ จนขึ้นว่า ordersend error 148
ช่วยรบกวนบอกจุดที่ผิดหน่อยครับผม นี่คือโค๊ดครับ

int dist=24;
double b1[];
double b2[];

int start() {

int cnt,ticket,total;

   int counted_bars = 1000;
   //IndicatorCounted();
   int k,i,j,limit,hhb,llb;
   
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-1;
   if(counted_bars>=1) limit=Bars-counted_bars-1;
   if (limit<0) limit=0;

   for (i=limit;i>=0;i--)   {
 //     b1=EMPTY_VALUE;
 //     b2=EMPTY_VALUE;
      b1=0;
      b2=0;
      hhb = iHighest(NULL,0,MODE_HIGH,dist,i-dist/2);
      llb = iLowest(NULL,0,MODE_LOW,dist,i-dist/2);
     
      total=OrdersTotal();
     
      if(total==0)
      {
      if (i==hhb)
         b1=High[hhb]*Point;
         
         ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-Point*20,Ask+Point*40,"test",555,0,Green);
                    OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
      }
                   
      if (i==llb)
         b2=Low[llb]*Point;
         
         ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Bid+Point*20,Bid-Point*40,"test",555,0,Red);
                     OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
   }
   return(0);
}

อยากให้เปิดออร์เดอร์ครั้งละ 1 ออเดอร์ทุกครั้งที่เข้าเงื่อนไขน่ะครับ แต่นี่มันเล่นรัวเลย หรือว่าสัญญาณมันออกถี่เองเลยทำไม่ได้

ขอบคุณมากครับ

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
  if(total==0)
   {
      if (i==hhb)
         b1=High[hhb]*Point;
         
         ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-Point*20,Ask+Point*40,"test",555,0,Green);
                    OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
                       
      if (i==llb)
         b2=Low[llb]*Point;
         
         ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Bid+Point*20,Bid-Point*40,"test",555,0,Red);
                     OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
    }

การเรียกใช้อินดิเคเตอร์  ใช้ icustom อ่านค่าเอาครับ  ไม่ใช่เอาโค้ดอินดิเคเตอร์มาใส่ในอีเอ