Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools
Zurück   Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools > Metatrader 4 > Programmierung MQL4
Startseite Registrieren Hilfe Community Kalender Heutige Beiträge Suchen

Programmierung MQL4 Hier gehts rund ums Programmieren in MQL4.

Login
Benutzername:
Kennwort:


Statistik
Themen: 4978
Beiträge: 43287
Benutzer: 7.223
Aktive Benutzer: 74
Links: 84
Wir begrüßen unseren neuesten Benutzer: Sundaytrader
Mit 2.475 Benutzern waren die meisten Benutzer gleichzeitig online (16.01.20 um 22:38).
Neue Benutzer:
vor einer Woche
- Sundaytrad...
vor einer Woche
- TS_6
vor einer Woche
- Mane
vor 3 Wochen
- AlbertZiz
vor 3 Wochen
- michak

Onlineuser
'Wer ist online' anzeigen Benutzer: 0
Gäste: 429
Gesamt: 429
Team: 0
Team:  
Benutzer:  
Freunde anzeigen

Empfehlungen

Antwort
 
Themen-Optionen Thema durchsuchen Ansicht
  #1 (permalink)  
Alt 01.03.24
Neues Mitglied
 
Registriert seit: Jul 2019
Beiträge: 14
Alex60 befindet sich auf einem aufstrebenden Ast
Standard Fehlermeldung 4051

Hallo,

ich bekomme beim Markt von MQL5 bei der Validation meines EA´s eine Fehlermeldung, das wäre diese:
invalid lots amount for OrderSend function
OrderSend error 4051

Der EA läuft aber einwandfrei. An was kann das liegen?
Code:
int ACCOUNT_NUMBER=0;// <----------------------------
//+------------------------------------------------------------------+
//|                                                Real Odin.mq4          |
//|                                      BullsBears-Trading Akademie |
//|                            bullsbears.trading.akademie@gmail.com |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//+--------------------------------- --------------------------------+
//+----- http://bullsbears-trading.de -------------------------------+
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//+----- Real Odin Expert Advisor ---------------------------------+
//+------------------------------------------------------------------+
//+----- http://bullsbears-trading.de -------------------------------+
//+------------------------------------------------------------------+

#property version   "1.0" 
#property copyright "BullsBearsTradingAkademie"
#property link      "bullsbears.trading.akademie@gmail.com"
#property strict
#define buy -2
#define sell 2

#include <stdlib.mqh>
#include <WinUser32.mqh>
#import "wininet.dll"
#define INTERNET_FLAG_PRAGMA_NOCACHE    0x00000100 // Forces the request to be resolved by the origin server, even if a cached copy exists on the proxy.
#define INTERNET_FLAG_NO_CACHE_WRITE    0x04000000 // Does not add the returned entity to the cache. 
#define INTERNET_FLAG_RELOAD            0x80000000 // Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int InternetOpenA(string sAgent, int lAccessType, string sProxyName="", string sProxyBypass="", int lFlags=0);
int InternetOpenUrlA(int hInternetSession, string sUrl, string sHeaders="", int lHeadersLength=0, int lFlags=0, int lContext=0);
int InternetReadFile(int hFile, string sBuffer, int lNumBytesToRead, int& lNumberOfBytesRead[]);
int InternetCloseHandle(int hInet);
#import

enum yn
  {
   n=0,//NO
   y=1 //YES
  };
//---- input parameters
extern string  separator_01="----  General  Settings  ----";
extern bool      use_daily_target=false;
extern double    daily_target=100;
extern bool      trade_in_fri=true;
extern int       magic=22;
extern double    start_lot=0.01;
extern double    range=25;
extern bool      rge_multiplier=false;
extern double    r_multiplier=1.5;
extern int       level=10;
extern string  separator_02="----  Lot & TP  Settings  ----";
extern bool      lot_multiplier=true;
extern double    l_multiplier=2.0;
extern double    increment=0.1;
extern bool      power_lots=true;
extern bool      tp_by_level=true;
extern double    tp_1=25;
extern double    tp_2=0;
extern bool      use_sl_and_tp=false;
extern double    sl_std=60;
extern double    tp_std=30;
extern double    tp_in_money=5.0;
extern bool      stealth_mode=true;
 string  separator_03="----  Hedge  Settings  ----";
 bool      hedge=true;
 int       h_level=3;
 int       h_top_level=100;
 double    h_tp=80;
 double    h_sl=25;
 double    b_even_set=10;
 double    h_offset=20;
 double    h_factor=1.05;
 bool      level_limit=false;
 extern string  separator_04="----  Indicator  Settings  ----";                                                                                                   
 extern bool      use_bb=true;
 extern int       bb_period=20;
 extern int       bb_deviation=2;
 extern int       bb_shift=0;
 extern bool      use_stoch=true;
 extern int       k=5;
 extern int       d=3;
 extern int       slowing=3;
 extern int       price_field=0;
 extern int       stoch_shift=0;
 extern int       lo_level=30;
 extern int       up_level=70;
 extern bool      use_rsi=true;
 extern int       rsi_period=12;
 extern int       rsi_shift=0;
 extern int       lower=30;
 extern int       upper=70;
 string  separator_00="----  RSI - Foward  Trend   ----";
 bool      forward_trend=false;
 int       rsi_period_1=30;
 int       rsi_shift_1=0;
 int       lower_min=35;
 int       lower_max=33;
 int       upper_min=65;
 int       upper_max=67;
 bool      use_velocity=true;
 int       fv_period=10;
 int       fv_offset=20;
 string  separator_05="----  RSI - Hedge  Entry   ----";
 bool      h_rsi_entry=true;
 int       rsi_period_2=14;
 int       rsi_shift_2=0;
 int       lower_2=25;
 int       upper_2=75;
 bool      h_velocity=false;
 bool      use_h_rsi=false;
 int       vel_period=13;
 int       vel_offset=50;
 string  separator_06="----  RSI - Hedge  Exit   ----";
 bool      h_rsi_exit=true;
 int       rsi_period_3=14;
 int       rsi_shift_3=0;
 int       lower_3=50;
 int       upper_3=50;
 double    sl_threshold=0;
 string  separator_07="----  RSI - TP  Override   ----";
 bool      tp_override=true;
 int       rsi_period_4=14;
 int       rsi_shift_4=0;
 int       lower_4=25;
 int       upper_4=75;
 string  separator_08="----  Additional  ----";
