EA Programing => ปัญหาที่พบในการเขียน EA => Topic started by: zidane19 on มีนาคม 03, 2017, 03:22:01 pm
-
ตามหัวข้อเลยครับ
รัน ทุกวินาที เลยครับ ต้อง Remove EA ออก ถึงจะหยุดครับ
//+------------------------------------------------------------------+
int start()
{
if( IsTesting() == true )//Point 1
{ Print("Your Run BackTest Now");
return(0);
}
if( IsDemo() == true )
{ Print("Your Run DEMO Now");
return(0);
}
Print("Your Run Real Account Now");
return(0);
}
//+------------------------------------------------------------------+
-
ที่เป็นแบบนั้นเพราะเราเขียนในฟังกชั่น start มันจะทำงานทุกสัญญาณที่มีการขยับ
ดังนั้นเพื่อให้ง่ายให้เราไปเช็กใน Oninit() ก่อนตัั้งแต่แรก และเก็บค่าเอาไว้เพื่อส่งต่อให้ในฟังกชั่น start() เพื่อดูอีกทีว่าจะให้ทำหรือไม่ทำ
bool check;
//+------------------------------------------------------------------+
int OnInit()
{
if(IsTesting()==true)
{
Print("Your Run BackTest Now");
check=false;
}
if(IsDemo()==true)
{
Print("Your Run DEMO Now");
check=false;
}
if(IsTesting()==false || IsDemo()==false)
{
Print("Your Run Real Account Now");
check=true;
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
int start()
{
if(check=true)
{
// โปรแกรมที่จะรัน
}
return(0);
}
-
ขอบคุณครับ ได้ความรู้เพิ่มเติมอีกแล้ว