السلام عليكم ورحمة الله
يدخل شراء ازا تحقق تغيير اللون الى الاخضر مع اغلاق فوق موفينغ افريج 55
والعكس في البيع
اضافة اخد الربح والاستوب وملاحقة الربح
الملف المرفق 516915
الملف المرفق 516916
Printable View
السلام عليكم ورحمة الله
يدخل شراء ازا تحقق تغيير اللون الى الاخضر مع اغلاق فوق موفينغ افريج 55
والعكس في البيع
اضافة اخد الربح والاستوب وملاحقة الربح
الملف المرفق 516915
الملف المرفق 516916
هل احد المبرمجين يساعدني
تفضل ويمكن تعدل وتضيف الشروط اللي بدك
كود PHP:
#property version "1.00"
#property strict
extern int Nbr_Periods=10;
extern double Multiplier=3.0;
extern int MA_Period=55;
extern bool Use_Time_For_EA=false;
extern string Start_Time="07:00";
extern string Ending_Time="16:00";
extern double LotSize=0.1;
extern bool AutoLotSizing=false;
extern double RiskPercent=1;
extern int Take_Profit=0;
extern int Stop_Loss=0;
extern bool UseTrailingStop=false;
extern int WhenToTrail=50;
extern int TrailAmount=25;
extern int MagicNumber=1;
double pips=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
double ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
if(ticksize==0.00001 || ticksize==0.001)
pips=ticksize*10;
else pips=ticksize;
return(0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if(IsNewCandle())Check_Trades();
if(UseTrailingStop)AdjustTrail();
}
//+-------------------------------------------------------------------+
void Check_Trades(){
if(iCustom(_Symbol,0,"SuperTrend MT4 Indicator",Nbr_Periods,Multiplier,0,1)!=EMPTY_VALUE
&& iCustom(_Symbol,0,"SuperTrend MT4 Indicator",Nbr_Periods,Multiplier,1,1)==EMPTY_VALUE
&& iClose(_Symbol,0,1)>iMA(_Symbol,0,MA_Period,0,0,0,1))OrderEntry(0);
if(iCustom(_Symbol,0,"SuperTrend MT4 Indicator",Nbr_Periods,Multiplier,1,1)!=EMPTY_VALUE
&& iCustom(_Symbol,0,"SuperTrend MT4 Indicator",Nbr_Periods,Multiplier,0,1)==EMPTY_VALUE
&& iClose(_Symbol,0,1)<iMA(_Symbol,0,MA_Period,0,0,0,1))OrderEntry(1);
}
//+-------------------------------------------------------------------+
void OrderEntry(int Direction){
double BTP=0,STP=0,BSL=0,SSL=0;
if(Take_Profit>0){BTP=Ask+Take_Profit*pips;STP=Bid-Take_Profit*pips;}
if(Stop_Loss>0){BSL=Ask-Stop_Loss*pips;SSL=Bid+Stop_Loss*pips;}
if(AutoLotSizing && RiskPercent>0)
{
double Equity=AccountEquity();
double RiskedAmount=Equity*RiskPercent*0.01;
if(Stop_Loss>0)LotSize=(RiskedAmount/(Stop_Loss*pips/pips))/10;
}
if((Use_Time_For_EA && TimeCurrent()>=StrToTime(Start_Time) && TimeCurrent()<=StrToTime(Ending_Time)) || !Use_Time_For_EA){
if(Direction==0 && OpenOrdersThisPairBuy(Symbol())==0)int BuyTicket=OrderSend(_Symbol,OP_BUY,LotSize,Ask,3,BSL,BTP,NULL,MagicNumber,0,clrGreen);
if(Direction==1 && OpenOrdersThisPairSell(Symbol())==0)int SellTiclet=OrderSend(_Symbol,OP_SELL,LotSize,Bid,3,SSL,STP,NULL,MagicNumber,0,clrRed);
}
}
//+-------------------------------------------------------------------+
int OpenOrdersThisPairBuy(string SYMBOL)
{
int total=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))Print("error Selecting order ",GetLastError());
if(OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber && OrderSymbol()==SYMBOL)
total++;
}
return (total);
}
//+-------------------------------------------------------------------+
int OpenOrdersThisPairSell(string SYMBOL)
{
int total=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))Print("error Selecting order ",GetLastError());
if(OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber && OrderSymbol()==SYMBOL)
total++;
}
return (total);
}
//+-------------------------------------------------------------------+
bool IsNewCandle()
{
static int BarsOnChart=0;
if(Bars==BarsOnChart)
return (false);
BarsOnChart=Bars;
return(true);
}
//+-------------------------------------------------------------------+
void AdjustTrail()
{
for(int b=OrdersTotal()-1;b>=0;b--)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol())
if(OrderType()==OP_BUY)
if(NormalizeDouble(Bid-OrderOpenPrice(),Digits)>NormalizeDouble(WhenToTrail*pips,Digits))
if(OrderStopLoss()<NormalizeDouble(Bid-TrailAmount*pips,Digits) || OrderStopLoss()==0)
if(!OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(TrailAmount*pips),Digits),OrderTakeProfit(),0,CLR_NONE))
Print("error modifying buy order ",GetLastError());
}
for(int s=OrdersTotal()-1;s>=0;s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol())
if(OrderType()==OP_SELL)
if(NormalizeDouble(OrderOpenPrice()-Ask,Digits)>NormalizeDouble(WhenToTrail*pips,Digits))
if(OrderStopLoss()>NormalizeDouble(Ask+TrailAmount*pips,Digits) || OrderStopLoss()==0)
if(!OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+(TrailAmount*pips),Digits),OrderTakeProfit(),0,CLR_NONE))
Print("error modifying sell order ",GetLastError());
}
}
//+------------------------------------------------------------------+
شكرا جزيلا لك اخي الكريم ورحم الله والديك
شكرا شكرا