FX-Arabia

جديد المواضيع















الملاحظات

منتدى المؤشرات و الاكسبيرتات تعليم برمجة الاكسبيرت ، اكسبيرت مجانى ، برمجة مؤشرات ، مؤشر ، تصميم اكسبيرت مجانا ، اكسبيرتات جديدة ، مؤشرات جديدة ، كل ما يتعلق بالتحليل و الخاص بالمؤشرات الفنية او الرقمية ، Expert advisor ، mql ، mql4 ، دورة برمجة ، برمجة اكسبيرت ، اكسبيرت رابح ، اكسبيرت جيد ، ادارة حسابات ، تداول الى ، ميتاتريدر ، تحميل منصة ، منصة تداول ، برمجة مؤشر ، مكتبة مؤشرات ، مؤشر جديد ، مؤشرات جديدة ، مؤشر حصرى ، احدث مؤشر .


تصحيح كود برمجي

منتدى المؤشرات و الاكسبيرتات


إضافة رد
 
أدوات الموضوع
قديم 22-02-2023, 11:21 AM   المشاركة رقم: 1
الكاتب
knives55
عضو جديد

البيانات
تاريخ التسجيل: Mar 2016
رقم العضوية: 30027
العمر: 33
المشاركات: 3
بمعدل : 0.00 يوميا

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

المنتدى : منتدى المؤشرات و الاكسبيرتات
افتراضي تصحيح كود برمجي

سلام عليكم اانا استخدم اكسبرت مستردولار لكن وجدة فيه مشكل مزعج جدا وهو دئما اول امر هو بيع ديما بيع لا يفتح شراء ابدا

اريد اعرف اين كود لي فيه مشكل بحيث برنامج يصبح يفتح شراء وبيع حسب اختيار

وكذلك اريد اضافة امر حيث اذا كانت صفقه مفتوحه بيع عند غلق يفتح عكسها شراء وهكذا

كود:
//+------------------------------------------------------------------+
//|              www.arabictrader.com                                |
//|              MR.dollar                                           |
//+------------------------------------------------------------------+

#property copyright "MR.dollarEA"
#property link      "mrdollar.cs@gmail.com"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum order
  {
   SELL,BUY 
  };
 

input bool  EnableTimeFilter=false;
input string  Start_Hour="00:00";
input string  End_Hour="23:00";

input string info_1=" Multiplier Settings ";
input order FirstOrder= SELECT_BY_POS;
input int Step=20;
input int TakeProfit=20;
input int StopLoss=0;
input double Multiplier=2;

input int TradesNumberForTakeProfit2=4;
input int TakeProfit2=20;
input bool EnableProfitUSD=false;
input double TotalProfitUSD=0;
input string info_2="Custom Lot Multiplier Settings";
input bool EnableCustomLot=false;
input double  Lots_1=0.1;
input double  Lots_2=0.1;
input double  Lots_3=0.1;
input double  Lots_4=0.1;
input double  Lots_5=0.1;
input double  Lots_6=0.1;
input double  Lots_7=0.1;
input double  Lots_8=0.1;
input double  Lots_9=0.1;
input double  Lots_10=0.1;
input double  Lots_11=0.1;
input double  Lots_12=0.1;
input double  Lots_13=0.1;
input double  Lots_14=0.1;
input double  Lots_15=0.1;
input double  Lots_16=0.1;
input double  Lots_17=0.1;
input double  Lots_18=0.1;
input double  Lots_19=0.1;
input double  Lots_20=0.1;

input string  MM_Parameters=" Money Management ";
input double  Lots=0.1;
input bool  MoneyManagement=false;
input double  Risk=1;
input int MagicNumber=2035;

double point;
int digits,P;
int lot_digits;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(MarketInfo(Symbol(),MODE_MINLOT)<0.1)lot_digits=2;
   else lot_digits=1;
   if(Digits==5 || Digits==3)P=10;
   else P=1;
   if(Digits<4)
     {
      point=0.01;
      digits=2;
     }
   else
     {
      point=0.0001;
      digits=4;
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS    deinitialization function                |
//+------------------------------------------------------------------+

void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int orderscnt(int type=-1)
  {
   int cnt=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber() && (OrderType()==type || type==-1))
           {
            cnt++;
           }
        }
     }
   return(cnt);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool TimeFilter(string StartH,string EndH)
  {
   datetime Start=StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+StartH);
   datetime End=StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+EndH);

   if(!(Time[0]>=Start && Time[0]<=End))
     {
      return(false);
     }
   return(true);
  }
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS   Start function                            |
//+------------------------------------------------------------------+

