النتائج 1 إلى 8 من 8
  1. #1
    الصورة الرمزية alshakatan
    alshakatan غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Mar 2007
    الإقامة
    المملكة العربية السعودية
    المشاركات
    439

    افتراضي كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    زي ما إنتم عارفين إنهم أضافوا رقم عشري للأسعار مثل 98.10 إلى 98.100 أو 0.9999 إلى 0.99990
    فما هو الكود لإسترجاع الرقم المكون من ثلاث أرقام عشرية إلى رقمين عشريين
    ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~~ ~~5~~~ ~~~~ ~~~ ~~4 أرقام

    وشكرا مقدما

  2. #2
    الصورة الرمزية ساق الجواء
    ساق الجواء غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Dec 2006
    الإقامة
    أنا من نجد ويكفيني هواها *** ويبري علتي شربي لماها
    المشاركات
    592

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    هناك عدة طرق وما أستخدمه منها شخصيا وقد لا تكون الطريقة الأفضل كما يلي:

    أضف المتحول العام التالي (قبل وظائف int و deint و start )

    كود:
    double Poin; 
    أضف الكود التالي ضمن وظيفة int . وإن لم تكن الوظيفة موجودة استحدثها.

    كود:
    if (Point == 0.00001) Poin = 0.0001; //6 digits
    else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)
    else Poin = Point; //Normal 
    استبدل أي كلمة Point في بقية كودك بكلمة Poin . ولا تبدلها في الكود المذكور أعلاه.

    اضغط زر كومبايل طبعا.

    مثال تطبيقي:


    كود:
    //+------------------------------------------------------------------+
    //|                                         abdullah_st.mq4|
    //|                                                                  |
    //+------------------------------------------------------------------+
    #property copyright "abdullah_st"
    #property link      "None"
    //-------------------------------
    #include <stdlib.mqh>
    #include <stderror.mqh>
    //-------------------------------
    extern int Slippage=3;
    extern int MagicNumber = 23215650;
    extern int TimeFrame = 0;// Optimize per currency pair. current=0 , M1=1, M5=5, M15=15,
    // M30=30, H1=60, H4=240, Daily=1440
    //-------------------------------
    extern bool MM=true;//Select true for automatic money management
    extern int RiskPercent=1;//Update per your desired risk
    extern double Lots=0.1;//Optimize per account balance
    extern int MaxTrades=1;
    //----------------------
    extern int StopLoss=25;         //Optimize per currency pair and timeframe
    extern int TakeProfit = 100;       //Optimize per currency pair and timeframe
    //--------------------------------
    extern bool TrailingAlls = true;
    extern int Trail = 25;            //Optimize per currency pair and timeframe
    extern int TrailStart = 5;       //Optimize per currencypair and timeframe
    //----------------------
    extern bool BreakEven = true;
    extern int  BreakEvenTrigger = 25;
    //------------------ 
    extern int TTFbars=15;//15=default number of bars for computation
    extern int TopLine=50;
    extern int BottomLine=-50;
    extern int t3_period=5;
    extern double b=0.7;
    //---------------- 
    double Poin; // global variable declaration to fix the 6 Digit Forex Quotes
    //issue for MetaTrader Expert Advisors
    string EA_Name = "abdullah_st";
    bool AlertOn = true;
    datetime timeprev=0;//Working only after a new candle.
    //+------------------------------------------------------------------+
    //| expert initialization function                                   |
    //+------------------------------------------------------------------+
    int init()
    {
     
     //Initialization to Check for unconventional Point digits number
     if (Point == 0.00001) Poin = 0.0001; //6 digits
     else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)
     else Poin = Point; //Normal for 5 & 3 Digit Forex Quotes
     return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    int deinit()
    {
     return(0);
    }
    //+------------------------------------------------------------------+
    //|  Money Mangement and Lot Optimization                                  |
    //+------------------------------------------------------------------+
    double LotsOptimized()
      {
       double lot=Lots;
    //------ get broker's min/max
       double MinLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MINLOT)),2);
       double MaxLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MAXLOT)),2);
    //------ automatically select lot size per MM
       if (MM) lot=NormalizeDouble(MathFloor(AccountFreeMargin()*RiskPercent/100)/100,1);
    //------ make lots automatically per broker's min/max
       if (lot < MinLots)
       lot=MinLots;
       if (lot > MaxLots)
       lot=MaxLots;   
       return(lot);
      } 
     
    //+------------------------------------------------------------------+
    //| expert start function                                            |
    //+------------------------------------------------------------------+
    int start()
    {
    //+------------------------------------------------------------------+
    //| Function calls                                            |
    //+------------------------------------------------------------------+
       if (TrailingAlls) Trailingalls(TrailStart, Trail); 
    //------------------------------------
       if (BreakEven)    Breakeven();
    //------------------------------------------------------------------+
    //| Working only at a new candle rather than at every tick                                            |
    //+------------------------------------------------------------------+
       if(timeprev==Time[0])//Time[0] is time of the cuurent bar
       return(0);
       timeprev=Time[0];
       //This means instead of working (ie moving TSL) after every tick, work only after
       //a new candle.
       //it makes testing faster and test profit results higher.
       //It means you can use your code only once for each bar, usually first tick.
       //Any other tick code doesn't work. Sometimes it is very usefull.
       //Any action in start function afer this code will be performed once within the Bars
       //regardless of the time you specify
    //+------------------------------------------------------------------+
    //| indicators                                  |
    //+------------------------------------------------------------------+
     double cMainBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/0,/*shift*/1);
     
     double cSignalBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/1,/*shift*/1);  
     
     double pMainBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/0,/*shift*/2);
     
     double pSignalBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/1,/*shift*/2);  
    //+------------------------------------------------------------------+
    //| implementing exit signals                                  |
    //+------------------------------------------------------------------+
    //------------- Closing Buy --------------------
          if(cMainBuffer>cSignalBuffer)
          if(pMainBuffer<pSignalBuffer)
          if(CountLongs()>0)
          {
          CloseLongs();
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to SHORT. BUY order has been closed");
          AlertOn = false;
          }
          }
          }
     
    //------------- Closing Sell --------------------
     
          if(cMainBuffer<cSignalBuffer)
          if(pMainBuffer>pSignalBuffer)
          if(CountShorts()>0)
          {
          CloseShorts();
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to LONG. SELL order has been closed");
          AlertOn = false;
          }
          }
          }
    //+------------------------------------------------------------------+
    //| implementing entry signals                                  |
    //+------------------------------------------------------------------+
    //------------- Placing Buy --------------------
     
          if(cMainBuffer>cSignalBuffer)
          if(pMainBuffer<pSignalBuffer)
          if(CountLongs()<1)
          {
          OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,Slippage,
          StopLong(Bid,StopLoss),TakeLong(Ask,TakeProfit),EA_Name,MagicNumber,0,Blue);
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to LONG. BUY order has been placed");
          AlertOn = false;
          }
          }
          }
    //------------- Placing Sell --------------------
     
          if(cMainBuffer<cSignalBuffer)
          if(pMainBuffer>pSignalBuffer)
          if(CountShorts()<1)
          {
          OrderSend(Symbol(),OP_SELL, LotsOptimized(),Bid,Slippage,
          StopShrt(Ask,StopLoss),TakeShrt(Bid,TakeProfit),EA_Name,MagicNumber,0,Red);
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to SHORT. SELL order has been placed");
          AlertOn = false;
          }
          }
          }
     
    //----------------------------
     
     return(0);
     } //End of Start function
    //+------------------------------------------------------------------+
    //| calculating orders breakeven                                   |
    //+------------------------------------------------------------------+
     
    void Breakeven()
       {
       int totalorders = OrdersTotal();
       for(int i=totalorders-1;i>=0;i--)
       {
     
       if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
       continue;
       if(OrderSymbol()!=Symbol())
       continue;
     
       if(OrderMagicNumber()!=MagicNumber)
       continue;
     
       if(BreakEven== false)
       continue;   
     
       if(BreakEvenTrigger == 0)
       continue;   
     
       if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     
       if(OrderSymbol()==Symbol())
     
       if(OrderMagicNumber()==MagicNumber)
       if(BreakEven== true)
     
       if(BreakEvenTrigger > 0)
       {   
     
       if(OrderType() == OP_BUY)
       {
       if(Ask<OrderOpenPrice())
       continue;
       if(OrderStopLoss()>=OrderOpenPrice()) 
       continue;
     
       if((NormalizeDouble(Ask,Digits)-NormalizeDouble(OrderOpenPrice(),Digits))<=(BreakEvenTrigger*Poin))
       continue;
       if(Ask>OrderOpenPrice())
       if(OrderStopLoss()<OrderOpenPrice() || OrderStopLoss()==0) 
       if((NormalizeDouble(Ask,Digits)-NormalizeDouble(OrderOpenPrice(),Digits))>(BreakEvenTrigger*Poin))
       { 
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+3*Poin,OrderTakeProfit(),0,Green);
       Print( "BUY Order moved to breakeven : ", OrderStopLoss());
       }
       }
     
       if(OrderType() == OP_SELL)
       {
       if(Bid>OrderOpenPrice())
       continue;
       if(OrderStopLoss()<=OrderOpenPrice()) 
       continue;
     
       if((NormalizeDouble(OrderOpenPrice(),Digits)-NormalizeDouble(Bid,Digits))<=(BreakEvenTrigger*Poin))
       continue;
       if(Bid<OrderOpenPrice())   
     
       if(OrderStopLoss()>OrderOpenPrice() || OrderStopLoss()==0) 
     
       if((NormalizeDouble(OrderOpenPrice(),Digits)-NormalizeDouble(Bid,Digits))>(BreakEvenTrigger*Poin))
       { 
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-3*Poin,OrderTakeProfit(),0,Green);
       Print( "SELL Order moved to breakeven : ", OrderStopLoss());
       }
       }
       }
       }
       return;
       }
    //+------------------------------------------------------------------+
    //| modifying orders trailing stop                                   |
    //+------------------------------------------------------------------+
     
    void Trailingalls(int start,int stop)
    {
     
     if(stop==0)
      return;
     
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
       continue;
      if(OrderSymbol()!=Symbol())
       continue;
     
      if(OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(TrailingAlls== false)
       continue;   
      if(start==0)
       continue;
      if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
     
      if(OrderSymbol()==Symbol())
     
      if(OrderMagicNumber()==MagicNumber)
     
      if(TrailingAlls== true)
     
      if(start>0)
      {
      if(OrderType()==OP_BUY)
      {
       //double Long_profit=NormalizeDouble(NormalizeDouble(Ask,Digits)
                   //-NormalizeDouble(OrderOpenPrice(),Digits)/Poin,0);
       double Long_profit=NormalizeDouble((Ask-OrderOpenPrice())/Poin,0);
       //double Long_profit=NormalizeDouble(Ask-OrderOpenPrice(),0)*Poin;
       double Long_stopcal=NormalizeDouble(Ask,Digits)-(stop*Poin);
       double Long_stoptrade=OrderStopLoss();
     
       if(Long_profit<=start)
        continue;
       if(Long_stopcal<=Long_stoptrade)
        continue;
     
       if(Long_profit>start)
     
       if(Long_stoptrade==0||(Long_stoptrade!=0 && Long_stopcal>Long_stoptrade))
      {
          OrderModify(OrderTicket(),OrderOpenPrice(),Long_stopcal,OrderTakeProfit(),0,Blue);
          Print( "BUY Order trailstop moved : ", OrderStopLoss());
      }
      }
     
      if(OrderType()==OP_SELL)
      {
       //double Short_profit=NormalizeDouble(NormalizeDouble(OrderOpenPrice(),Digits)
                   //-NormalizeDouble(Bid,Digits)/Poin,0);
       double Short_profit=NormalizeDouble((OrderOpenPrice()-Bid)/Poin,0);
       //double Short_profit=NormalizeDouble(OrderOpenPrice()-Bid,0)*Poin;
       double Short_stopcal=NormalizeDouble(Bid,Digits)+(stop*Poin);
       double Short_stoptrade=OrderStopLoss();
     
       if(Short_profit<=start)
        continue;
     
       if(Short_stopcal>=Short_stoptrade)
        continue;
     
       if(Short_profit>start)
       if(Short_stoptrade==0||(Short_stoptrade!=0 && Short_stopcal<Short_stoptrade))
      {
           OrderModify(OrderTicket(),OrderOpenPrice(),Short_stopcal,OrderTakeProfit(),0,Red);
           Print( "SELL Order trailstop moved : ", OrderStopLoss());
      }
      }
     
     }
    }
    }
    //+------------------------------------------------------------------+
    //| calculating orders stoploss                                   |
    //+------------------------------------------------------------------+
     
    double StopLong(double price,int stop)
    {
     if(stop==0)
      return(0);
     else
      return(price-(stop*Poin));
    }
    //+---------------------------------
    double StopShrt(double price,int stop)
    {
     if(stop==0)
      return(0);
     else
      return(price+(stop*Poin));
    }
    //+------------------------------------------------------------------+
    //| calculating orders takeprofit                                   |
    //+------------------------------------------------------------------+
     
    double TakeLong(double price,int take)
    {
     if(take==0)
      return(0);
     else
      return(price+(take*Poin));
    }
    //+--------------------------------
    double TakeShrt(double price,int take)
    {
     if(take==0)
      return(0);
     else
      return(price-(take*Poin));
    }
     
    //+------------------------------------------------------------------+
    //| closing orders                                   |
    //+------------------------------------------------------------------+
    void CloseLongs()
    {
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(OrderType()==OP_BUY)
       OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,SkyBlue);
     }
    }
    //---------------------------
    void CloseShorts()
    {
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
      if(OrderType()==OP_SELL)
       OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Orange);
     }
    }
    //+------------------------------------------------------------------+
    //| counting open orders                                   |
    //+------------------------------------------------------------------+
    int CountLongs()
    {
     int count=0;
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
     
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(OrderType()==OP_BUY)
       count++;
     }
     return(count);
    }
    //--------------------------------
    int CountShorts()
    {
     int count=0;
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
     
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(OrderType()==OP_SELL)
       count++;
     }
     return(count);
    }
    //+------------------------------------------------------------------+
    آخر تعديل بواسطة ساق الجواء ، 23-04-2009 الساعة 10:45 PM

  3. #3
    الصورة الرمزية alshakatan
    alshakatan غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Mar 2007
    الإقامة
    المملكة العربية السعودية
    المشاركات
    439

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    اقتباس المشاركة الأصلية كتبت بواسطة ساق الجواء مشاهدة المشاركة
    هناك عدة طرق وما أستخدمه منها شخصيا وقد لا تكون الطريقة الأفضل كما يلي:

    أضف المتحول العام التالي (قبل وظائف int و deint و start )

    كود:
    double Poin; 
    أضف الكود التالي ضمن وظيفة int . وإن لم تكن الوظيفة موجودة استحدثها.

    كود:
    if (Point == 0.00001) Poin = 0.0001; //6 digits
    else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)
    else Poin = Point; //Normal 
    استبدل أي كلمة Point في بقية كودك بكلمة Poin . ولا تبدلها في الكود المذكور أعلاه.

    اضغط زر كومبايل طبعا.

    مثال تطبيقي:


    كود:
    //+------------------------------------------------------------------+
    //|                                         abdullah_st.mq4|
    //|                                                                  |
    //+------------------------------------------------------------------+
    #property copyright "abdullah_st"
    #property link      "None"
    //-------------------------------
    #include <stdlib.mqh>
    #include <stderror.mqh>
    //-------------------------------
    extern int Slippage=3;
    extern int MagicNumber = 23215650;
    extern int TimeFrame = 0;// Optimize per currency pair. current=0 , M1=1, M5=5, M15=15,
    // M30=30, H1=60, H4=240, Daily=1440
    //-------------------------------
    extern bool MM=true;//Select true for automatic money management
    extern int RiskPercent=1;//Update per your desired risk
    extern double Lots=0.1;//Optimize per account balance
    extern int MaxTrades=1;
    //----------------------
    extern int StopLoss=25;         //Optimize per currency pair and timeframe
    extern int TakeProfit = 100;       //Optimize per currency pair and timeframe
    //--------------------------------
    extern bool TrailingAlls = true;
    extern int Trail = 25;            //Optimize per currency pair and timeframe
    extern int TrailStart = 5;       //Optimize per currencypair and timeframe
    //----------------------
    extern bool BreakEven = true;
    extern int  BreakEvenTrigger = 25;
    //------------------ 
    extern int TTFbars=15;//15=default number of bars for computation
    extern int TopLine=50;
    extern int BottomLine=-50;
    extern int t3_period=5;
    extern double b=0.7;
    //---------------- 
    double Poin; // global variable declaration to fix the 6 Digit Forex Quotes
    //issue for MetaTrader Expert Advisors
    string EA_Name = "abdullah_st";
    bool AlertOn = true;
    datetime timeprev=0;//Working only after a new candle.
    //+------------------------------------------------------------------+
    //| expert initialization function                                   |
    //+------------------------------------------------------------------+
    int init()
    {
     
    //Initialization to Check for unconventional Point digits number
    if (Point == 0.00001) Poin = 0.0001; //6 digits
    else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)
    else Poin = Point; //Normal for 5 & 3 Digit Forex Quotes
     return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    int deinit()
    {
     return(0);
    }
    //+------------------------------------------------------------------+
    //|  Money Mangement and Lot Optimization                                  |
    //+------------------------------------------------------------------+
    double LotsOptimized()
      {
       double lot=Lots;
    //------ get broker's min/max
       double MinLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MINLOT)),2);
       double MaxLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MAXLOT)),2);
    //------ automatically select lot size per MM
       if (MM) lot=NormalizeDouble(MathFloor(AccountFreeMargin()*RiskPercent/100)/100,1);
    //------ make lots automatically per broker's min/max
       if (lot < MinLots)
       lot=MinLots;
       if (lot > MaxLots)
       lot=MaxLots;   
       return(lot);
      } 
     
    //+------------------------------------------------------------------+
    //| expert start function                                            |
    //+------------------------------------------------------------------+
    int start()
    {
    //+------------------------------------------------------------------+
    //| Function calls                                            |
    //+------------------------------------------------------------------+
       if (TrailingAlls) Trailingalls(TrailStart, Trail); 
    //------------------------------------
       if (BreakEven)    Breakeven();
    //------------------------------------------------------------------+
    //| Working only at a new candle rather than at every tick                                            |
    //+------------------------------------------------------------------+
       if(timeprev==Time[0])//Time[0] is time of the cuurent bar
       return(0);
       timeprev=Time[0];
       //This means instead of working (ie moving TSL) after every tick, work only after
       //a new candle.
       //it makes testing faster and test profit results higher.
       //It means you can use your code only once for each bar, usually first tick.
       //Any other tick code doesn't work. Sometimes it is very usefull.
       //Any action in start function afer this code will be performed once within the Bars
       //regardless of the time you specify
    //+------------------------------------------------------------------+
    //| indicators                                  |
    //+------------------------------------------------------------------+
     double cMainBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/0,/*shift*/1);
     
     double cSignalBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/1,/*shift*/1);  
     
     double pMainBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/0,/*shift*/2);
     
     double pSignalBuffer = iCustom(NULL,TimeFrame,"ttf",
     TTFbars, TopLine, BottomLine, t3_period, b,
     /*number of the data buffer*/1,/*shift*/2);  
    //+------------------------------------------------------------------+
    //| implementing exit signals                                  |
    //+------------------------------------------------------------------+
    //------------- Closing Buy --------------------
          if(cMainBuffer>cSignalBuffer)
          if(pMainBuffer<pSignalBuffer)
          if(CountLongs()>0)
          {
          CloseLongs();
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to SHORT. BUY order has been closed");
          AlertOn = false;
          }
          }
          }
     
    //------------- Closing Sell --------------------
     
          if(cMainBuffer<cSignalBuffer)
          if(pMainBuffer>pSignalBuffer)
          if(CountShorts()>0)
          {
          CloseShorts();
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to LONG. SELL order has been closed");
          AlertOn = false;
          }
          }
          }
    //+------------------------------------------------------------------+
    //| implementing entry signals                                  |
    //+------------------------------------------------------------------+
    //------------- Placing Buy --------------------
     
          if(cMainBuffer>cSignalBuffer)
          if(pMainBuffer<pSignalBuffer)
          if(CountLongs()<1)
          {
          OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,Slippage,
          StopLong(Bid,StopLoss),TakeLong(Ask,TakeProfit),EA_Name,MagicNumber,0,Blue);
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to LONG. BUY order has been placed");
          AlertOn = false;
          }
          }
          }
    //------------- Placing Sell --------------------
     
          if(cMainBuffer<cSignalBuffer)
          if(pMainBuffer>pSignalBuffer)
          if(CountShorts()<1)
          {
          OrderSend(Symbol(),OP_SELL, LotsOptimized(),Bid,Slippage,
          StopShrt(Ask,StopLoss),TakeShrt(Bid,TakeProfit),EA_Name,MagicNumber,0,Red);
          {
          if (AlertOn)
          {
          Alert( " "+Symbol()+" M"+Period()+": Signal to SHORT. SELL order has been placed");
          AlertOn = false;
          }
          }
          }
     
    //----------------------------
     
     return(0);
     } //End of Start function
    //+------------------------------------------------------------------+
    //| calculating orders breakeven                                   |
    //+------------------------------------------------------------------+
     
    void Breakeven()
       {
       int totalorders = OrdersTotal();
       for(int i=totalorders-1;i>=0;i--)
       {
     
       if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
       continue;
       if(OrderSymbol()!=Symbol())
       continue;
     
       if(OrderMagicNumber()!=MagicNumber)
       continue;
     
       if(BreakEven== false)
       continue;   
     
       if(BreakEvenTrigger == 0)
       continue;   
     
       if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     
       if(OrderSymbol()==Symbol())
     
       if(OrderMagicNumber()==MagicNumber)
       if(BreakEven== true)
     
       if(BreakEvenTrigger > 0)
       {   
     
       if(OrderType() == OP_BUY)
       {
       if(Ask<OrderOpenPrice())
       continue;
       if(OrderStopLoss()>=OrderOpenPrice()) 
       continue;
     
       if((NormalizeDouble(Ask,Digits)-NormalizeDouble(OrderOpenPrice(),Digits))<=(BreakEvenTrigger*Poin))
       continue;
       if(Ask>OrderOpenPrice())
       if(OrderStopLoss()<OrderOpenPrice() || OrderStopLoss()==0) 
       if((NormalizeDouble(Ask,Digits)-NormalizeDouble(OrderOpenPrice(),Digits))>(BreakEvenTrigger*Poin))
       { 
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+3*Poin,OrderTakeProfit(),0,Green);
       Print( "BUY Order moved to breakeven : ", OrderStopLoss());
       }
       }
     
       if(OrderType() == OP_SELL)
       {
       if(Bid>OrderOpenPrice())
       continue;
       if(OrderStopLoss()<=OrderOpenPrice()) 
       continue;
     
       if((NormalizeDouble(OrderOpenPrice(),Digits)-NormalizeDouble(Bid,Digits))<=(BreakEvenTrigger*Poin))
       continue;
       if(Bid<OrderOpenPrice())   
     
       if(OrderStopLoss()>OrderOpenPrice() || OrderStopLoss()==0) 
     
       if((NormalizeDouble(OrderOpenPrice(),Digits)-NormalizeDouble(Bid,Digits))>(BreakEvenTrigger*Poin))
       { 
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-3*Poin,OrderTakeProfit(),0,Green);
       Print( "SELL Order moved to breakeven : ", OrderStopLoss());
       }
       }
       }
       }
       return;
       }
    //+------------------------------------------------------------------+
    //| modifying orders trailing stop                                   |
    //+------------------------------------------------------------------+
     
    void Trailingalls(int start,int stop)
    {
     
     if(stop==0)
      return;
     
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
       continue;
      if(OrderSymbol()!=Symbol())
       continue;
     
      if(OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(TrailingAlls== false)
       continue;   
      if(start==0)
       continue;
      if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
     
      if(OrderSymbol()==Symbol())
     
      if(OrderMagicNumber()==MagicNumber)
     
      if(TrailingAlls== true)
     
      if(start>0)
      {
      if(OrderType()==OP_BUY)
      {
       //double Long_profit=NormalizeDouble(NormalizeDouble(Ask,Digits)
                   //-NormalizeDouble(OrderOpenPrice(),Digits)/Poin,0);
       double Long_profit=NormalizeDouble((Ask-OrderOpenPrice())/Poin,0);
       //double Long_profit=NormalizeDouble(Ask-OrderOpenPrice(),0)*Poin;
       double Long_stopcal=NormalizeDouble(Ask,Digits)-(stop*Poin);
       double Long_stoptrade=OrderStopLoss();
     
       if(Long_profit<=start)
        continue;
       if(Long_stopcal<=Long_stoptrade)
        continue;
     
       if(Long_profit>start)
     
       if(Long_stoptrade==0||(Long_stoptrade!=0 && Long_stopcal>Long_stoptrade))
      {
          OrderModify(OrderTicket(),OrderOpenPrice(),Long_stopcal,OrderTakeProfit(),0,Blue);
          Print( "BUY Order trailstop moved : ", OrderStopLoss());
      }
      }
     
      if(OrderType()==OP_SELL)
      {
       //double Short_profit=NormalizeDouble(NormalizeDouble(OrderOpenPrice(),Digits)
                   //-NormalizeDouble(Bid,Digits)/Poin,0);
       double Short_profit=NormalizeDouble((OrderOpenPrice()-Bid)/Poin,0);
       //double Short_profit=NormalizeDouble(OrderOpenPrice()-Bid,0)*Poin;
       double Short_stopcal=NormalizeDouble(Bid,Digits)+(stop*Poin);
       double Short_stoptrade=OrderStopLoss();
     
       if(Short_profit<=start)
        continue;
     
       if(Short_stopcal>=Short_stoptrade)
        continue;
     
       if(Short_profit>start)
       if(Short_stoptrade==0||(Short_stoptrade!=0 && Short_stopcal<Short_stoptrade))
      {
           OrderModify(OrderTicket(),OrderOpenPrice(),Short_stopcal,OrderTakeProfit(),0,Red);
           Print( "SELL Order trailstop moved : ", OrderStopLoss());
      }
      }
     
     }
    }
    }
    //+------------------------------------------------------------------+
    //| calculating orders stoploss                                   |
    //+------------------------------------------------------------------+
     
    double StopLong(double price,int stop)
    {
     if(stop==0)
      return(0);
     else
      return(price-(stop*Poin));
    }
    //+---------------------------------
    double StopShrt(double price,int stop)
    {
     if(stop==0)
      return(0);
     else
      return(price+(stop*Poin));
    }
    //+------------------------------------------------------------------+
    //| calculating orders takeprofit                                   |
    //+------------------------------------------------------------------+
     
    double TakeLong(double price,int take)
    {
     if(take==0)
      return(0);
     else
      return(price+(take*Poin));
    }
    //+--------------------------------
    double TakeShrt(double price,int take)
    {
     if(take==0)
      return(0);
     else
      return(price-(take*Poin));
    }
     
    //+------------------------------------------------------------------+
    //| closing orders                                   |
    //+------------------------------------------------------------------+
    void CloseLongs()
    {
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(OrderType()==OP_BUY)
       OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,SkyBlue);
     }
    }
    //---------------------------
    void CloseShorts()
    {
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
      if(OrderType()==OP_SELL)
       OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Orange);
     }
    }
    //+------------------------------------------------------------------+
    //| counting open orders                                   |
    //+------------------------------------------------------------------+
    int CountLongs()
    {
     int count=0;
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
     
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(OrderType()==OP_BUY)
       count++;
     }
     return(count);
    }
    //--------------------------------
    int CountShorts()
    {
     int count=0;
     int trade;
     for(trade=OrdersTotal()-1;trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
     
      if(OrderSymbol()!=Symbol()|| OrderMagicNumber()!=MagicNumber)
       continue;
     
      if(OrderType()==OP_SELL)
       count++;
     }
     return(count);
    }
    //+------------------------------------------------------------------+

    أولا أبغ أشكرك حبيب الكل على مجهوداتك
    و ثانيا برضه أشكرك على الأكواد اللي حأجربها

    زي ما إنتم عارفين إنهم أضافوا رقم عشري للأسعار مثل 98.10 إلى 98.100 أو 0.9999 إلى 0.99990
    فما هو الكود لإسترجاع الرقم المكون من ثلاث أرقام عشرية إلى رقمين عشريين
    ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~~ ~~5~~~ ~~~~ ~~~ ~~4 أرقام

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

  4. #4
    الصورة الرمزية ساق الجواء
    ساق الجواء غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Dec 2006
    الإقامة
    أنا من نجد ويكفيني هواها *** ويبري علتي شربي لماها
    المشاركات
    592

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    اقتباس المشاركة الأصلية كتبت بواسطة alshakatan مشاهدة المشاركة

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

  5. #5
    الصورة الرمزية alshakatan
    alshakatan غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Mar 2007
    الإقامة
    المملكة العربية السعودية
    المشاركات
    439

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

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

  6. #6
    الصورة الرمزية صانع قرار
    صانع قرار غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Jan 2008
    المشاركات
    106

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    اقتباس المشاركة الأصلية كتبت بواسطة alshakatan مشاهدة المشاركة

    حصلت حل مؤقت للمشكلة اللي واجهتها بخصوص التيك بروفت , إنه أضيف صفر . يعني لو أبغ أحط 50 أخليها 500 و سو فار ماشي الحال

    اسمحوا لي بهذه المشاركة البسيطة.

    بالنسبة للتعامل مع TakeProfit او StopLoss او اي متغيير فيه عدد النقاط، فهناك طريقة اخرى.

    وهي باستختدام المتغيير المعرف مسبقاً Digits، واللذي يعيد لك قيمة عدد النقاط العشرية للزوج.

    مثلاً، باضافة الكود التالي بعد start فوراً، وابقاء باقي الكود كما هو عليه، سيتعامل الاكسبيرت مع اي حالة تلقائياً.

    كود:
    int start()
    { 
       if (Digits==3 || Digits==5) {
          TakeProfit=TakeProfit*10;
          StopLoss=StopLoss*10;
          TrailingStop=TrailingStop*10;
            او اي متغييرات فيها عدد نقاط
       }
       .
       .
       .

  7. #7
    الصورة الرمزية ساق الجواء
    ساق الجواء غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Dec 2006
    الإقامة
    أنا من نجد ويكفيني هواها *** ويبري علتي شربي لماها
    المشاركات
    592

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    اقتباس المشاركة الأصلية كتبت بواسطة صانع قرار مشاهدة المشاركة
    اسمحوا لي بهذه المشاركة البسيطة.

    بالنسبة للتعامل مع TakeProfit او StopLoss او اي متغيير فيه عدد النقاط، فهناك طريقة اخرى.

    وهي باستختدام المتغيير المعرف مسبقاً Digits، واللذي يعيد لك قيمة عدد النقاط العشرية للزوج.

    مثلاً، باضافة الكود التالي بعد start فوراً، وابقاء باقي الكود كما هو عليه، سيتعامل الاكسبيرت مع اي حالة تلقائياً.

    كود:
    int start()
    { 
       if (Digits==3 || Digits==5) {
          TakeProfit=TakeProfit*10;
          StopLoss=StopLoss*10;
          TrailingStop=TrailingStop*10;
            او اي متغييرات فيها عدد نقاط
       }
       .
       .
       .

    شكرا على المشاركة وكما قلت في الأعلى "هناك أيضا عدة طرق أخرى وما أستخدمه منها شخصيا واعتدت عليه وقد لا تكون الطريقة الأفضل هي ما ذكرته في الأعلى" ولكل شيخ طريقته ولم أرد سرد الطرق الأخرى لأني لم أمارسها ولئلا أسبب تشتتا للإخوان.

    أما أنت فبما أنك متقن لطريقتك فحسن أنك شاركت حتى يكون الإخوان بالخيار وحتى تجيب على تساؤلاتهم عن طريقتك إن أحبوا اتباعها.

  8. #8
    الصورة الرمزية alshakatan
    alshakatan غير متواجد حالياً عضو المتداول العربي
    تاريخ التسجيل
    Mar 2007
    الإقامة
    المملكة العربية السعودية
    المشاركات
    439

    افتراضي رد: كيف يمكن معالجة الرقم العشري الزايد في الأسعار

    اقتباس المشاركة الأصلية كتبت بواسطة صانع قرار مشاهدة المشاركة
    اسمحوا لي بهذه المشاركة البسيطة.

    بالنسبة للتعامل مع TakeProfit او StopLoss او اي متغيير فيه عدد النقاط، فهناك طريقة اخرى.

    وهي باستختدام المتغيير المعرف مسبقاً Digits، واللذي يعيد لك قيمة عدد النقاط العشرية للزوج.

    مثلاً، باضافة الكود التالي بعد start فوراً، وابقاء باقي الكود كما هو عليه، سيتعامل الاكسبيرت مع اي حالة تلقائياً.

    كود:
    int start()
    { 
       if (Digits==3 || Digits==5) {
          TakeProfit=TakeProfit*10;
          StopLoss=StopLoss*10;
          TrailingStop=TrailingStop*10;
            او اي متغييرات فيها عدد نقاط
       }
       .
       .
       .
    شكرا على اكود و الشرح
    الله يديمكم علينا

المواضيع المتشابهه

  1. مشاركات: 7
    آخر مشاركة: 21-07-2010, 06:30 PM
  2. بوش: معالجة الأزمة المالية مهمة عالمية
    By التحليلات والأخبار in forum سوق تداول العملات الأجنبية والسلع والنفط والمعادن
    مشاركات: 1
    آخر مشاركة: 12-10-2008, 06:52 AM
  3. توصية الصاحي
    By صاحب سمو المشاعر in forum توقعات وتوصيات سوق العملات
    مشاركات: 3
    آخر مشاركة: 13-03-2008, 09:41 AM
  4. معالجة افشاء اسرار المنزل عند الاطفال ....
    By zid in forum استراحة اعضاء المتداول العربي
    مشاركات: 1
    آخر مشاركة: 09-06-2007, 08:42 AM
  5. التفاؤل الزايد عن حده ... هينقلب لضده ...
    By Dr.GM in forum سوق تداول العملات الأجنبية والسلع والنفط والمعادن
    مشاركات: 2
    آخر مشاركة: 27-11-2006, 01:40 AM

الاوسمة لهذا الموضوع


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17