عرض مشاركة واحدة
قديم 25-04-2013, 12:55 AM   المشاركة رقم: 168
الكاتب
imaddine
عضو نشيط

البيانات
تاريخ التسجيل: Dec 2012
رقم العضوية: 12839
المشاركات: 202
بمعدل : 0.05 يوميا

الإتصالات
الحالة:
imaddine غير متواجد حالياً
وسائل الإتصال:

كاتب الموضوع : MOVING_AVERAGE المنتدى : منتدى المؤشرات و الاكسبيرتات
افتراضي رد: دورة تعليم برمجة الاكسبريت

استاذ موفنج اعلم انك لا تمتلك الكثير من
الوقت نظرا لكثرت الطلبات فالله يكون في عونك
لكن لو سمحت ممكن ان تعدل على هذا الكود
وساقوم باطلاع عليه لدراسته من جديد لو سمحت
[PHP]double TP,SL;

if(TrailingStop>0)MoveTrailingStop();
//////////////////////////////////////////////////
double openprice,lots,newLot;int s;
if(UseMultiplier){
for(s=0;s<OrdersTotal();s++){
OrderSelect(s,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber&&OrderType()==OP_BUY){
openprice=OrderOpenPrice();lots=OrderLots();
}
}{

هنا قمت بجعل المضاعف + وكمتغير خاجي جعلت Multiplier =1
حتى تكون المضاعفات 1 2 3 4 5 6
newLot=Multiplier+lots;
if(Ask<=openprice-Step*point&&orderstotal()>=1){
if(TakeProfit==0){TP=0;}else{TP=Ask+TakeProfit*poi nt;}

OrderSend(Symbol(),OP_BUY,newLot,NormalizeDouble(A sk,digits),3,0,TP," ",MagicNumber,0,Blue);

}
}
for(s=0;s<OrdersTotal();s++){
OrderSelect(s,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber&&OrderType()==OP_SELL){
openprice=OrderOpenPrice(); lots=OrderLots();
}
}{

newLot=Multiplier+lots;
if(Bid>=openprice+Step*point&&orderstotal()>=1){
if(TakeProfit==0){TP=0;}else{TP=Bid-TakeProfit*point;}
OrderSend(Symbol(),OP_SELL,newLot,NormalizeDouble( Bid,digits),3,0,TP,"",MagicNumber,0,Red);

}
}
}


//////////////////////////////////////////////////
static datetime NewBar;
if(orderstotal()==0)

{
// close orders
}

double Cl1=iClose(0,0,1);
double Cl2=iClose(0,0,2);

//////////////////////////////////////////////////

if(NewBar<Time[0])

if(Cl2<Cl1)
{CloseSellOrders();}

if(Cl2>Cl1)
{CloseBuyOrders();}

if(profit()>=ProfitTarget){
while(orderstotal()>0){CloseSellOrders();CloseBuyO rders();}
هنا المشكلة الاولى كيف اجعله يحافظ على الصفقات الخاسرة
دون اغلاقها
}
{
// close orders
}
//////////////////////////////////////////////////

if(Cl2<Cl1) {
if(orderstotal()<MaxTrades&&Time0!=Time[0])
{
{
// open orders
Time0=Time[0];
}
//Buy
if(TakeProfit==0){TP=0;}
else{TP=Ask+TakeProfit*point;}
if(StopLoss==0){SL=0;}
else{SL=Ask-StopLoss*point;}
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,SL,TP,"",Magi cNumber,0,Blue);
}
}
//////////////////////////////////////////////////


if(Cl2>Cl1){
if(orderstotal()<MaxTrades&&Time0!=Time[0])
{
{
// open orders
Time0=Time[0];
}
//Sell
if(TakeProfit==0){TP=0;}
else{TP=Bid-TakeProfit*point;}
if(StopLoss==0){SL=0;}
else{SL=Bid+StopLoss*point;}
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,SL,TP,"",Mag icNumber,0,Red);

}
}

return(0);
}
//+------------------------------------------------------------------+

void CloseBuyOrders()
{
for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == MagicNumber && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
}
}
}

void CloseSellOrders()
{
for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == MagicNumber && OrderSymbol()==Symbol())
{
if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
}
void MoveTrailingStop()
{

for(int cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol()&& OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)
{
if(TrailingStop>0&&NormalizeDouble(Ask-TrailingStep*point,digits)>NormalizeDouble(OrderOp enPrice()+TrailingStop*point,digits))
{
if((NormalizeDouble(OrderStopLoss(),digits)<Normal izeDouble(Bid-TrailingStop*point,digits))||(OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(Bid-TrailingStop*point,digits),OrderTakeProfit(),0,Blu e);

}
}
}
else
{
if(TrailingStop>0&&NormalizeDouble(Bid+TrailingSte p*point,digits)<NormalizeDouble(OrderOpenPrice()-TrailingStop*point,digits))
{
if((NormalizeDouble(OrderStopLoss(),digits)>(Norma lizeDouble(Ask+TrailingStop*point,digits)))||(Orde rStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(Ask+TrailingStop*point,digits),OrderTakeP rofit(),0,Red);

}
}
}
}
}
}

اعتمدت هنا على دالة اغلاق على ربح معين لكن لو امكن
جعل الطريقة كما شرحتها يخرج عند اشارة عكسية مهما كان
الربح كبير او صغير او حتى على نقطة التعادل
double profit(){
double c;
for(int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber){
c=c+OrderProfit();
}
}
return(c);
}
[/PHP]