extern string  separator_09="----  Trading  Sessions  ----";
extern bool      use_trading_sessions=false;
extern bool      asian_session=true;  //  0:00 -  8:00 GMT
extern bool      euro_session=true;   //  6:00 - 16:00 GMT
extern bool      ny_session=true;     // 12:00 - 21:00 GMT
extern int       gmt_shift=1;
extern bool      daylight_savings=false;
extern string  separator_10="----  Asian  Daily  /  GMT  ----";
extern bool      asian_daily=true;
extern int       sun_asian_open=0, sun_asian_close=8;
extern int       mon_asian_open=0, mon_asian_close=8;
extern int       tue_asian_open=0, tue_asian_close=8;
extern int       wed_asian_open=0, wed_asian_close=8;
extern int       thu_asian_open=0, thu_asian_close=8;
extern int       fri_asian_open=0, fri_asian_close=8;
extern string  separator_11="----  European  Daily  /  GMT  ----";
extern bool      euro_daily=true;
extern int       sun_euro_open=6,  sun_euro_close=16;
extern int       mon_euro_open=6,  mon_euro_close=16;
extern int       tue_euro_open=6,  tue_euro_close=16;
extern int       wed_euro_open=6,  wed_euro_close=16;
extern int       thu_euro_open=6,  thu_euro_close=16;
extern int       fri_euro_open=6,  fri_euro_close=16;
extern string  separator_12="----  New  York  Daily  /  GMT  ----";
extern bool      ny_daily=true;
extern int       sun_ny_open=12,   sun_ny_close=21;
extern int       mon_ny_open=12,   mon_ny_close=21;
extern int       tue_ny_open=12,   tue_ny_close=21;
extern int       wed_ny_open=12,   wed_ny_close=21;
extern int       thu_ny_open=12,   thu_ny_close=21;
extern int       fri_ny_open=12,   fri_ny_close=21;
 string BreakEven            = "--------------------< Break Even >--------------------";//Break Even Settings ............................................................................................................
 bool   UseBreakEven         = 0;      // Use Break Even
 double BreakEvenStart       = 10;     // Break Even Trigger
 double BreakEvenProfit      = 1;      // Break Even Profit
extern string TrailingStopLoss     = "--------------------< Trailing Stop >--------------------";//Trailing Stop Settings ............................................................................................................
input bool   UseTrailingStop      = 0;      // Use Trailing
input double TrailingStart        = 10;     // Trailing Start
input double TrailingStop         = 7;      // Trailing Stop
input string News_Filter           = "--------------------< News Filter >--------------------";//*
input bool   NewsFilter            = 0;      // Use News Filter
input int    MinBefore             = 15;     // Minutes Before News
input int    MinAfter              = 15;     // Minutes After News 
input bool 	 IncludeHigh 		     = true;   // High Impact News
input bool 	 IncludeMedium 		  = true;   // Medium Impact News
input bool 	 IncludeLow 			  = false;  // Low Impact News    
input bool 	 IncludeSpeaks 		  = true; 	 
input bool   AutoReportToCurrSym   = false;  // Auto Report to current Symbol
input bool	 ReportAllForUSD	     = true;
input bool   ReportAllForEUR       = true;
input bool   ReportAllForGBP       = true; 
input bool   ReportAllForNZD       = true;
input bool   ReportAllForJPY       = true;
input bool   ReportAllForAUD       = true;
input bool   ReportAllForCHF       = true;
input bool   ReportAllForCAD       = true;
input bool   ReportAllForCNY       = false;

input bool new_=false;//Fixed logic
input double max_percent_loss=5;//Max percent to stop

bool t_day[5];
datetime mtd_time,trail_sek;

double pt;
double minlot;
double stoplevel;
double std=0.1;
double rge;
double balance;
double bal_2=0;
double b_hedge;
double s_hedge;
double p_lot;
double pl_bal=0;
double st_lot;
double pl_factor;
double t_profit=0;
int prec=0;
int b_cnt;
int s_cnt;
int h_cnt;
int m;
int end_cycle;
bool e_cycle_set;
bool closeall;
datetime get_time;
bool h_b_e,EnableFileErrorLogging=0,NewsTime=0;
int PrevMinute=-1;
string NewsTimeComment="";
datetime tim;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   if(Digits==3 || Digits==5)
      pt=10*Point;
   else
      pt=Point;
   minlot   =   MarketInfo(Symbol(),MODE_MINLOT);
   stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
   if(start_lot<minlot)
      Print("lotsize is to small.");
   if(sl_std<stoplevel)
      Print("stoploss is to tight.");
   if(tp_std<stoplevel)
      Print("takeprofit is to tight.");
   if(minlot==0.01)
     {
      prec=2;
      std=10.0;
     }
   if(minlot==0.1)
     {
      prec=1;
      std=1.0;
     }
