EA Programing => ปัญหาที่พบในการเขียน EA => Topic started by: suttisak on กรกฎาคม 27, 2015, 11:00:06 am
-
จากโค๊ด ผมให้อินดีแสดงค่าหารออกมาตอนคอมไพล์ผ่านแต่ลงชาร์ตแล้วมัน Zero Divide
พอเปลี่ยนเป็น + ,- ,* แสดงผลได้หมดยกเว้น /
ผมทำผิดตรงไหนรบกวนช่วยแนะนำด้วยนะครับ
int start()
{
int i,counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
double a,b,x,y,z,xx;
for(i=limit; i>=0; i--)
{
a=iClose(FirstSymbol,0,i);
b=iClose(SecondSymbol,0,i);
x=(a/b);
// xx=X
buffer1 = x;
// buffer2 = iClose(SecondSymbol,0,i);
// buffer3 = iClose(SecondSymbol,0,i);
IndicatorShortName("Stochastic ("+K+","+D+","+S+") "+FirstSymbol+" "+SecondSymbol+" Diff: "+DoubleToStr(MathAbs(buffer1), 0)+"% ");
}
//----
//----
return(0);
}
-
A = B / C
change it to:
if(C>0) A = B / C
Zero Divide คือ ตัวหารเป็น 0
-
ขอบคุณครับ เดี๋ยวลองดู
-
ใช้ได้แล้ว ขอบคุณท่านแอดมินครับ