
رد: ارجو اضافة ال MaxLot للاكسبيرت التالي
اقتباس:
المشاركة الأصلية كتبت بواسطة سمير محمد ارمان
تم عمل المطلوب
تحياتى
استاذي العزيز سمير
لا انسى فضلك بعد الله في تعلمي البرمجه
اتمنى ان تكون في افضل حال
انا جربت طريقه اخرى هل تعتبر صحيحه او لها مشاكل اخرى
كود:
int open(int ty,double lott,double prc,int pof,int sll)
{
double sl=0,tp=0;
bool modi;
if(lott >Max_Lots)lott=Max_Lots;else lott=lott;
if(ty==OP_BUY || ty==OP_BUYSTOP || ty==OP_BUYLIMIT)
{
if(sll>0){sl=prc-(sll*pt);}else{sl=0;}
if(pof>0){tp=prc+(pof*pt);}else{tp=0;}
clr=Green;
T="Ask ";
pr=NormalizeDouble(Ask,Digits);
}
if(ty==OP_SELL || ty==OP_SELLSTOP || ty==OP_SELLLIMIT)
{
if(sll>0){sl=prc+(sll*pt);}else{sl=0;}
if(pof>0){tp=prc-(pof*pt);}else{tp=0;}
clr=Red;
T="Bid";
pr=NormalizeDouble(Bid,Digits);
}
int tik=OrderSend(Symbol()
,ty
,lott
,NormalizeDouble(prc,Digits)
,10
,0
,0
,"samir"
,MagicNumber
,0
,clr);
string t;
if(ty==OP_BUY)t="BUY";if(ty==OP_SELL)t="SELL";if(ty==OP_BUYSTOP)t="BUY STOP";if(ty==OP_SELLSTOP)t="SELL STOP";if(ty==OP_BUYLIMIT)t="BUY LIMIT";if(ty==OP_SELLLIMIT)t="SELL LIMIT";
if(tik>0)
{
if(tp>0 || sl>0)modi=OrderModify(tik,prc,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),0,CLR_NONE); else modi=true;
if(!modi){Print("Modify Err#= ",GetLastError()," ",Symbol()," ",Period()," Open Price= ",DoubleToStr(prc,Digits)," SL= ",DoubleToStr(sl,Digits)," Tp= ",DoubleToStr(tp,Digits));}
Print("Order Opened successfully " ,"Type ",t," LotSize ",lott," Price ",DoubleToStr(prc,Digits)," TP ",DoubleToStr(tp,Digits)," SL ",DoubleToStr(sl,Digits));
}
else
{
Print("OrderSend failed with error #",GetLastError(), " Type ",t," LotSize= ",lott," ",T,"Now= ",DoubleToStr(pr,Digits)," Price= ",DoubleToStr(prc,Digits)," TP= ",DoubleToStr(tp,Digits)," SL= ",DoubleToStr(sl,Digits)," Spread= ",MarketInfo(Symbol(),MODE_SPREAD));
}
//////
return(tik);
}