Open Forex4you Account

Server รัน EA 1000 / ปี

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

Author Topic: สอบถามเรื่อง Code SAR ครับ  (Read 5658 times)

AvatarFX

  • Jr. Member
  • **
  • Posts: 60
    • Make Money Online
สอบถามเรื่อง Code SAR ครับ
« on: พฤษภาคม 17, 2012, 07:18:18 am »
1.พอดีผมได้ code SAR มา ลอง demo ดู และปรับค่านิดหน่อยก็ ok ครับ
2.แต่ผมอยากให้เปิด order แค่ order เีดียว จนกว่าจะเกิด SAR Buy ใหม่อ่ะครับ
3.ถ้าตลาดปกติ ก็ตรงตามเงื่อนไขเราเลย คือ SAR เกิดเม็ดแรกปุ๊บ ก็เปิด order เลยครับ
4.แต่ปัญหาก็คือ ถ้าตลาดแรงๆ ราคาจะขึ้นสูงมากกว่า 10  จุด ในแท่งเทียนเดียวกัน (ผมใช้ TF M15)
5.เมื่อ order แรก ถูก close ไป  order ใหม่ก็เปิดครับ
6.ซึ่งจริงๆ ผมอยากให้เปิด order ใหม่ก็ต่อเมื่อ มีการเกิด SAR ใหม่ ครับ
6.ผมลองหาวิธีแล้วแต่ก็ไม่สำเร็จ
7.คุณ admin หรือ เืพื่อนๆคนไหน พอจะทราบวิธีการบ้างไม๊ครับ

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

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------
extern string ForexSignals    ="www.TradingBug.com";
extern int MagicNumber =220002;
extern int StopLoss   =20;     // SL for an opened order
extern int TakeProfit =8;     // ?? for an opened order //default 20
extern double Lots    =0.1;    // Strictly set amount of lots //default 0.1
extern int Slippage   =3;      // Price Slippage //default 5
extern double Step    =0.02;   //Parabolic setting //default 0.001
extern double Maximum =0.2;    //Parabolic setting
extern int    OpenDel =0;     // wont open if current price has already covered this in the positive from bar open price
extern int    OpenAft =0;     // wont open if movement hasnt covered this peeps in the positive


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

int start()
  {
//trading criteria
bool   result;
double price;
int     cmd,error,TP,SL,StopMultd,OpenDelayBuy,OpenDelaySell,OpenAfterBuy,OpenAfterSell,OpenAfter,OpenDelay,Tral_Stop;
  
int    digits=MarketInfo("EURUSD",MODE_DIGITS);

if(digits==5){StopMultd=10;} else{StopMultd=1;}

TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
SL=NormalizeDouble(StopLoss*StopMultd,Digits);
OpenDelay=OpenDel*StopMultd;
OpenAfter=OpenAft*StopMultd;
Tral_Stop=Trail_Stop*StopMultd;
int Slip=Slippage*StopMultd;

string csymb=Symbol();
double bidp   =MarketInfo(csymb,MODE_BID);
double askp   =MarketInfo(csymb,MODE_ASK);

OpenDelayBuy=bidp-iLow(NULL,0,0)*Point;
OpenDelaySell=iHigh(NULL,0,0)-askp*Point;
OpenAfterBuy=bidp-iLow(NULL,0,0)*Point;
OpenAfterSell=iHigh(NULL,0,0)-askp*Point;


//-------------------------------------------------------------------+
//Check open orders
//-------------------------------------------------------------------+


if(OrdersTotal()>0){
  for(int i=1; i<=OrdersTotal(); i++)          // Cycle searching in orders
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
        {
          if(OrderMagicNumber()==MagicNumber) {int halt1=1;}
 
        }
     }

}


 if ((iSAR(NULL, 0,Step,Maximum, 0)<iClose(NULL,0,0))&&(iSAR(NULL, 0,Step,Maximum, 1)>iClose(NULL,0,1))) //Signal Buy
 {

 if(((OpenDelay>=OpenDelayBuy)||(OpenDelay==0))&&(OpenAfter<OpenAfterBuy)){    

 //open buy
 if(halt1!=1)
    {
     int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,NormalizeDouble(Ask-SL*Point,Digits),NormalizeDouble(Ask+TP*Point,Digits),"psar bug 6 order ",MagicNumber);//Opening Buy
     if(openbuy==TRUE) {Alert("Order opened !!!"); PlaySound("alert.wav"); }
    }
  }
 }
 
« Last Edit: พฤษภาคม 17, 2012, 07:22:40 am by AvatarFX »