//----
   range*=pt;
   rge=range;
   sl_std*=pt;
   tp_std*=pt;
   tp_1*=pt;
   tp_2*=pt;
   h_tp*=pt;
   h_sl*=pt;
   h_offset*=pt;
   b_even_set*=pt;
   sl_threshold*=pt;
   if(h_velocity)
      h_level=1;
   if(hedge && level_limit)
      level=h_level;
//----
   if(use_sl_and_tp)
      stealth_mode=false;
//----
   if(!GlobalVariableGet("bal_2"+Symbol()+(string)magic))
      GlobalVariableSet("bal_2"+Symbol()+(string)magic,0);
   if(GlobalVariableGet("bal_2"+Symbol()+(string)magic)>0)
      bal_2=GlobalVariableGet("bal_2"+Symbol()+(string)magic);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+-------------------------------------------------------------------+
//| pofit                                                             |
//+-------------------------------------------------------------------+
double pofit()
  {
   double profit=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
           {
            profit+=OrderProfit()+OrderSwap();
           }
        }
     }
   return(profit);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   if(ACCOUNT_NUMBER>0 && ACCOUNT_NUMBER!=AccountNumber())
     {
      Comment("Wrong Account number!");
      return 0;
     }
   double cur_p=pofit();
   double prec_p=0;
   if(AccountBalance()>0)
      prec_p=NormalizeDouble(((AccountBalance()+cur_p)*100/AccountBalance())-100,2);

   if(prec_p<0)
     {
      if(MathAbs(prec_p) >= MathAbs(max_percent_loss))
        {
         Comment("EA NOT WORKING BY ACCOUNT MAX PERCENT LOSS");
         return 0;
        }
     }
//---
   News();
   BreakEvens();
   TrailingStops();
//----
   if(use_daily_target && dailyprofit()>=daily_target)
     {
      Comment("\ndaily target achieved.");
      return(0);
     }
   if(!trade_in_fri && DayOfWeek()==5 && T()==0)
     {
      Comment("\nstop trading in Friday.");
      return(0);
     }
//+------------------------------------------------------------------+
//| start of ecTrage mod - ramble_32@yahoo.com                       |
//+------------------------------------------------------------------+
   h_cnt=0;
   b_cnt=0;
   s_cnt=0;
   double lot2;
   for(int i=0; i<OrdersTotal(); i++) // additional
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic)
         continue;
      //----
      if(OT2()=="H")
        {
         h_cnt++;
        }
      else
        {
         if(cmd()<2)
            if(cmd()==0)
               b_cnt++;
         if(cmd()==1)
            s_cnt++;
        }
     }
   if(h_cnt==0)
      h_b_e=false;
//+------------------------------------------------------------------+
   double AE=AccountEquity();
   if(power_lots)
     {
      if(pl_bal==0)
        {
         pl_bal=AE;
         st_lot=start_lot;
        }
      if(T()==0)
        {
         pl_factor=AE/pl_bal;
         st_lot=start_lot*pl_factor;
        }
     }
//+------------------------------------------------------------------+
   if(lot_multiplier)
      lot2=NormalizeDouble(st_lot*MathPow(l_multiplier,T()),prec);
   else
      lot2=NormalizeDouble(st_lot+(increment*T()),          prec);
   if(rge_multiplier)
      rge=range*MathPow(r_multiplier,T());
//+------------------------------------------------------------------+
   int o_send=2;
   if(use_trading_sessions)
     {
      o_send=order_send();
     }
   else
     {
      if(signal()==buy)
         o_send=0;
      if(signal()==sell)
         o_send=1;
     }
//----
   if(e_cycle_set)
      end_cycle++;
   if(end_cycle>1)
     {
      e_cycle_set=false;
      end_cycle=0;
     }
   if(T()==0)
     {
      closeall=false;
      get_time=TimeCurrent();
     }
//----

   if((IsTesting() || (IsExpertEnabled() && IsTradeAllowed())) && !NewsTime && !closeall && end_cycle==0 && h_cnt==0 && (!new_ || tim!=Time[0])) // additional
     {
      tim=Time[0];
      if(T()<level)
        {
         if((o_send==0 || (b_cnt>0 && Ask<=LOOP()-rge))&& allow_open_order(0))                          // BUY
           {
            if(hedge && T()==0)
               s_hedge=Bid-rge;
            bool os = OrderSend(Symbol(),0,lot2,Ask,20,0,0,"L"+((string)b_cnt+(string)1),magic,0,Blue);
           }
         if((o_send==1 || (s_cnt>0 && Bid>=LOOP()+rge)) && allow_open_order(1))                         // SELL
           {
            if(hedge && T()==0)
               b_hedge=Ask+rge;
            bool os = OrderSend(Symbol(),1,lot2,Bid,20,0,0,"L"+((string)s_cnt+(string)1),magic,0,Red);
           }
        }
      //----
      if(hedges() && h_rsi_entry)                                               // HEDGE
        {
         if(h_velocity)
           {
            if(s_cnt>0 && Ask>=b_hedge && ((!use_h_rsi && h_velo()>vel_offset)
                                           || (use_h_rsi && h_entry()>upper_2)) && allow_open_order(0))
               bool os = OrderSend(Symbol(),0,h_lot(),Ask,20,0,0,"H"+((string)s_cnt+(string)1),magic,0,Blue);
            //----
            if(b_cnt>0 && Bid<=s_hedge && ((!use_h_rsi && h_velo()<-vel_offset)
                                           || (use_h_rsi && h_entry()<lower_2)) && allow_open_order(1))
               bool os = OrderSend(Symbol(),1,h_lot(),Bid,20,0,0,"H"+((string)b_cnt+(string)1),magic,0,Red);
           }
         if(!h_velocity)
           {
            if(s_cnt>0 && Ask>=LOOP() && Ask<=LOOP()+h_offset && h_entry()>upper_2 && allow_open_order(0))
               bool os = OrderSend(Symbol(),0,h_lot(), Ask,20,0,0,"H"+((string)s_cnt+(string)1),magic,0,Blue);
            //----
            if(b_cnt>0 && Bid<=LOOP() && Bid>=LOOP()-h_offset && h_entry()<lower_2 && allow_open_order(1))
               bool os = OrderSend(Symbol(),1,h_lot(), Bid,20,0,0,"H"+((string)b_cnt+(string)1),magic,0,Red);
           }
        }
     }
