VR---RIF---MOD

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
VR---RIF---MOD
//=============================================
//Ïî âîïðîñàì çàêàçà ñîâåòíèêîâ îáðàùàòüñÿ íà 
//            ICQ      155553959
//=============================================
extern string ÍÀÑÒÐÎÉÊÈ= "Ãëàâíûå íàñòðîéêè"  ;
extern int    Slip            = 50            ; 
extern int    MagicNumber     = 227           ; 
extern double Lots            = 0.1           ;  
extern int    StopLoss        = 500           ;
extern int    TakeProfit      = 500           ;
extern string TRAL            = "Íàñòðîéêè òðåèëèíã ñòîï-ëîññà";            
extern bool   TrailWhileMinus  = false    ;                                     
extern int    Trail            = 200      ;
//=============================================
extern int    FastEMA         =15             ;
extern int    SlowEMA         =45             ;
extern int    RSIPeriod       =3              ;
extern string ZAKAZ= "ÀÑÜÊÀ ÄËß ÑÂßÇÈ 155553959"; 
//=============================================
int    t1,t2,tiket                                 ;
double slb,tpb,sls,tps;
int start ()                                  {

//=================================================================================
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);                         
//=================================================================================
//ÍÀ×ÀËÎ
//=================================================================================
int siup=0;
int sidw=0;
double pipdiffCurrent=SID1-SID2;
if (pipdiffCurrent>0 && RSIS>50) 
{siup = 1; } 
else 
if (pipdiffCurrent<0 && RSIS<50)
{sidw = 1;  }
  slb=NormalizeDouble(Bid - (StopLoss*  Point),Digits);                             //   ðàñ÷¸ò ñòîïà äëÿ áàé ïîçèöèé//
  tpb=NormalizeDouble(Ask + (TakeProfit*Point),Digits);                             // ðàñ÷¸ò ïðîôèòà äëÿ áàé ïîçèöèé//
  sls=NormalizeDouble(Ask + (StopLoss*  Point),Digits);                             //  ðàñ÷¸ò ñòîïà äëÿ ñåëë ïîçèöèé//
  tps=NormalizeDouble(Bid - (TakeProfit*Point),Digits); 
//=================================================================================
//=================================================================================
if (OrdersTotal() == 0)
{
        if(siup==1)
        {        
//===============================================================================================================================//
                t1=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),Slip,slb,tpb,NULL,MagicNumber,0,CLR_NONE);
        }
        
        if(sidw==1)
        {
                t2=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),Slip,sls,tps,NULL,MagicNumber,0,CLR_NONE);
        }
}

//===============================================================================================================================//
if (OrdersTotal() == 1)
{
        if(siup==1)
        {        
//===============================================================================================================================//
                if(t2>0)
                {
                   OrderClose(t2,Lots,Ask,Slip,Red);
                }
        }
        
        if(sidw==1)
        {
                if(t1>0)
                {
                   OrderClose(t1,Lots,Bid,Slip,Red);
                }
        }
}
//---------------------------------------------------------------------------------------------------------------------------
//Òðàë
//---------------------------------------------------------------------------------------------------------------------------
for (int k=OrdersTotal()-1; k>=0; k--)
    {                                                                    
   OrderSelect(k, SELECT_BY_POS );                               //âûáèðàåì îðäåð
   {
      if(OrderType() == OP_BUY)                                               
         if(TrailWhileMinus == true || Bid-OrderOpenPrice()>Point*Trail)      
            if(Bid - OrderStopLoss() > Trail*Point)                           
            {
               OrderModify(OrderTicket(), 0, Bid - Trail*Point, OrderTakeProfit(), 0); 
               
           }
         
      if(OrderType() == OP_SELL)                                             
         if(TrailWhileMinus == true || OrderOpenPrice()-Ask>Point*Trail)      
            if(OrderStopLoss() - Ask > Trail*Point)                           
            {
               OrderModify(OrderTicket(), 0, Ask + Trail*Point, OrderTakeProfit(), 0);        
            }
   }
}
}
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 ---