كيف اجعل دالة الهاى واللو تقرأ الخمس ارقام
السلام عليكم
MR.dollar
متشكر جدا لردك السريع
جزاك الله خيرا على تعبك هذا
معلش هذا اول اكسبيرت لى واسئلتى كثيرة
مرفق الاكسبيرت
وطريقة عملة هى
يقوم بفتح صفقة باى ستوب وصفقة سيل ستوب من هاى ولو شمعة محددة
وعند تفعيل صفقة باى ستوب الى باى مثلا
يتم فتح صفقة سيل ستوب مضاعفة(مرة واحدة فقط)
ولكنه كان كلما اغلقت صفقة مفعلة او عند غلق الجهاز وفتحة مرة اخرى يقوم بعمل صفقة مضاعفة جديدة
فقمت باضافة متغير tm
حتى لا تتكرر لا اعلم هل ستنجح ام لا
فارجوا مراجعة الاكسبيرت
وكتابة ملاحظاتك
باقى الاكسبيرت اريد مساعدة حضرتك
لو تكرمت بكود لتنفيذ الآتى
لو الصفقة المفعلة اغلقت على ربح يتم الغاء الصفقتين المعلقتين
ولو اغلقت على خسارة سوف تفعل الصفقتين
واريد بعد ذلك اغلاق الاكسبيرت
هل يوجد دالة لاغلاق الاكسبيرت
ومتشكر جدا
رغم ان كلمة متشكر لا توافيك حقك
كود PHP:
//+------------------------------------------------------------------+
//| |
//| KH_TEST_1 |
//| |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ENTRIES |
//+------------------------------------------------------------------+
extern double Lots =0.01;
extern int TakeProfit =20;
extern int StartHour =20;
extern string Candle ="00";
extern int Step =20;
extern int MagicNumber =900;
//+------------------------------------------------------------------+
//| Variables |
//+------------------------------------------------------------------+
double pt;
double Lots_2;
double L;
double Buyentery;
double Sellentery;
double StopLoss_2;
double MathCeil;
int StopLoss;
bool Tm=false;
//+------------------------------------------------------------------+
//| دالة المنصة رباعية أو خماسية |
//+------------------------------------------------------------------+
int init()
{
if(Digits==5||Digits==4)
{
pt=0.0001;
}
else
{
pt=0.01;
}
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
datetime TradeTime=StringToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+Candle);
bool time = (Hour()>=StartHour);
int My_Bar = iBarShift(Symbol(),0,TradeTime,false);
double hi = High[My_Bar];
Print("Hi =",Hi);
//عند طباعة الهاى يطبع الق يمة 4فقط رغم ان المنصة خماسية
double lo = Low[My_Bar];
Buyentery = hi+Step*pt;
Sellentery = lo-Step*pt;
//+------------------------------------------------------------------+
//| حساب ستوب لوز المضاعفة وقيمة المضاعفة |
//+------------------------------------------------------------------+
StopLoss=(((Buyentery-Sellentery)/pt)+1);
L=StopLoss/TakeProfit ;
Lots_2=Lots* MathCeil( L);
//+------------------------------------------------------------------+
//| فتح باي ستوب وسيل ستوب |
//+------------------------------------------------------------------+
if(time==true&&ordtotal1(OP_BUYSTOP)==0&&ordtotal1(OP_BUY)==0&&ordtotal1(OP_SELL)==0)
{
open(OP_BUYSTOP,Lots,Buyentery,TakeProfit,StopLoss) ;
}
if(time==true&&ordtotal1(OP_SELLSTOP)==0&&ordtotal1(OP_SELL)==0&&ordtotal1(OP_BUY)==0)
{
open(OP_SELLSTOP,Lots,Sellentery,TakeProfit,StopLoss) ;
}
//+------------------------------------------------------------------+
//| المضاعفة |
//+------------------------------------------------------------------+
if(time==true&&Tm==false&&ordtotal1(OP_BUY)==1&&ordtotal1(OP_SELLSTOP)==1)
{
open(OP_SELLSTOP,Lots_2,Sellentery,TakeProfit,StopLoss) ;
Tm=true;
}
if(time==true&&Tm==false&&ordtotal1(OP_SELL)==1&&ordtotal1(OP_BUYSTOP)==1)
{
open(OP_BUYSTOP,Lots_2,Buyentery,TakeProfit,StopLoss) ;
Tm=true;
}
return(0);
}
//+------------------------------------------------------------------+
int open(int ty,double lot,double prc,int pof,int sll)
{
double sl=0,tp=0;
color clr;
string T;double pr;
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 //int cmd, // operation
,lot //double volume, // volume
,prc //double price, // price
,10 //int slippage, // slippage
,sl //double stoploss, // stop loss
,tp //double takeprofit, // take profit
,"KHALED" //string comment=NULL, // comment
,MagicNumber //int magic=0, // magic number
,0 //datetime expiration=0, // pending order expiration
,clr); //color arrow_color=clrNONE // color
/////////
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)
{
Print("Order Opened successfully " ,"Type ",t," LotSize ",lot);
}
else
{
Print("OrderSend failed with error #",GetLastError(), " Type ",t," LotSize ",lot);
}
return(tik);
}
//+------------------------------------------------------------------+
//| دالة عدد الأوردرات |
//+------------------------------------------------------------------+
int ordtotal1(int type)
{
int total_2=0;
for(int b=0;b<OrdersTotal();b++)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber&&OrderType()==type)
{
total_2++;
}
}
}
return(total_2);
}