//+------------------------------------------------------------------+
   double OOP=0, OSL=0, OTP=0, sl_0=sl_std, tp_0=tp_std, h2_tp=h_tp;
   for(int i=0; i<OrdersTotal(); i++) // additional
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
         continue;
      OOP=OrderOpenPrice();
      if(OT2()=="H")
        {
         if(cmd()==0)
           {

            if(tp_override && h_tp_over()>upper_4)
               h2_tp=0;
            OSL=OOP()-h_sl;
            if(h_sl==0)
               OSL=0;
            OTP=OOP()+h2_tp;
            if(h2_tp==0)
               OTP=0;
            if(Ask>=OOP()+b_even_set)
               h_b_e=true;
            if(h_b_e)
               OSL=OOP()+(2*pt);
            double stop=MarketInfo(Symbol(),MODE_STOPLEVEL);
            if(OSL<Bid-stop*Point() && OTP>Ask+stop*Point() && (NormalizeDouble(OSL,_Digits)!=OrderStopLoss() || NormalizeDouble(OTP,_Digits)!=OrderTakeProfit()))
              {
               bool om = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OSL,_Digits),NormalizeDouble(OTP,_Digits),0,CLR_NONE);
               if(!om)
                  Print("er1");
              }
           }
         if(cmd()==1)
           {
            if(tp_override && h_tp_over()<lower_4)
               h2_tp=0;
            OSL=OOP()+h_sl;
            if(h_sl==0)
               OSL=0;
            OTP=OOP()-h2_tp;
            if(h2_tp==0)
               OTP=0;
            if(Bid<=OOP()-b_even_set)
               h_b_e=true;
            if(h_b_e)
               OSL=OOP()-(2*pt);
            double stop=MarketInfo(Symbol(),MODE_STOPLEVEL);
            if(OTP<Bid-stop*Point() && OSL>Ask+stop*Point() && (NormalizeDouble(OSL,_Digits)!=OrderStopLoss() || NormalizeDouble(OTP,_Digits)!=OrderTakeProfit()))
              {
               bool om = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OSL,_Digits),NormalizeDouble(OTP,_Digits),0,CLR_NONE);
               if(!om)
                  Print("er2");
              }
           }
         //----
         if(h_rsi_exit)
           {
            if((cmd()==0 && Ask>OOP()-sl_threshold && h_exit()<lower_3)
               || (cmd()==1 && Bid<OOP()+sl_threshold && h_exit()>upper_3))
               bool oc = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
           }
        }
     }
//+------------------------------------------------------------------+
   double deviate=0, h_dev=0;
   sl_0=sl_std;
   tp_0=tp_std;
   for(int i=0; i<OrdersTotal(); i++) // additional
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
         continue;
      OOP=OrderOpenPrice();
      OTP=OrderOpenPrice();
      if(LCT()==1)
        {
         if(cmd()==0 && Ask<=OOP())
            deviate=OOP()-Ask;
         if(cmd()==1 && Bid>=OOP())
            deviate=Bid-OOP();
        }
      if(OT2()=="H")
        {
         if(cmd()==0 &&Ask<=OOP())
            h_dev=OOP()-Ask;
         if(cmd()==1 &&Bid>=OOP())
            h_dev=Bid-OOP();
        }
      if(tp_by_level)
        {
         tp_0=tp_1;
         if(LCT()>1)
            tp_0=tp_2;
        }
      if((!stealth_mode || tp_by_level) && OT2()!="H")
        {
         if(cmd()==1)
           {
            sl_0*=-1;
            tp_0*=-1;
           }

         if(use_sl_and_tp)
            OSL=OOP-sl_0;
         OTP=OOP+tp_0;
         if(tp_0==0)
            OTP=0;
         if(sl_0==0)
            OSL=0;
         double stop=MarketInfo(Symbol(),MODE_STOPLEVEL);
         if((OrderTakeProfit()==0 && OTP > 0) || (OrderStopLoss()==0 && OSL > 0))
           {
            if(OrderType()==0 && (OTP==0 || OTP>Ask+stop*Point()) && (OSL==0 || OSL<Bid-stop*Point()))
              {
               bool om = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OSL,_Digits),NormalizeDouble(OTP,_Digits),0,clrNONE);
               if(!om)
                  Print("er3");
              }

            if(OrderType()==1 && (OTP==0 || OTP<Bid-stop*Point()) && (OSL==0 || OSL>Ask+stop*Point()))
              {
               bool om = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OSL,_Digits),NormalizeDouble(OTP,_Digits),0,clrNONE);
               if(!om)
                  Print("er4");
              }
           }
        }
     }