طبعا ان يحافظ على الصفقات الخاسرة ويضاعف اللوت
1 2 3 4 5 اي كل مرة +1 وعندما تكون الاشارة عكسية
والمحصلة ربح يغلق كل الصفقات ويعيد من جديد
وبارك الله فيك



عرض البوم صور imaddine  
رد مع اقتباس
  #168  
قديم 25-04-2013, 12:55 AM
imaddine imaddine غير متواجد حالياً
عضو نشيط
افتراضي رد: دورة تعليم برمجة الاكسبريت

استاذ موفنج اعلم انك لا تمتلك الكثير من
الوقت نظرا لكثرت الطلبات فالله يكون في عونك
لكن لو سمحت ممكن ان تعدل على هذا الكود
وساقوم باطلاع عليه لدراسته من جديد لو سمحت
[PHP]double TP,SL;

if(TrailingStop>0)MoveTrailingStop();
//////////////////////////////////////////////////
double openprice,lots,newLot;int s;
if(UseMultiplier){
for(s=0;s<OrdersTotal();s++){
OrderSelect(s,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber&&OrderType()==OP_BUY){
openprice=OrderOpenPrice();lots=OrderLots();
}
}{

هنا قمت بجعل المضاعف + وكمتغير خاجي جعلت Multiplier =1
حتى تكون المضاعفات 1 2 3 4 5 6
newLot=Multiplier+lots;
if(Ask<=openprice-Step*point&&orderstotal()>=1){
if(TakeProfit==0){TP=0;}else{TP=Ask+TakeProfit*poi nt;}

OrderSend(Symbol(),OP_BUY,newLot,NormalizeDouble(A sk,digits),3,0,TP," ",MagicNumber,0,Blue);

}
}
for(s=0;s<OrdersTotal();s++){
OrderSelect(s,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber&&OrderType()==OP_SELL){
openprice=OrderOpenPrice(); lots=OrderLots();
}
}{

newLot=Multiplier+lots;
if(Bid>=openprice+Step*point&&orderstotal()>=1){
if(TakeProfit==0){TP=0;}else{TP=Bid-TakeProfit*point;}
OrderSend(Symbol(),OP_SELL,newLot,NormalizeDouble( Bid,digits),3,0,TP,"",MagicNumber,0,Red);

}
}
}


//////////////////////////////////////////////////
static datetime NewBar;
if(orderstotal()==0)

{
// close orders
}

double Cl1=iClose(0,0,1);
double Cl2=iClose(0,0,2);

//////////////////////////////////////////////////

if(NewBar<Time[0])

if(Cl2<Cl1)
{CloseSellOrders();}

if(Cl2>Cl1)
{CloseBuyOrders();}

if(profit()>=ProfitTarget){
while(orderstotal()>0){CloseSellOrders();CloseBuyO rders();}
هنا المشكلة الاولى كيف اجعله يحافظ على الصفقات الخاسرة
دون اغلاقها
}
{
// close orders
}
//////////////////////////////////////////////////

if(Cl2<Cl1) {
if(orderstotal()<MaxTrades&&Time0!=Time[0])
{
{
// open orders
Time0=Time[0];
}
//Buy
if(TakeProfit==0){TP=0;}
else{TP=Ask+TakeProfit*point;}
if(StopLoss==0){SL=0;}
else{SL=Ask-StopLoss*point;}
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,SL,TP,"",Magi cNumber,0,Blue);
}
}
//////////////////////////////////////////////////


if(Cl2>Cl1){
if(orderstotal()<MaxTrades&&Time0!=Time[0])
{
{
// open orders
Time0=Time[0];
}
//Sell
if(TakeProfit==0){TP=0;}
else{TP=Bid-TakeProfit*point;}
if(StopLoss==0){SL=0;}
else{SL=Bid+StopLoss*point;}
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,SL,TP,"",Mag icNumber,0,Red);

}
}

return(0);
}
//+------------------------------------------------------------------+

void CloseBuyOrders()
{
for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == MagicNumber && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
}
}
}

void CloseSellOrders()
{
for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == MagicNumber && OrderSymbol()==Symbol())
{
if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
}
void MoveTrailingStop()
{

for(int cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol()&& OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)
{
if(TrailingStop>0&&NormalizeDouble(Ask-TrailingStep*point,digits)>NormalizeDouble(OrderOp enPrice()+TrailingStop*point,digits))
{
if((NormalizeDouble(OrderStopLoss(),digits)<Normal izeDouble(Bid-TrailingStop*point,digits))||(OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(Bid-TrailingStop*point,digits),OrderTakeProfit(),0,Blu e);

}
}
}
else
{
if(TrailingStop>0&&NormalizeDouble(Bid+TrailingSte p*point,digits)<NormalizeDouble(OrderOpenPrice()-TrailingStop*point,digits))
{
if((NormalizeDouble(OrderStopLoss(),digits)>(Norma lizeDouble(Ask+TrailingStop*point,digits)))||(Orde rStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(Ask+TrailingStop*point,digits),OrderTakeP rofit(),0,Red);

}
}
}
}
}
}

اعتمدت هنا على دالة اغلاق على ربح معين لكن لو امكن
جعل الطريقة كما شرحتها يخرج عند اشارة عكسية مهما كان
الربح كبير او صغير او حتى على نقطة التعادل
double profit(){
double c;
for(int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber){
c=c+OrderProfit();
}
}
return(c);
}
[/PHP]

طبعا ان يحافظ على الصفقات الخاسرة ويضاعف اللوت
1 2 3 4 5 اي كل مرة +1 وعندما تكون الاشارة عكسية
والمحصلة ربح يغلق كل الصفقات ويعيد من جديد
وبارك الله فيك




رد مع اقتباس