VR---ZVERi1

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Stochastic oscillator
Miscellaneous
It plays sound alertsIt issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
VR---ZVERi1
//=============================================
//                                ZVER=1=.mq4 |
//Copyright © 2010, MetaQuotes Software Corp. |
//                  http://www.metaquotes.net |
//=============================================
extern string ÍÀÑÒÐÎÉÊÈ= "Ãëàâíûå íàñòðîéêè"  ;
extern int    TakeProfit      = 700           ;
extern int    StopLoss        = 500           ;
extern bool   LOC             = true          ;
extern bool   MAX             = false         ;
extern double Overlot         = 5             ;
extern int    Slip            = 50            ; 
extern int    MagicNumber     = 227           ;
extern bool   COMMENT         = false         ;
extern int    time            = 1             ; 
//=============================================
extern string Àâòîòîðãîâëÿ    = "Äëÿ âõîäà"   ; 
extern bool   Avtomat         = true          ; 
extern double Lots            = 0.01          ; 
extern int    LotsProcent     = 10            ; 
extern int    Bezubitoc       = 500            ;            
//=============================================
extern string ÈÍÄÈÊÀÒÎÐÛ1     ="3xMAs#2"      ;
extern bool   xMAs            = false         ;
//=============================================
extern int    MA1_period      = 3             ; 
extern int    MA1_type        = 1             ;
extern int    MA1_price       = 0             ;          
extern int    MA1_shift       = 0             ; 
//=============================================           
extern int    MA2_period      = 7             ; 
extern int    MA2_type        = 1             ;
extern int    MA2_price       = 1             ;          
extern int    MA2_shift       = 0             ;
//=============================================           
extern int    MA3_period      = 90            ; 
extern int    MA3_type        = 3             ;
extern int    MA3_price       = 0             ;          
extern int    MA3_shift       = 0             ;
//=============================================
extern string ÈÍÄÈÊÀÒÎÐÛ2     ="ÑÒÎÕÀÑÒÈÊ"    ;
extern bool   STOHASTIC       = true          ;
//=============================================
extern int    Kperiod         = 42            ;
extern int    Dperiod         = 5             ;
extern int    slowing         = 7             ;
extern int    UPuroven        = 50            ;
extern int    DWuroven        = 50            ;
//=============================================
extern string ÈÍÄÈÊÀÒÎÐÛ3     ="RSI"          ;
extern bool   RSI             = true          ;
//=============================================
extern int    RSIperiod       = 14            ;
extern int    UPuroven_       = 50            ;
extern int    DWuroven_       = 50            ;
//=============================================
extern string ÈÍÄÈÊÀÒÎÐÛ4     ="ÑÒÐÅËÊÈ=SIDUS";
extern bool   SIDUS           = true          ;
extern int    FastEMA         =14             ;
extern int    SlowEMA         =21             ;
extern int    RSIPeriod       =17             ;
//=============================================
double Lot,slb,slbb,tpb,sls,slss,tps,OtkrSS,OtkrBS;
double OtkrSS1,OtkrBS1,ho,lo,u,d              ;
int    tiket,t1,t2                            ;
int start ()                                  {
//====================================================================//
//                             ÐÀÑ×¨Ò ËÎÒÀ                            //
//====================================================================//
   string Symb   =Symbol()                                           ;//Ôèíàíñîâûé èíñòðóì.
   double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED)               ;//Ñòîèì. 1 ëîòà
   double Min_Lot=MarketInfo(Symb,MODE_MINLOT)                       ;//Ìèí. ðàçìåð. ëîòîâ
   double Step   =MarketInfo(Symb,MODE_LOTSTEP)                      ;//Øàã èçìåíåí ðàçìåðà
   double Free   =AccountFreeMargin()                                ;//Ñâîáîäíûå ñðåäñòâà