//+------------------------------------------------------------------+
//| end of ecTrage mod - ramble_32@yahoo.com                         |
//+------------------------------------------------------------------+
   if(use_sl_and_tp && T()>1)
     {
      int type=0;
      double s_l=0, t_p=0;
      for(int i=0; i<OrdersTotal(); i++)
        {
         bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
            continue;
         type=OrderType();
         s_l=OrderStopLoss();
         t_p=OrderTakeProfit();
        }
      //----
      for(int i=OrdersTotal()-1; i>=0; i--)
        {
         bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
            continue;
         if(OrderType()==type)
           {
            double stop=MarketInfo(Symbol(),MODE_STOPLEVEL);
            if(OrderStopLoss()!=s_l || OrderTakeProfit()!=t_p)
              {
               if(OrderType()==0 && s_l<Bid-stop*Point() && t_p>Ask+stop*Point())
                 {
                  bool om = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(s_l,_Digits),NormalizeDouble(t_p,_Digits),0,CLR_NONE);
                  if(!om)
                     Print("OrderModify error");
                 }

               if(OrderType()==1 && t_p<Bid-stop*Point() && s_l>Ask+stop*Point())
                 {
                  bool om = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(s_l,_Digits),NormalizeDouble(t_p,_Digits),0,CLR_NONE);
                  if(!om)
                     Print("OrderModify error");
                 }

              }
           }
        }
     }
//+------------------------------------------------------------------+
   double profit=0;
   for(int i=0; i<OrdersTotal(); i++)
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
         continue;
      profit+=OrderProfit();
     }
//+------------------------------------------------------------------+
   double h2_loss=0;
   balance=0;
   for(int i=0; i<OrdersHistoryTotal(); i++)
     {
      bool ost2 = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
         continue;
      balance+=OrderProfit();
     }
//----
   if(T()==0 || bal_2==0)
     {
      GlobalVariableSet("bal_2"+Symbol()+(string)magic,balance);
      bal_2=GlobalVariableGet("bal_2"+Symbol()+(string)magic);
     }
   double tp_m=tp_in_money*pl_factor, tp_m2=balance-bal_2+profit;
   if(tp_m2>=tp_m && profit>0)
     {
      closeall();
      closeall=true;
      e_cycle_set=true;
     }
//+------------------------------------------------------------------+
   string OT="--", h2_factor="0 %", v_dsp="N", trend="Counter", t_dsp=" / RSI";
   if(b_cnt>0)
      OT="B";
   if(s_cnt>0)
      OT="S";
   if(hedge)
      h2_factor=DoubleToStr(h_factor*100,0)+"%";
   if(h_velocity)
      v_dsp="Y";
   if(forward_trend)
      trend="Forward";
   if(use_velocity)
      t_dsp=" / V / "+(string)fv_period+" / "+(string)fv_offset;
   double h_lot=0, t_lot=h_lot()*(1/h_factor);
   if(h_cnt>0)
      h_lot=h_lot();
   if(t_profit==0 || balance+profit>t_profit)
      t_profit=balance+profit;
//----
   string line_1="Level = "+(string)T()+" / "+(string)level+" / "+OT+"  |  Equity = "+DoubleToStr(AE,2)+"  |  Profit = "+DoubleToStr(balance+profit,2)+" / "+DoubleToStr(t_profit,2)+"  |  Target = "+DoubleToStr(tp_m2,2)+" / "+DoubleToStr(tp_m,2)+"\n";
   string line_2="Hedge = "+h2_factor+" / "+(string)h_cnt+" / "+(string)h_level+"  |  H Lot = "+DoubleToStr(h_lot,2)+" / "+DoubleToStr(t_lot,2)+"  |  Spread = "+DoubleToStr((Ask-Bid)/pt,2)+"  |  Deviation = "+DoubleToStr(deviate/pt,0)+" / "+DoubleToStr(h_dev/pt,0)+"\n";
   string line_3="Trend = "+trend+t_dsp+"  |  Velocity = "+v_dsp+" / "+DoubleToStr(h_velo(),0)+" / "+(string)vel_offset;
//----
   Comment(line_1, line_2, line_3+"\nPercent current: "+DoubleToString(prec_p,2)+"%");
//----
   return(0);
  }
//+------------------------------------------------------------------+
double dailyprofit()
  {
   int day=Day();
   double res=0;
   for(int i=0; i<OrdersHistoryTotal(); i++)
     {
      bool ot5 = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic)
         continue;
      if(TimeDay(OrderOpenTime())==day)
         res+=OrderProfit();
     }
   return(res);
  }
//+------------------------------------------------------------------+
int T() // modified
  {
   int Ts=0;
   for(int i=0; i<OrdersTotal(); i++)
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic)
         continue;
      if(OT2()!="H")
         Ts++;
     }
   return(Ts);
  }
//+------------------------------------------------------------------+
double h_lot() // additional
  {
   double h_lots=0;
   for(int i=0; i<OrdersTotal(); i++)
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic)
         continue;
      if(OT2()!="H")
         h_lots+=OrderLots();
     }
   h_lots=NormalizeDouble(h_lots, prec);
   return(h_lots);
  }
//+------------------------------------------------------------------+
double LOOP() // additional
  {
   double LOOPs=0;
   int t_cnt=0;
   for(int i=0; i<OrdersTotal(); i++)
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1)
         continue;
      if(cmd()==0)
        {
         t_cnt++;
         if(t_cnt==1 || (t_cnt>1 && OOP()<LOOPs))
            LOOPs=OOP();
        }
      if(cmd()==1)
        {
         t_cnt++;
         if(t_cnt==1 || (t_cnt>1 && OOP()>LOOPs))
            LOOPs=OOP();
        }
     }
   return(LOOPs);
  }
//+------------------------------------------------------------------+
int cmd() // additional
  {
   int cmds=OrderType();
   return(cmds);
  }
double OOP() // additional
  {
   double OOPs=OrderOpenPrice();
   return(OOPs);
  }
