السلام عليكم ورحمة الله تعالى وبركاته
جزاكم الله الف خير على جميع المعلومات التي تقدمونها و جعلها الله صدقة جارية في الدنيا و الاخرة
عندي سؤال برمجي الله يبارك فيكم :
اذا اردت ان يتم فتح صفقات كلما تحرك السعر عدد من النقاط ستيب , مع شرط ان لا يفتح نفس نوع الصفقة من نفس السعر
حاولت كثيرا ان اجد صيغة الشرط او الدالة و لكن لم أفلح
اذا ممكن مساعدة
//+------------------------------------------------------------------+
//| Hajsoft1.mq4 |
//| Copyright 2015, HajSoft |
/
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, HajSoft""
#property version "1.00"
#property strict
extern double Lot = 0.01 ;
extern int StepOp = 3 ;
extern int StepReO = 1 ;
extern int TakeProfit = 0 ;
extern int HTP = 7 ;
extern int MagicNumber = 868380 ;
int T,B1,S1,C,B2,S2;
double TPB,TPS;
bool BE,SE ;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
T = 1 ;
if ( Digits == 5 || Digits == 3 ){ T = 10 ;}
if ( TakeProfit == 0 ) {TPB = 0;}
else {TPB = Ask+TakeProfit*Point*T;}
if ( TakeProfit == 0 ) {TPS = 0;}
else {TPS = Bid-TakeProfit*Point*T;}
B1= OrderSend(Symbol(),OP_BUY,Lot,Ask,4,0,TPB," Buy Initial ",MagicNumber,0,clrSeaGreen);
S1 = OrderSend(Symbol(),OP_SELL,Lot,Bid,4,0,TPS," Sell Initial ",MagicNumber,0,clrDarkOrange);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
double OrderStepPriceB2 = LastOpenPriceB() + StepOp*Point*T ;
double OrderStepPriceS2 = LastOpenPriceS() - StepOp*Point*T ;
//if ( Ask != OrderOpenPrice() )
//if ( Ask >= OrderOpenPrice() + StepReO*Point*T )
//if ( Ask <= OrderOpenPrice ()- StepReO*Point*T )
{
if ( Ask > OrderStepPriceB2 )
{
B2 = OrderSend(Symbol(),OP_BUY,Lot,Ask,4,0,TPB," Buy Initial ",MagicNumber,0,clrSeaGreen);
S2 = OrderSend(Symbol(),OP_SELL,Lot,Bid,4,0,TPS," Sell Initial ",MagicNumber,0,clrDarkOrange);
}
if ( Bid < OrderStepPriceS2 )
{
B2 = OrderSend(Symbol(),OP_BUY,Lot,Ask,4,0,TPB," Buy Initial ",MagicNumber,0,clrSeaGreen);
S2 = OrderSend(Symbol(),OP_SELL,Lot,Bid,4,0,TPS," Sell Initial ",MagicNumber,0,clrDarkOrange);
}
}
}
double LastOpenPriceB()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
bool s1=OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()== MagicNumber && OrderType() == OP_BUY )
{
return(OrderOpenPrice());}
}
return(0);
}
//--------------------- LastOpenPrice For Sell Order -----------------------+
double LastOpenPriceS()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
bool s1=OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()== MagicNumber && OrderType() == OP_SELL )
{
return(OrderOpenPrice());}
}
return(0);
}
//////////////////////
//+------------------------ Hide TakeProfit For Buy Orders ------------------------------------------+
int HBuyTP()
{
for( int i=OrdersTotal() ; i>=0 ; i-- )
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY)
{
if (Bid>(OrderOpenPrice() + HTP * Point * T))
{
C = OrderClose(OrderTicket(),OrderLots(),Bid,4*T,clrAq uamarine);
}
}
}
}
return(0);
}
//+----------------------- Hide TakeProfit For Sell Orders ------------------------------------------+
int HSellTP()
{
for( int i=OrdersTotal() ; i>=0 ; i-- )
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL)
{
if (Ask<(OrderOpenPrice() - HTP * Point * T))
{
C = OrderClose(OrderTicket(),OrderLots(),Ask,4*T,clrAq uamarine);
}
}
}
}
return(0);
}