//====================================================================//
   if (Lots>0)                                                        //Ëîòû çàäàíû ÿâíî..
{                                                                     //ïðîâåðèì ýòî
      double Money=Lots*One_Lot                                      ;//Ñòîèìîñòü îðäåðà
      if(Money<=AccountFreeMargin())                                  //Ñðåäñòâ õâàòàåò..
         Lot=Lots                                                    ;//ïðèíèìàåì çàäàííîå
      else                                                            //Åñëè íå õâàòàåò..
         Lot=MathFloor(Free/One_Lot/Step)*Step                       ;//Ðàñ÷¸ò ëîòîâ
}                                                                     //
//====================================================================//
   else                                                               //Åñëè ëîòû íå çàäàíû
{                                                                     //òî áåð¸ì ïðîöåíò
      if (LotsProcent > 100)                                          //Çàäàíî îøèáî÷íî ..
          LotsProcent=100                                            ;//òî íå áîëåå 100
      if (LotsProcent==0)                                             //Åñëè óñòàíîâëåí 0 ..
          Lot=Min_Lot                                                ;//òî ìèíèìàëüíûé ëîò
      else                                                            //Æåëàåì. êîëè÷.ëîòîâ:
          Lot=MathFloor(Free*LotsProcent/100/One_Lot/Step)*Step      ;//Ðàñ÷
}
//====================================================================//
   if (Lot < Min_Lot)                                                 // Åñëè ìåíüøå äîïóñò..
       Lot=Min_Lot                                                   ;// .. òî ìèíèàìàëüíûé
   if (Lot*One_Lot > AccountFreeMargin())                             // Íå õâàòàåò äàæå..
     {                                                                // ..íà ìèíèìàëüí. ëîò:(
      Print(11,0,Min_Lot)                                            ;// Ñîîáùåíèå..
      return(false)                                                  ;// ..è âûõîä 
     }                                                                // Âûõîä èç ïîëüç. ô-èè
//====================================================================//
//                         ÊÎÍÅÖ ÐÀÑ×¨Ò ËÎÒÀ                          //
//====================================================================//
Comment("=========ÄÐÓÃÈÅ ÌÎÈ ÐÀÁÎÒÛ WWW.TESVOP.NAROD.RU");

int dw=0                                      ;
int up=0                                      ;
//=================================================================================
double spid = iMA        (NULL,0,MA1_period       ,MA1_shift,MA1_type,MA1_price,0);
double sred = iMA        (NULL,0,MA2_period       ,MA2_shift,MA2_type,MA2_price,0);
double medl = iMA        (NULL,0,MA3_period       ,MA3_shift,MA3_type,MA3_price,0);
double SID1 = iMA        (NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,0);
double SID2 = iMA        (NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,0);
double RSIS = iRSI       (NULL,0,RSIPeriod, PRICE_CLOSE,        0);
double Bstoh= iStochastic(NULL,0,Kperiod,Dperiod,slowing,MODE_SMA,0,MODE_SIGNAL,0);
double Mstoh= iStochastic(NULL,0,Kperiod,Dperiod,slowing,MODE_SMA,0,MODE_MAIN  ,0);
double RSI  = iRSI       (NULL,0,RSIperiod,PRICE_CLOSE,0)                         ;
//=================================================================================
// Ïîïåðëî
//=================================================================================
// SIDUS
//=================================================================================
int SI=0;
int siup=0;
int sidw=0;
if (SIDUS== true) { 
SI=1;
double pipdiffCurrent=SID1-SID2;
if (pipdiffCurrent>0 && RSIS>50) 
{
siup = 1; 
} 
else 
if (pipdiffCurrent<0 && RSIS<50)
{
sidw = 1;  
}}
//=================================================================================
//3xMAs#2
//=================================================================================
int ma=0;
int maup=0;
int madw=0;
if (xMAs==true)
{ 
ma=1;
if ((spid>sred)&&(sred>medl))
{maup = 1;}
if ((medl>sred)&&(sred>spid))
{madw = 1;}}
//=================================================================================
// STOHASTIC
//=================================================================================
int stoh=0;
int stohup=0;
int stohdw=0;
if (STOHASTIC==true)
{
stoh=1;
if (Bstoh<Mstoh&&DWuroven>Mstoh)
{stohup = 1;}
 if (Bstoh>Mstoh&&UPuroven<Mstoh)
{stohdw = 1;}}
//=================================================================================
//RSI
//=================================================================================
int rsi=0;
int rsiup=0;
int rsidw=0;
if (RSI==true)
{
rsi=1;
if (RSI<DWuroven_)
{rsiup = 1;}
 if (RSI>UPuroven_)
{rsidw = 1;}}
//=================================================================================
int UP=rsi+stoh+ma+SI;
if (UP==maup+siup+stohup+rsiup)
{
up=1;
}
if (UP==sidw+madw+stohdw+rsidw)
{
dw=1;
}
//=================================================================================
time=time*60000;
double spr= MarketInfo("EURUSD",MODE_SPREAD);
double spred=(spr*Point);
//=================================================================================
//  slb    =NormalizeDouble(Bid - (StopLoss  *    Point),Digits)      ;                             
//  tpb    =NormalizeDouble(Ask + (TakeProfit*    Point),Digits)      ;                             
//  sls    =NormalizeDouble(Ask + (StopLoss  *    Point),Digits)      ;                             
//  tps    =NormalizeDouble(Bid - (TakeProfit*    Point),Digits)      ;
   