string OT2() // additional
  {
   string OT2s=StringSubstr(OrderComment(),0,1);
   return(OT2s);
  }
int LCT()
  {
   int LCTs=StrToInteger(StringSubstr(OrderComment(),1,3));
   return(LCTs);
  }
bool hedges() // additional
  {
   bool hedge_2=false;
   if(hedge && T()>=h_level && T()<=h_top_level)
      hedge_2=true;
   return(hedge_2);
  }
//+------------------------------------------------------------------+
double h_entry() // additional
  {
   double rsi_1=0;
   if(hedges() && h_cnt==0)
     {
      if(h_rsi_entry)
         rsi_1=iRSI(Symbol(),0,rsi_period_2,PRICE_CLOSE,rsi_shift_2);
     }
   return(rsi_1);
  }
double h_exit() // additional
  {
   double rsi_2=0;
   if(hedges() && h_cnt>0)
     {
      if(h_rsi_exit)
         rsi_2=iRSI(Symbol(),0,rsi_period_3,PRICE_CLOSE,rsi_shift_3);
     }
   return(rsi_2);
  }
double h_tp_over() // additional
  {
   double rsi_3=0;
   if(hedges() && h_cnt>0)
     {
      if(tp_override)
         rsi_3=iRSI(Symbol(),0,rsi_period_4,PRICE_CLOSE,rsi_shift_4);
     }
   return(rsi_3);
  }
double h_velo()
  {
   double velo=0; // additional
   if(hedge && h_cnt==0)
     {
      if(h_rsi_entry && h_velocity)
         velo=iCustom(NULL,0,"J_TPO_Velocity",vel_period,0,0);
     }
   return(velo);
  }
//+------------------------------------------------------------------+
int order_send()
  {
   int o_sends=2;
   if(use_trading_sessions)
     {
      int total_shift=gmt_shift;
      if(daylight_savings)
         total_shift=gmt_shift+1;
      int asian_open=0+total_shift, asian_close=8 +total_shift;
      int euro_open=6 +total_shift, euro_close=16 +total_shift;
      int ny_open=12  +total_shift, ny_close=21   +total_shift;
      //----
      if(DayOfWeek()==0) // sunday
        {
         if(asian_daily)
           {
            asian_open=sun_asian_open;
            asian_close=sun_asian_close;
           }
         if(euro_daily)
           {
            euro_open=sun_euro_open;
            euro_close=sun_euro_close;
           }
         if(ny_daily)
           {
            ny_open=sun_ny_open;
            ny_close=sun_ny_close;
           }
         //---
         if(!t_day[0])
           {
            t_day[0]=true;
            mtd_time=TimeCurrent();
            t_day[5]=false;
           }
        }
      if(DayOfWeek()==1) // monday
        {
         if(asian_daily)
           {
            asian_open=mon_asian_open;
            asian_close=mon_asian_close;
           }
         if(euro_daily)
           {
            euro_open=mon_euro_open;
            euro_close=mon_euro_close;
           }
         if(ny_daily)
           {
            ny_open=mon_ny_open;
            ny_close=mon_ny_close;
           }
         //---
         if(!t_day[1])
           {
            t_day[1]=true;
            mtd_time=TimeCurrent();
            t_day[0]=false;
           }
        }
      if(DayOfWeek()==2) // tuesday
        {
         if(asian_daily)
           {
            asian_open=tue_asian_open;
            asian_close=tue_asian_close;
           }
         if(euro_daily)
           {
            euro_open=tue_euro_open;
            euro_close=tue_euro_close;
           }
         if(ny_daily)
           {
            ny_open=tue_ny_open;
            ny_close=tue_ny_close;
           }
         //---
         if(!t_day[2])
           {
            t_day[2]=true;
            mtd_time=TimeCurrent();
            t_day[1]=false;
           }
        }
      if(DayOfWeek()==3) // wednesday
        {
         if(asian_daily)
           {
            asian_open=wed_asian_open;
            asian_close=wed_asian_close;
           }
         if(euro_daily)
           {
            euro_open=wed_euro_open;
            euro_close=wed_euro_close;
           }
         if(ny_daily)
           {
            ny_open=wed_ny_open;
            ny_close=wed_ny_close;
           }
         //---
         if(!t_day[3])
           {
            t_day[3]=true;
            mtd_time=TimeCurrent();
            t_day[2]=false;
           }
        }
      if(DayOfWeek()==4) // thursday
        {
         if(asian_daily)
           {
            asian_open=thu_asian_open;
            asian_close=thu_asian_close;
           }
         if(euro_daily)
           {
            euro_open=thu_euro_open;
            euro_close=thu_euro_close;
           }
         if(ny_daily)
           {
            ny_open=thu_ny_open;
            ny_close=thu_ny_close;
           }
         //---
         if(!t_day[4])
           {
            t_day[4]=true;
            mtd_time=TimeCurrent();
            t_day[3]=false;
           }
        }
      if(DayOfWeek()==5) // friday
        {
         if(asian_daily)
           {
            asian_open=fri_asian_open;
            asian_close=fri_asian_close;
           }
         if(euro_daily)
           {
            euro_open=fri_euro_open;
            euro_close=fri_euro_close;
           }
         if(ny_daily)
           {
            ny_open=fri_ny_open;
            ny_close=fri_ny_close;
           }
         //---
         if(!t_day[5])
           {
            t_day[5]=true;
            mtd_time=TimeCurrent();
            t_day[4]=false;
           }
        }
      //----
      bool o_time=false;
      if(asian_session && Hour()>=asian_open && Hour()<=asian_close)
         o_time=true;
      if(euro_session  && Hour()>=euro_open  && Hour()<=euro_close)
         o_time=true;
      if(ny_session    && Hour()>=ny_open    && Hour()<=ny_close)
         o_time=true;
      //----
      if(o_time)
        {
         if(signal()==buy)
            o_sends=0;
         if(signal()==sell)
            o_sends=1;
        }
     }
   return(o_sends);
  }
