การเขียน EA เพื่อแสดงข้อความบน Chart

      ในการเขียน EA บางครั้งเราจำเป็นต้องแสดงผลของค่าบางค่าที่เราต้องการบน Chart เพื่อให้ง่ายต่อการตรวจสอบผลการทำงานของ EA ว่าทำงานได้ถูกต้องตามเงื่อนไขที่เราตั้งไว้หรือไม่
        จากตัวอย่างด้านล่างเป็นการแสดงผลขอกำไร/ขาดทุนของ Order ที่เราเปิดอยู่ ซึ่งจะแสดงหมายเลข Ticket และ Profit ที่เกิดขึ้น











ตัวอย่างการเขียนโค๊ด

int getLastOrderProfit() {
   string name = "strProfit";
   string strDispaly; 
   for(int i=0;i<OrdersTotal();i++){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
         if(OrderSymbol()==Symbol()){
            strDispaly = "Order Ticket "+ OrderTicket()+" Profit: " + DoubleToStr(OrderProfit(),0);
            ObjectCreate(name,OBJ_LABEL,0,0,0);
            ObjectSet(name,OBJPROP_XDISTANCE,5);
            ObjectSet(name,OBJPROP_YDISTANCE,80);
            ObjectSetText(name,strDispaly,14,"Arial",DodgerBlue);
            return(OrderProfit());
         } 
      }    
   }         

}

int start() {
    if(OrdersTotal()>0) {
        getLastOrderProfit();
    }
}


1 ความคิดเห็น:

  1. Your Affiliate Money Making Machine is waiting -

    And earning money online using it is as simple as 1...2...3!

    Here's how it all works...

    STEP 1. Input into the system which affiliate products you want to promote
    STEP 2. Add PUSH BUTTON traffic (this ONLY takes 2 minutes)
    STEP 3. Watch the affiliate products system grow your list and sell your affiliate products all for you!

    Do you want to start making profits??

    The solution is right here

    ตอบลบ