//  OtkrBS =NormalizeDouble(Ask + (TakeProfit/3*2*Point),Digits)      ; 
//  OtkrSS =NormalizeDouble(Bid - (StopLoss  /3*2*Point),Digits)      ;
  
//  OtkrBS1=NormalizeDouble(Bid - (TakeProfit/3*2*Point),Digits)      ; 
//  OtkrSS1=NormalizeDouble(Ask + (StopLoss  /3*2*Point),Digits)      ;
//=================================================================================
//=================================================================================
//íîâûå ïàðàìåòðû âõîäà
//=================================================================================
//=================================================================================
  slb    =NormalizeDouble(Bid - (StopLoss/3*2  *    Point),Digits)      ;
  slbb   =NormalizeDouble(Bid +spred- (StopLoss      *    Point),Digits)      ;   
                             
  tpb    =NormalizeDouble(Ask + (TakeProfit*        Point),Digits)      ; 
                              
  sls    =NormalizeDouble(Ask + (StopLoss/3*2  *    Point),Digits)      ;  
  slss   =NormalizeDouble(Ask -spred+(StopLoss  *    Point),Digits)      ;                            
  tps    =NormalizeDouble(Bid - (TakeProfit*        Point),Digits)      ;
   
  OtkrBS =NormalizeDouble(Ask + (TakeProfit/3*2*Point),Digits)      ; 
  OtkrSS =NormalizeDouble(Bid - (StopLoss  /3*2*Point),Digits)      ;
  
  OtkrBS1=NormalizeDouble(Bid - (TakeProfit/3*2*Point),Digits)      ; 
  OtkrSS1=NormalizeDouble(Ask + (StopLoss  /3*2*Point),Digits)      ;
//=================================================================================
//=================================================================================
// ÊÎÍÅÖ íîâûõ ïàðàìåòðîâ âõîäà
//=================================================================================
//=================================================================================
   int total=OrdersTotal();
   int n=0;
   for (int i=total-1; i>=0; i--)
   {
    if(OrderSelect(i, SELECT_BY_POS))
    {
     if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
     {
      n++;
     }
    }
   }

if ((n == 0)&&(Avtomat==true))
{
        if(up==1)
        {        
//===============================================================================================================================//
                tiket=OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),Slip,slb,tpb,NULL,MagicNumber,0,CLR_NONE); 
                PlaySound("2.wav");
                if (LOC==true&&Avtomat==true)
        {
                t1 =  OrderSend(Symbol(), OP_SELLSTOP, Lot*Overlot,OtkrSS,Slip,0,slbb, 0, MagicNumber,0);
        }
                if (MAX==true&&Avtomat==true)
        {
                t2 =  OrderSend(Symbol(), OP_BUYSTOP, Lot*Overlot,OtkrSS1,Slip,0,tpb, 0, MagicNumber,0);
        }
                Print("îøèáêà ", GetLastError());               
        }
//-------------------------------------------------------------------------------------------------------------------------------//
        else
//-------------------------------------------------------------------------------------------------------------------------------//
        if(dw==1)
        {
                tiket=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),Slip,sls,tps,NULL,MagicNumber,0,CLR_NONE);
                PlaySound("2.wav");
                if (MAX==true&&Avtomat==true)
        {
                t1 = OrderSend(Symbol(), OP_SELLSTOP, Lot*Overlot,OtkrSS,Slip,0,tps, 0, MagicNumber,0);
        }
                if (LOC==true&&Avtomat==true)
        {
                t2 = OrderSend(Symbol(), OP_BUYSTOP, Lot*Overlot,OtkrSS1,Slip,0,slss, 0, MagicNumber,0);
        }
                Print("îøèáêà ", GetLastError());                
        }
}
//=================================================================================
//===============================================================================================================================//
//===============================================================================================================================//