//+------------------------------------------------------------------+
int signal()
  {
   if(T()==0) // additional
     {
      if(forward_trend)
        {
         if(!use_velocity)
           {
            double rsi_1=iRSI(Symbol(),0,rsi_period_1,PRICE_CLOSE,rsi_shift_1);
            if(rsi_1>upper_min && rsi_1<upper_max)
               return(buy);
            if(rsi_1<lower_min && rsi_1>lower_max)
               return(sell);
           }
         if(use_velocity)
           {
            double velo=iCustom(NULL,0,"J_TPO_Velocity",fv_period,0,0);
            if(velo>vel_offset)
               return(buy);
            if(velo<-vel_offset)
               return(sell);
           }
        }
      if(!forward_trend)
        {
         double upBB=iBands(Symbol(),0,bb_period,bb_deviation,0,PRICE_CLOSE,MODE_UPPER,bb_shift);
         double loBB=iBands(Symbol(),0,bb_period,bb_deviation,0,PRICE_CLOSE,MODE_LOWER,bb_shift);
         double stoch=iStochastic(Symbol(),0,k,d,slowing,MODE_SMA,price_field,MODE_SIGNAL,stoch_shift);
         double rsi=iRSI(Symbol(),0,rsi_period,PRICE_CLOSE,rsi_shift);
         if(use_bb && use_stoch && use_rsi)
           {
            if(High[bb_shift]>upBB && stoch>up_level && rsi>upper)
               return(sell);
            if(Low[bb_shift]<loBB && stoch<lo_level && rsi<lower)
               return(buy);
           }
         if(use_bb && use_stoch && !use_rsi)
           {
            if(High[bb_shift]>upBB && stoch>up_level)
               return(sell);
            if(Low[bb_shift]<loBB && stoch<lo_level)
               return(buy);
           }
         if(use_bb && !use_stoch && !use_rsi)
           {
            if(High[bb_shift]>upBB)
               return(sell);
            if(Low[bb_shift]<loBB)
               return(buy);
           }
         if(!use_bb && use_stoch && use_rsi)
           {
            if(stoch>up_level && rsi>upper)
               return(sell);
            if(stoch<lo_level && rsi<lower)
               return(buy);
           }
         if(!use_bb && use_stoch && !use_rsi)
           {
            if(stoch>up_level)
               return(sell);
            if(stoch<lo_level)
               return(buy);
           }
         if(use_bb && !use_stoch && use_rsi)
           {
            if(High[bb_shift]>upBB && rsi>upper)
               return(sell);
            if(Low[bb_shift]<loBB && rsi<lower)
               return(buy);
           }
         if(!use_bb && !use_stoch && use_rsi)
           {
            if(rsi>upper)
               return(sell);
            if(rsi<lower)
               return(buy);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
void closeall()
  {
  Print("closeall");
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic)
         continue;
      if(cmd()>1)
         bool od = OrderDelete(OrderTicket());
      else
        {
         if(cmd()==0)
            bool oc = OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
         else
            bool oc = OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
        }
     }
  }
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| Trailing Stop                                                    |
//+------------------------------------------------------------------+
void TrailingStops()
  {
   if(!UseTrailingStop || TrailingStop == 0)
      return;
   if(trail_sek>TimeCurrent())
      return;
   for(int i = 0; i < OrdersTotal(); i++)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && (magic == 0 || OrderMagicNumber() == magic))
           {
            if(OrderType() == OP_BUY)
              {
               if(Bid - OrderOpenPrice() > TrailingStart * _Point && OrderStopLoss() < ND(Bid-TrailingStop*_Point))
                 {
                  Trail(ND(Bid - TrailingStop * _Point),OrderTicket());
                 }
              }
            if(OrderType() == OP_SELL)
              {
               if(OrderOpenPrice() - Ask > TrailingStart * _Point && (OrderStopLoss()==0||OrderStopLoss()>ND(Ask+TrailingStop*_Point)))
                 {
                  Trail(ND(Ask + TrailingStop * _Point),OrderTicket());
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------------------------------------------------------------------------+
void Trail(double sl, int ticket)
  {
   if(OrderSelect(ticket, SELECT_BY_TICKET,MODE_TRADES))
     {
      double stop=MarketInfo(Symbol(),MODE_STOPLEVEL);
      if(OrderType()==0 && sl<Bid-stop*Point())
        {
         trail_sek=TimeCurrent()+5;
         bool modify = OrderModify(ticket, OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrGold);
         int err = GetLastError();
         if(err!=ERR_NO_ERROR)
           {
            Print("Error on Trail Order modify = ", ErrorDescription(err));
           }

        }

      if(OrderType()==1 && sl>Ask+stop*Point())
        {
         trail_sek=TimeCurrent()+5;
         bool modify = OrderModify(ticket, OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrGold);
         int err = GetLastError();
         if(err!=ERR_NO_ERROR)
           {
            Print("Error on Trail Order modify = ", ErrorDescription(err));
           }
        }
     }
  }
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| Break Even                                                       |
//+------------------------------------------------------------------+
void BreakEvens()
  {
   if(!UseBreakEven || BreakEvenStart == 0)
      return;

   for(int i = 0; i < OrdersTotal(); i++)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && (magic == 0 || OrderMagicNumber() == magic))
           {
            if(OrderType() == OP_BUY)
              {
               if(Bid-OrderOpenPrice() > BreakEvenStart*_Point && ND(OrderOpenPrice()+BreakEvenProfit*_Point) > OrderStopLoss())
                 {
                  Modify(ND(OrderOpenPrice()+BreakEvenProfit*_Point),OrderTicket());
                 }
              }
            if(OrderType() == OP_SELL)
              {
               if(OrderOpenPrice()-Ask > BreakEvenStart*_Point && (0 == OrderStopLoss() || ND(OrderOpenPrice()-BreakEvenProfit*_Point) < OrderStopLoss()))
                 {
                  Modify(ND(OrderOpenPrice()-BreakEvenProfit*_Point),OrderTicket());
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------------------------------------------------------------------------+
bool Modify(double sl, int ticket)
  {
   if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
     {
      if(OrderModify(ticket, OrderOpenPrice(), sl, OrderTakeProfit(), 0, clrGold))
         return(true);
      int err = GetLastError();
      if(err!=ERR_NO_ERROR)
        {
         Print("Error on BreakEven Order modify = ", ErrorDescription(err));
        }
     }
   return(false);
  }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
double ND(double price)
  {
   if(price > 0)
      return(NormalizeDouble(price,_Digits));
   return(0);
  }
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| Check Symbol Points                                              |
//+------------------------------------------------------------------+
double point(string symbol=NULL)
  {
   string sym=symbol;
   if(symbol==NULL)
      sym=Symbol();
   double bid=MarketInfo(sym,MODE_BID);
   int digits=(int)MarketInfo(sym,MODE_DIGITS);

   if(digits<=1)
      return(1); //CFD & Indexes
   if(digits==4 || digits==5)
      return(0.0001);
   if((digits==2 || digits==3) && bid>1000)
      return(1);
   if((digits==2 || digits==3) && bid<1000)
      return(0.01);
   if(StringFind(sym,"XAU")>-1 || StringFind(sym,"xau")>-1 || StringFind(sym,"GOLD")>-1)
      return(0.1);//Gold
   return(0);
  }
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH//
//+------------------------------------------------------------------+
//| News Filter Settings                                             |
//+------------------------------------------------------------------+
void News()
{ 
     string pair = Symbol();
	  string psy = StringSubstr(pair, 0, 3);
	  string nsy = StringSubstr(pair, 3, 3);
	  bool USD = ReportAllForUSD;
	  bool EUR = ReportAllForEUR;
	  bool GBP = ReportAllForGBP;
	  bool NZD = ReportAllForNZD;
	  bool JPY = ReportAllForJPY;
	  bool AUD = ReportAllForAUD;
	  bool CHF = ReportAllForCHF;
	  bool CAD = ReportAllForCAD;
	  bool CNY = ReportAllForCNY;
	  if(AutoReportToCurrSym){
	  USD = (psy=="USD" || nsy=="USD");
	  EUR = (psy=="EUR" || nsy=="EUR");
	  GBP = (psy=="GBP" || nsy=="GBP");
	  NZD = (psy=="NZD" || nsy=="NZD");
	  JPY = (psy=="JPY" || nsy=="JPY");
	  AUD = (psy=="AUD" || nsy=="AUD");
	  CHF = (psy=="CHF" || nsy=="CHF");
	  CAD = (psy=="CAD" || nsy=="CAD");
	  CNY = (psy=="CNY" || nsy=="CNY");}	  
	  
    if(NewsFilter && !IsTesting() && !IsOptimization())
      {
       if(Minute() != PrevMinute)
         {
          PrevMinute = Minute();

          double minutesSincePrevEvent = iCustom(NULL,0,"FFCal",IncludeHigh,IncludeMedium,IncludeLow,IncludeSpeaks,0,0,1,-1,-1,USD,EUR,GBP,NZD,JPY,AUD,CHF,CAD,CNY,1,0);
          double minutesUntilNextEvent = iCustom(NULL,0,"FFCal",IncludeHigh,IncludeMedium,IncludeLow,IncludeSpeaks,0,0,1,-1,-1,USD,EUR,GBP,NZD,JPY,AUD,CHF,CAD,CNY,1,1);

          NewsTime        = false;
          NewsTimeComment = "No News, Trading Allowed!"; 
            
          if((minutesUntilNextEvent <= MinBefore) || (minutesSincePrevEvent <= MinAfter))
            {
             NewsTime        = true;
             NewsTimeComment = "Ongoing News, Trading Disallowed!"; 
            }
         }
      }
    else
      {
       NewsTime        = false;
       NewsTimeComment = "Use News Filter = false !!!";
      }
}  
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Found                                                            |
//+------------------------------------------------------------------+
bool allow_open_order(int typs)
  {
   if(!new_)
      return true;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==typs)
           {
            if(OrderProfit()>0 && OrderCloseTime() > TimeCurrent()-PeriodSeconds()*5)
               return false;
            return true;
           }
        }
     }
   return true;
  }
//+------------------------------------------------------------------+
Mit Zitat antworten
Antwort

Lesezeichen


Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are aus
Pingbacks are aus
Refbacks are aus




Alle Zeitangaben in WEZ +2. Es ist jetzt 18:01 Uhr.





Suchmaschine - Reisen - Wavesnode - Facebook Forum - Spam Firewall
-----------------------------------------------------------------------------------------------------------------------------
Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
SEO by vBSEO 3.6.1
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum
MetaTrader bzw. MetaTrader 4 und MetaTrader 5 sind eingetragene Marken der MetaQuotes Software Corp.
-----------------------------------------------------------------------------------------------------------------------------