0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
double GetLot(double open,double sl,double riskPerLevel) { double stopLossPips=0.0; if(CheckDoubles(open,">",sl)) stopLossPips=open-sl; else if(CheckDoubles(open,"<",sl)) stopLossPips=sl-open; else return 0.0; double p = riskPerLevel/stopLossPips; double l = NormalizeDouble((p/MarketInfo(Symbol(),MODE_TICKVALUE))*Point,2); return(l); }
bool CheckDoubles(double a,string check,double b) { if(check==">") { if(a - b > Point / 2.0)return(1);else return (0); }else if(check=="<"){ if(b - a > Point / 2.0)return(1);else return (0); }else if(check==">="){ if(a - b > -Point)return(1);else return (0); }if(check=="<="){ if(b - a > -Point)return(1);else return (0); }else if(check=="!="){ if(MathAbs(a - b) > Point / 2)return(1);else return (0); }else { Print("Sorry you've entered a wrong check value"); } return (0); }
double risk_percent = 5;double risk_money=NormalizeDouble(((double)risk_percent/100.0)*AccountEquity(),2);double lot=GetLot(order_open_price, order_sl_price, risk_money);
ขอบคุณมากครับ ผมลองใช้แล้ว เวลาคอมไพลมันขึ้น expression not boolean ตรงบรรทัด return(1) ไม่เป็นไรครับ ผมไม่ใช่โปรแกรมเมอร์ แค่อยากลองแก้ไข EA ดูครับถ้าเราใช้ FxPro Quant ก็มีระบบ MM ให้ใช้ใช่ใหมครับ น่าจะง่ายขึ้นหน่อย