if (n == 1&&Avtomat==false)
{
    for (int k=total-1; k>=0; k--)
    {
        if(OrderSelect(k,SELECT_BY_POS, MODE_TRADES)==true)
          {
            
            if ((OrderType()==OP_BUY)&&(OrderTakeProfit()==0)&&(OrderStopLoss()==0))
              { 
                ho=OrderLots();
                OrderModify(OrderTicket(),OrderOpenPrice(),slb,tpb,0,Blue);
                if (LOC==true)
               {
                t1 =  OrderSend(Symbol(), OP_SELLSTOP, ho*Overlot,OtkrSS,Slip,0,slbb, 0, MagicNumber,0);
                }
                if (MAX==true)
                {
                t2 =  OrderSend(Symbol(), OP_BUYSTOP, ho*Overlot,OtkrSS1,Slip,0,tpb, 0, MagicNumber,0);
                }
                
              }
          }
      }     
//-------------------------------------------------------------------------------------------------------------------------------//
    for (int o=total-1; o>=0; o--)
      {
        if(OrderSelect(o,SELECT_BY_POS, MODE_TRADES)==true)
          {
            if ((OrderType()==OP_SELL)&&(OrderTakeProfit()==0)&&(OrderStopLoss()==0))
              { 
                lo=OrderLots();
                OrderModify(OrderTicket(),OrderOpenPrice(),sls,tps,0,Blue);
                if (MAX==true)
                {
                t1 = OrderSend(Symbol(), OP_SELLSTOP, lo*Overlot,OtkrSS,Slip,0,tps, 0, MagicNumber,0);
                }
                if (LOC==true)
                {
                t2 = OrderSend(Symbol(), OP_BUYSTOP, lo*Overlot,OtkrSS1,Slip,0,slss, 0, MagicNumber,0);
                }
                PlaySound("2.wav");
                
              }
                
             }             
          
     }
}
//===============================================================================================================================//
//===============================================================================================================================//
//=================================================================================
if (n==1)
{
if(OrderSelect(t1,SELECT_BY_TICKET  ))
{
        if(OrderType()==OP_SELLSTOP)
        {
                OrderDelete(t1);
        }
}
if(OrderSelect(t2,SELECT_BY_TICKET  ))
{
        if(OrderType()==OP_BUYSTOP)
        {
                OrderDelete(t2);
        }
}} 
//=================================================================================
//=================================================================================
if (COMMENT==true)
{
  if (UP==maup+siup+stohup+rsiup)
  {
  Alert("ÂÍÈÌÀÍÈÅ="+Symbol()+"=M"+Period(),"=ÂÛÁÐÀÍÍÛÅ ÈÍÄÈÊÀÒÎÐÛ ÃÎÂÎÐßÒ ÏÎÊÓÏÀÒÜ");
  Sleep(time);
  }
  if (UP==sidw+madw+stohdw+rsidw)
  {
  Alert("ÂÍÈÌÀÍÈÅ="+Symbol()+"=M"+Period(),"=ÂÛÁÐÀÍÍÛÅ ÈÍÄÈÊÀÒÎÐÛ ÃÎÂÎÐßÒ ÏÐÎÄÀÂÀÒÜ");
  Sleep(time);
  }
  if ((UP!=maup+siup+stohup+rsiup)||(UP!=sidw+madw+stohdw+rsidw))
  {
  Alert("ÆÄ¨Ì="+Symbol()+"=M"+Period(),"=ÈÍÄÈÊÀÒÎÐÛ ÐÀÇÍÎÍÀÏÐÀÂËÅÍÛ");
  Sleep(time/2);
  }
}
//=================================================================================
//=================================================================================
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (n==2)
{ 
    for (int w=total-1; w>=0; w--)
      {
        if(OrderSelect(w,SELECT_BY_POS, MODE_TRADES)==true)
          {
           if (OrderType()==OP_BUY)//&&OrderTakeProfit()==0)
              {
              double otkrbbb=OrderOpenPrice();
              double stopbbb=OrderStopLoss() ;
              double fan=      NormalizeDouble(otkrbbb+(Bezubitoc*Point),Digits);  
               if (Ask>= fan)     
               {
               if (stopbbb<otkrbbb)
                {
                 OrderModify(OrderTicket(),OrderOpenPrice(),otkrbbb,OrderTakeProfit(),0,Blue);
                }
               }
              }
           if (OrderType()==OP_SELL)//&&OrderTakeProfit()==0)
             {
              double otkrsss=OrderOpenPrice();
              double stopsss=OrderStopLoss() ;
              double han=  NormalizeDouble(otkrsss-(Bezubitoc*Point),Digits);
               if (Bid<= han)      
               {
               if (stopsss>otkrsss)
               {
                OrderModify(OrderTicket(),OrderOpenPrice(),otkrsss,OrderTakeProfit(),0,Blue);
               }
              }
            }
         }
     }
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
return(0);}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---