void OnTick()
  {

   Comment("Programmed By MR.dollar\n"+"www.ArabicTrader.com");

   if(EnableProfitUSD)
     {
      if(TotalProfit()>=TotalProfitUSD)
        {
         CloseAll();
        }
     }
   double newLot,TP,SL,price,multiplier=Multiplier;
   int ticket;

   if(orderscnt(OP_BUY)>0 && orderscnt(OP_SELL)==0)
     {
      if(LastClosedOrderInfo("Time",OP_SELL)>LastCurrentOrderInfo("Time"))
        {
         CloseAll();
        }
     }
   if(orderscnt(OP_SELL)>0 && orderscnt(OP_BUY)==0)
     {
      if(LastClosedOrderInfo("Time",OP_BUY)>LastCurrentOrderInfo("Time"))
        {
         CloseAll();
        }
     }

   if((orderscnt(OP_SELL)==0 && orderscnt(OP_BUYSTOP)>0) || (orderscnt(OP_BUY)==0 && orderscnt(OP_SELLSTOP)>0))
     {
      CloseAll();
     }

   ModifyAllOrdersTP(OP_SELL);
   ModifyAllOrdersTP(OP_BUY);

   if(orderscnt()>0)
     {
      if(LastCurrentOrderInfo("Type")==OP_BUY && orderscnt(OP_SELLSTOP)==0)
        {

         price=LastCurrentOrderInfo("Price")-Step*point;
         if(TakeProfit!=0)TP=price-TakeProfit*point;
         if(orderscnt()>=TradesNumberForTakeProfit2)TP=price-TakeProfit2*point;
         if(StopLoss!=0)SL=price+StopLoss*point;

         newLot=NormalizeDouble(LastCurrentOrderInfo("Lots",OP_BUY)*multiplier,lot_digits);
         if(EnableCustomLot)
           {
            int order_num=int(LastCurrentOrderInfo("Comment",OP_BUY));
            newLot=GetNextLot(order_num);
           }

         ticket=OrderSend(Symbol(),OP_SELLSTOP,newLot,NormalizeDouble(price,Digits),3*P,SL,TP,string(order_num+1),MagicNumber,0,Red);

         if(ticket<0)Print("Open Sell Stop Error: "+GetLastError());

        }

      if(LastCurrentOrderInfo("Type")==OP_SELL && orderscnt(OP_BUYSTOP)==0)
        {

         price=LastCurrentOrderInfo("Price")+Step*point;
         if(TakeProfit!=0)TP=price+TakeProfit*point;
         if(orderscnt()>=TradesNumberForTakeProfit2)TP=price+TakeProfit2*point;
         if(StopLoss!=0)SL=price-StopLoss*point;
         newLot=NormalizeDouble(LastCurrentOrderInfo("Lots",OP_SELL)*multiplier,lot_digits);

         if(EnableCustomLot)
           {
            order_num=int(LastCurrentOrderInfo("Comment",OP_SELL));
            newLot=GetNextLot(order_num);
           }

         ticket=OrderSend(Symbol(),OP_BUYSTOP,newLot,NormalizeDouble(price,Digits),3*P,SL,TP,string(order_num+1),MagicNumber,0,Blue);

         if(ticket<0)Print("Open Buy Stop Error: "+GetLastError());

        }
     }
////////////////////////////////////////////////////

   if(EnableTimeFilter&&TimeFilter(Start_Hour,End_Hour)==false)return;


   if(MoneyManagement) newLot=LotManage();
   else newLot=Lots;

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

   if(orderscnt()<1)
     {
      if(LastClosedOrderInfo("Type")==OP_SELL || (FirstOrder==BUY && LastClosedOrderInfo("Type")==-1))
        {
         if(TakeProfit==0){TP=0;}else{TP=Ask+TakeProfit*point;}
         if(StopLoss!=0)SL=Ask-StopLoss*point;

         ticket=OrderSend(Symbol(),OP_BUY,newLot,NormalizeDouble(Ask,Digits),3*P,SL,TP,"1",MagicNumber,0,Blue);
        }
      else
        {
         if(TakeProfit==0){TP=0;}else{TP=Bid-TakeProfit*point;}
         if(StopLoss!=0)SL=Bid+StopLoss*point;

         ticket=OrderSend(Symbol(),OP_SELL,newLot,NormalizeDouble(Bid,Digits),3*P,SL,TP,"1",MagicNumber,0,Red);
        }
      if(ticket<0)Print("Open Buy Error: "+GetLastError());
      PlaySound("Alert.wav");
     }

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

double GetNextLot(int cnt)
  {
   switch(cnt)
     {
      case 1:return(Lots_2);
      case 2:return(Lots_3);
      case 3:return(Lots_4);
      case 4:return(Lots_5);
      case 5:return(Lots_6);
      case 6:return(Lots_7);
      case 7:return(Lots_8);
      case 8:return(Lots_9);
      case 9:return(Lots_10);
      case 10:return(Lots_11);
      case 11:return(Lots_12);
      case 12:return(Lots_13);
      case 13:return(Lots_14);
      case 14:return(Lots_15);
      case 15:return(Lots_16);
      case 16:return(Lots_17);
      case 17:return(Lots_18);
      case 18:return(Lots_19);
      case 19:return(Lots_20);
      default:return(Lots_20);
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double TotalProfit()
  {
   double profit;
   for(int i=0;i<OrdersTotal();i++)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {
         profit+=OrderProfit();
        }
     }
   return(profit);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double LastClosedOrderInfo(string info,int type=-1)
  {
   for(int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type || type==-1))
        {

         if(info=="Type")return(OrderType());
         else if(info=="Lots")return(OrderLots());
         else if(info=="Price")return(OrderOpenPrice());
         else if(info=="TP")return(OrderTakeProfit());
         else if(info=="SL")return(OrderStopLoss());
         else if(info=="Profit")return(OrderProfit());
         else if(info=="Time")return(OrderCloseTime());
         else if(info=="Comment")return(StringToDouble(OrderComment()));



        }
     }
   return(-1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double LastCurrentOrderInfo(string info,int type=-1)
  {
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type || type==-1))
        {
         if(info=="Type")return(OrderType());
         else if(info=="Lots")return(OrderLots());
         else if(info=="Price")return(OrderOpenPrice());
         else if(info=="TP")return(OrderTakeProfit());
         else if(info=="SL")return(OrderStopLoss());
         else if(info=="Profit")return(OrderProfit());
         else if(info=="Time")return(OrderOpenTime());
         else if(info=="Comment")return(StringToDouble(OrderComment()));
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModifyAllOrdersTP(int type)
  {
   double TP=LastCurrentOrderInfo("TP",type);
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type || type==-1))
        {
         if(OrderTakeProfit()!=TP)
           {
            bool modify=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TP,0);
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS   Money Managment                           |
//+------------------------------------------------------------------+ 

double LotManage()
  {
   double lot=MathCeil(AccountFreeMargin() *Risk/1000)/100;

   if(lot<MarketInfo(Symbol(),MODE_MINLOT))lot=MarketInfo(Symbol(),MODE_MINLOT);
   if(lot>MarketInfo(Symbol(),MODE_MAXLOT))lot=MarketInfo(Symbol(),MODE_MAXLOT);


   return (NormalizeDouble(lot,2));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAll()
  {

   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {
         if(OrderType()==OP_BUY)
           {
            bool close_b=OrderClose(OrderTicket(),OrderLots(),Bid,3*P);
           }
         else if(OrderType()==OP_SELL)
           {
            bool close_s=OrderClose(OrderTicket(),OrderLots(),Ask,3*P);
           }
         else
           {
            bool del=OrderDelete(OrderTicket());
           }
        }
     }
  }

//+---------------------------------------------------------------------------------+



عرض البوم صور knives55  
رد مع اقتباس


  #1  
قديم 22-02-2023, 11:21 AM
knives55 knives55 غير متواجد حالياً
عضو جديد
افتراضي تصحيح كود برمجي

سلام عليكم اانا استخدم اكسبرت مستردولار لكن وجدة فيه مشكل مزعج جدا وهو دئما اول امر هو بيع ديما بيع لا يفتح شراء ابدا

اريد اعرف اين كود لي فيه مشكل بحيث برنامج يصبح يفتح شراء وبيع حسب اختيار

وكذلك اريد اضافة امر حيث اذا كانت صفقه مفتوحه بيع عند غلق يفتح عكسها شراء وهكذا

كود:
//+------------------------------------------------------------------+
//|              www.arabictrader.com                                |
//|              MR.dollar                                           |
//+------------------------------------------------------------------+

#property copyright "MR.dollarEA"
#property link      "mrdollar.cs@gmail.com"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum order
  {
   SELL,BUY 
  };
 

input bool  EnableTimeFilter=false;
input string  Start_Hour="00:00";
input string  End_Hour="23:00";

input string info_1=" Multiplier Settings ";
input order FirstOrder= SELECT_BY_POS;
input int Step=20;
input int TakeProfit=20;
input int StopLoss=0;
input double Multiplier=2;

input int TradesNumberForTakeProfit2=4;
input int TakeProfit2=20;
input bool EnableProfitUSD=false;
input double TotalProfitUSD=0;
input string info_2="Custom Lot Multiplier Settings";
input bool EnableCustomLot=false;
input double  Lots_1=0.1;
input double  Lots_2=0.1;
input double  Lots_3=0.1;
input double  Lots_4=0.1;
input double  Lots_5=0.1;
input double  Lots_6=0.1;
input double  Lots_7=0.1;
input double  Lots_8=0.1;
input double  Lots_9=0.1;
input double  Lots_10=0.1;
input double  Lots_11=0.1;
input double  Lots_12=0.1;
input double  Lots_13=0.1;
input double  Lots_14=0.1;
input double  Lots_15=0.1;
input double  Lots_16=0.1;
input double  Lots_17=0.1;
input double  Lots_18=0.1;
input double  Lots_19=0.1;
input double  Lots_20=0.1;

input string  MM_Parameters=" Money Management ";
input double  Lots=0.1;
input bool  MoneyManagement=false;
input double  Risk=1;
input int MagicNumber=2035;

double point;
int digits,P;
int lot_digits;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(MarketInfo(Symbol(),MODE_MINLOT)<0.1)lot_digits=2;
   else lot_digits=1;
   if(Digits==5 || Digits==3)P=10;
   else P=1;
   if(Digits<4)
     {
      point=0.01;
      digits=2;
     }
   else
     {
      point=0.0001;
      digits=4;
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS    deinitialization function                |
//+------------------------------------------------------------------+

void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int orderscnt(int type=-1)
  {
   int cnt=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber() && (OrderType()==type || type==-1))
           {
            cnt++;
           }
        }
     }
   return(cnt);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool TimeFilter(string StartH,string EndH)
  {
   datetime Start=StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+StartH);
   datetime End=StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+" "+EndH);

   if(!(Time[0]>=Start && Time[0]<=End))
     {
      return(false);
     }
   return(true);
  }
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS   Start function                            |
//+------------------------------------------------------------------+

