← Назад к списку файлов

hedg system.mq4

Поиск по коду файла

#property version   "1.00"
#property strict

extern double       Lots=0.01;              //Lots size 
input  double       MaximumRisk   =0.02;
input  double       DecreaseFactor=3;
extern double       Stop_Loss=20;           //Stop Loss  
extern int          MagicNumber=1234;       //MagicNumber 
input  double       TakeProfit=50;          //TakeProfit

int ticket=0;
int ticket1=0;
int ticket2=0;
int ticket3=0;
int           err;

int total=0;
double
Lot,Dmax,Dmin,// Amount of lots in a selected order
Lts,                             // Amount of lots in an opened order
Min_Lot,                         // Minimal amount of lots
Step,                            // Step of lot size change
Free,                            // Current free margin
One_Lot,                         // Price of one lot
Price,                           // Price of a selected order,
pips,
MA_1,MA_2,MA_3,MACD_SIGNAL;
int Type,freeze_level,Spread;

double priceopen,stoploss,takeprofit;

int orderticket;

int
Period_MA_2,  Period_MA_3,       // Calculation periods of MA for other timefr.
Period_MA_02, Period_MA_03,      // Calculation periods of supp. MAs
K2,K3,T;

int OnInit()
  {
      // код доступен только после оплаты
   }

void OnDeinit(const int reason)
  {
  }

void OnTick(void)
  {
      // код доступен только после оплаты
   }

void stop()
  {
   int cnt;

   double middleBB=iBands(Symbol(),0,20, 2,0,0,MODE_MAIN,1);//middle
   double lowerBB=iBands(Symbol(),0,20, 2,0,0,MODE_LOWER,1);//lower
   double upperBB=iBands(Symbol(),0,20, 2,0,0,MODE_UPPER,1);//upper

   double  MacdMAIN=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
   double  MacdSIGNAL=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);

   for(cnt=0;cnt<total;cnt++)
     {
      if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
         continue;
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {

         if(OrderType()==OP_BUY)
           {

            if(((Bid<OrderOpenPrice()-iATR(NULL,0,14,0))
               || ((MacdMAIN>0 && MacdMAIN<MacdSIGNAL) || (MacdMAIN<0 && (MathAbs(MacdMAIN)>MathAbs(MacdSIGNAL))))
               || Close[1]==upperBB))
               exitbuys();

           }
         else // go to short position
           {

            if(((Ask>OrderOpenPrice()+iATR(NULL,0,14,0))
               || ((MacdMAIN>0 && MacdMAIN>MacdSIGNAL) || (MacdMAIN<0 && (MathAbs(MacdMAIN)<MathAbs(MacdSIGNAL)))))
               || Close[1]==lowerBB)
               exitsells();

           }
        }
     }
  }

double LotsOptimized()
  {
   double lot=Lots;
   int    orders=OrdersHistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break

   if(MaximumRisk>0)
     {
  

Показано первые 50% кода (символов: 9038)

Как получить полную версию?

Введите ваш email и нажмите кнопку, чтобы перейти к оплате.