กองทุน SPDR GOLD SHARES
ถือทองก่อนหน้า
ถือทองล่าสุด
0.00
*หน่วยตัน / ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ
สถิติกองทุน SPDR
ราคาทองคำแท่ง 96.5%
ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ
ครั้งที่
ราคาก่อนหน้า
ราคาล่าสุด
0
(หน่วย บาท*) / อัปเดตล่าสุดเมื่อวันที่ 13 ก.ค. 2566 เวลา 13:04 น.
สถิติราคาทองคำ ไทย

close all order ตามเงื่อนไขของค่า custom indicator

  • 2 replies
  • 2,470 views
*

yong

close all order ตามเงื่อนไขของค่า custom indicator
« เมื่อ: 02, สิงหาคม 2018, 01:38:50 PM »
จะสร้าง code อย่างไรครับ ให้ ea close all order ตามเงื่อนไขที่เราวางไว้ โดยใช้ค่าของ custom indicator มาเปรียบเทียบแล้วปิดออเดอร์

extern double Common_TP = 10 //กำหนดค่าให้เปรียบเทียบกับ custom indy

double Icus = iCustom(NULL,0,"Icusindicator",12,9,0,0);  //ประกาศตัวแปรให้เก็บค่า buffer 0 ของ custom indy

void CloseTP()
   {
      for(int i=OrdersTotal()-1; i>=0; i--)
      {
      bool res=OrderSelect(i,SELECT_BY_POS, MODE_TRADES);

      if(Icus == Common_TP);  //เปรียบเทียบค่าถ้าเท่ากันให้ close all order

      bool tic =OrderClose(OrderTicket(),OrderLots(),OrderOpenPrice(),50,clrBlue);
      }
   }

ต้องการให้ close all order เมื่อค่าที่เรากำหนด = ค่าของ custom indicator ครับ

พอลองทดสอบแล้วมันไม่ปิดออเดอร์ให้อะครับ
/**33 /**33 /**33
(TH)** (TH)** (TH)**

*

iRuler

  • 1,282
Re: close all order ตามเงื่อนไขของค่า custom indicator
« ตอบกลับ #1 เมื่อ: 03, สิงหาคม 2018, 08:12:05 AM »
อ้างจาก: yong ที่ 02, สิงหาคม  2018, 01:38:50 PM
จะสร้าง code อย่างไรครับ ให้ ea close all order ตามเงื่อนไขที่เราวางไว้ โดยใช้ค่าของ custom indicator มาเปรียบเทียบแล้วปิดออเดอร์

extern double Common_TP = 10 //กำหนดค่าให้เปรียบเทียบกับ custom indy

double Icus = iCustom(NULL,0,"Icusindicator",12,9,0,0);  //ประกาศตัวแปรให้เก็บค่า buffer 0 ของ custom indy

void CloseTP()
   {
      for(int i=OrdersTotal()-1; i>=0; i--)
      {
      bool res=OrderSelect(i,SELECT_BY_POS, MODE_TRADES);

      if(Icus == Common_TP);  //เปรียบเทียบค่าถ้าเท่ากันให้ close all order

      bool tic =OrderClose(OrderTicket(),OrderLots(),OrderOpenPrice(),50,clrBlue);
      }
   }

ต้องการให้ close all order เมื่อค่าที่เรากำหนด = ค่าของ custom indicator ครับ

พอลองทดสอบแล้วมันไม่ปิดออเดอร์ให้อะครับ
/**33 /**33 /**33
(TH)** (TH)** (TH)**

ลองแบบนี้ครับ

โค๊ด [Select]
input double Common_TP = 10 //กำหนดค่าให้เปรียบเทียบกับ custom indy

double Icus = iCustom(NULL,0,"Icusindicator",12,9,0,0);  //ประกาศตัวแปรให้เก็บค่า buffer 0 ของ custom indy
if(Icus == Common_TP);  //เปรียบเทียบค่าถ้าเท่ากันให้ close all order
   CloseTP();


void CloseTP()
   {
      for(int i=OrdersTotal();i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
           {           
              if(OrderType()==OP_BUY)
                 bool res=OrderClose(OrderTicket(),OrderLots(),Bid,999,clrNONE);
              if(OrderType()==OP_SELL)
                 bool res=OrderClose(OrderTicket(),OrderLots(),Ask,999,clrNONE);
           }
        }
     }
   }

*

yong

Re: close all order ตามเงื่อนไขของค่า custom indicator
« ตอบกลับ #2 เมื่อ: 03, สิงหาคม 2018, 01:24:39 PM »
ขอบคุณครับ
(TH)** (TH)** (TH)**