void OnTick()
  {

   Comment("Programmed By MR.dollar\n"+"www.ArabicTrader.com");

   if(EnableProfitUSD)
     {
      if(TotalProfit()>=TotalProfitUSD)
        {
         CloseAll();
        }
     }
   double newLot,TP,SL,price,multiplier=Multiplier;
   int ticket;

   if(orderscnt(OP_BUY)>0 && orderscnt(OP_SELL)==0)
     {
      if(LastClosedOrderInfo("Time",OP_SELL)>LastCurrentOrderInfo("Time"))
        {
         CloseAll();
        }
     }
   if(orderscnt(OP_SELL)>0 && orderscnt(OP_BUY)==0)
     {
      if(LastClosedOrderInfo("Time",OP_BUY)>LastCurrentOrderInfo("Time"))
        {
         CloseAll();
        }
     }

   if((orderscnt(OP_SELL)==0 && orderscnt(OP_BUYSTOP)>0) || (orderscnt(OP_BUY)==0 && orderscnt(OP_SELLSTOP)>0))
     {
      CloseAll();
     }

   ModifyAllOrdersTP(OP_SELL);
   ModifyAllOrdersTP(OP_BUY);

   if(orderscnt()>0)
     {
      if(LastCurrentOrderInfo("Type")==OP_BUY && orderscnt(OP_SELLSTOP)==0)
        {

         price=LastCurrentOrderInfo("Price")-Step*point;
         if(TakeProfit!=0)TP=price-TakeProfit*point;
         if(orderscnt()>=TradesNumberForTakeProfit2)TP=price-TakeProfit2*point;
         if(StopLoss!=0)SL=price+StopLoss*point;

         newLot=NormalizeDouble(LastCurrentOrderInfo("Lots",OP_BUY)*multiplier,lot_digits);
         if(EnableCustomLot)
           {
            int order_num=int(LastCurrentOrderInfo("Comment",OP_BUY));
            newLot=GetNextLot(order_num);
           }

         ticket=OrderSend(Symbol(),OP_SELLSTOP,newLot,NormalizeDouble(price,Digits),3*P,SL,TP,string(order_num+1),MagicNumber,0,Red);

         if(ticket<0)Print("Open Sell Stop Error: "+GetLastError());

        }

      if(LastCurrentOrderInfo("Type")==OP_SELL && orderscnt(OP_BUYSTOP)==0)
        {

         price=LastCurrentOrderInfo("Price")+Step*point;
         if(TakeProfit!=0)TP=price+TakeProfit*point;
         if(orderscnt()>=TradesNumberForTakeProfit2)TP=price+TakeProfit2*point;
         if(StopLoss!=0)SL=price-StopLoss*point;
         newLot=NormalizeDouble(LastCurrentOrderInfo("Lots",OP_SELL)*multiplier,lot_digits);

         if(EnableCustomLot)
           {
            order_num=int(LastCurrentOrderInfo("Comment",OP_SELL));
            newLot=GetNextLot(order_num);
           }

         ticket=OrderSend(Symbol(),OP_BUYSTOP,newLot,NormalizeDouble(price,Digits),3*P,SL,TP,string(order_num+1),MagicNumber,0,Blue);

         if(ticket<0)Print("Open Buy Stop Error: "+GetLastError());

        }
     }
////////////////////////////////////////////////////

   if(EnableTimeFilter&&TimeFilter(Start_Hour,End_Hour)==false)return;


   if(MoneyManagement) newLot=LotManage();
   else newLot=Lots;

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

   if(orderscnt()<1)
     {
      if(LastClosedOrderInfo("Type")==OP_SELL || (FirstOrder==BUY && LastClosedOrderInfo("Type")==-1))
        {
         if(TakeProfit==0){TP=0;}else{TP=Ask+TakeProfit*point;}
         if(StopLoss!=0)SL=Ask-StopLoss*point;

         ticket=OrderSend(Symbol(),OP_BUY,newLot,NormalizeDouble(Ask,Digits),3*P,SL,TP,"1",MagicNumber,0,Blue);
        }
      else
        {
         if(TakeProfit==0){TP=0;}else{TP=Bid-TakeProfit*point;}
         if(StopLoss!=0)SL=Bid+StopLoss*point;

         ticket=OrderSend(Symbol(),OP_SELL,newLot,NormalizeDouble(Bid,Digits),3*P,SL,TP,"1",MagicNumber,0,Red);
        }
      if(ticket<0)Print("Open Buy Error: "+GetLastError());
      PlaySound("Alert.wav");
     }

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

double GetNextLot(int cnt)
  {
   switch(cnt)
     {
      case 1:return(Lots_2);
      case 2:return(Lots_3);
      case 3:return(Lots_4);
      case 4:return(Lots_5);
      case 5:return(Lots_6);
      case 6:return(Lots_7);
      case 7:return(Lots_8);
      case 8:return(Lots_9);
      case 9:return(Lots_10);
      case 10:return(Lots_11);
      case 11:return(Lots_12);
      case 12:return(Lots_13);
      case 13:return(Lots_14);
      case 14:return(Lots_15);
      case 15:return(Lots_16);
      case 16:return(Lots_17);
      case 17:return(Lots_18);
      case 18:return(Lots_19);
      case 19:return(Lots_20);
      default:return(Lots_20);
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double TotalProfit()
  {
   double profit;
   for(int i=0;i<OrdersTotal();i++)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {
         profit+=OrderProfit();
        }
     }
   return(profit);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double LastClosedOrderInfo(string info,int type=-1)
  {
   for(int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type || type==-1))
        {

         if(info=="Type")return(OrderType());
         else if(info=="Lots")return(OrderLots());
         else if(info=="Price")return(OrderOpenPrice());
         else if(info=="TP")return(OrderTakeProfit());
         else if(info=="SL")return(OrderStopLoss());
         else if(info=="Profit")return(OrderProfit());
         else if(info=="Time")return(OrderCloseTime());
         else if(info=="Comment")return(StringToDouble(OrderComment()));



        }
     }
   return(-1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double LastCurrentOrderInfo(string info,int type=-1)
  {
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type || type==-1))
        {
         if(info=="Type")return(OrderType());
         else if(info=="Lots")return(OrderLots());
         else if(info=="Price")return(OrderOpenPrice());
         else if(info=="TP")return(OrderTakeProfit());
         else if(info=="SL")return(OrderStopLoss());
         else if(info=="Profit")return(OrderProfit());
         else if(info=="Time")return(OrderOpenTime());
         else if(info=="Comment")return(StringToDouble(OrderComment()));
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModifyAllOrdersTP(int type)
  {
   double TP=LastCurrentOrderInfo("TP",type);
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type || type==-1))
        {
         if(OrderTakeProfit()!=TP)
           {
            bool modify=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TP,0);
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS   Money Managment                           |
//+------------------------------------------------------------------+ 

double LotManage()
  {
   double lot=MathCeil(AccountFreeMargin() *Risk/1000)/100;

   if(lot<MarketInfo(Symbol(),MODE_MINLOT))lot=MarketInfo(Symbol(),MODE_MINLOT);
   if(lot>MarketInfo(Symbol(),MODE_MAXLOT))lot=MarketInfo(Symbol(),MODE_MAXLOT);


   return (NormalizeDouble(lot,2));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAll()
  {

   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {
         if(OrderType()==OP_BUY)
           {
            bool close_b=OrderClose(OrderTicket(),OrderLots(),Bid,3*P);
           }
         else if(OrderType()==OP_SELL)
           {
            bool close_s=OrderClose(OrderTicket(),OrderLots(),Ask,3*P);
           }
         else
           {
            bool del=OrderDelete(OrderTicket());
           }
        }
     }
  }

//+---------------------------------------------------------------------------------+




رد مع اقتباس

قديم 23-02-2023, 06:02 PM   المشاركة رقم: 2
الكاتب
knives55
عضو جديد

البيانات
تاريخ التسجيل: Mar 2016
رقم العضوية: 30027
العمر: 33
المشاركات: 3
بمعدل : 0.00 يوميا

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

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

يعني ولا واحد قادر



عرض البوم صور knives55  
رد مع اقتباس
  #2  
قديم 23-02-2023, 06:02 PM
knives55 knives55 غير متواجد حالياً
عضو جديد
افتراضي رد: تصحيح كود برمجي

يعني ولا واحد قادر




رد مع اقتباس
إضافة رد

مواقع النشر (المفضلة)

الكلمات الدلالية (Tags)
برمجى, تصحيح

أدوات الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة



الساعة الآن 01:36 AM



جميع الحقوق محفوظة الى اف اكس ارابيا www.fx-arabia.com

تحذير المخاطرة

التجارة بالعملات الأجنبية تتضمن علي قدر كبير من المخاطر ومن الممكن ألا تكون مناسبة لجميع المضاربين, إستعمال الرافعة المالية في التجاره يزيد من إحتمالات الخطورة و التعرض للخساره, عليك التأكد من قدرتك العلمية و الشخصية على التداول.

تنبيه هام

موقع اف اكس ارابيا هو موقع تعليمي خالص يهدف الي توعية المستثمر العربي مبادئ الاستثمار و التداول الناجح ولا يتحصل علي اي اموال مقابل ذلك ولا يقوم بادارة محافظ مالية وان ادارة الموقع غير مسؤولة عن اي استغلال من قبل اي شخص لاسمها وتحذر من ذلك.

اتصل بنا

البريد الإلكتروني للدعم الفنى : support@fx-arabia.com
جميع الحقوق محفوظة اف اكس ارابيا – احدى مواقع Inwestopedia Sp. Z O.O. للاستشارات و التدريب – جمهورية بولندا الإتحادية.
Powered by vBulletin® Copyright ©2000 - 2024 , Designed by Fx-Arabia Team