Pricetor v2

Author: Copyright � 2009, MetaQuotes Software Corp.
Price Data Components
Series array that contains open prices of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
Pricetor v2
//+------------------------------------------------------------------+
//|                                                  Pricetor v2.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern bool check=false; 
extern int PeriodP=12; 
extern double TrailingStop = 35;// ðàññòîÿíèå ïîñëå êîòîðîãî áóäåì óñòàíàâëèâàòü áåçóáûòîê
extern double X=5;//óñòàíîâêà â + 5 ïóíêòîâ! 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double P_up0, P_down0, P_up1, P_down1;
   int cnt, total;

  P_up0=iCustom(Symbol(),Period(),"Öåíîâîé êàíàë",PeriodP,0,0);
  P_down0=iCustom(Symbol(),Period(),"Öåíîâîé êàíàë",PeriodP,1,0);
  P_up1=iCustom(Symbol(),Period(),"Öåíîâîé êàíàë",PeriodP,0,1);
  P_down1=iCustom(Symbol(),Period(),"Öåíîâîé êàíàë",PeriodP,1,1);

    
   for(cnt=OrdersTotal()-1;cnt>=0;cnt--) {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&    OrderSymbol()==Symbol())   {
         if(OrderType()==OP_BUY) {  
            
            if(P_down1>P_down0) {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
                 return(0); 
                }
            if(TrailingStop>0)  
              {                  
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop && OrderStopLoss()!=OrderOpenPrice()+X*Point)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+X*Point,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
            else  
            {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
               return(0); 
              }
            if(TrailingStop>0)  
              {               
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if(NormalizeDouble(OrderStopLoss(),Digits) != NormalizeDouble(OrderOpenPrice()-X*Point,Digits))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-X*Point,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
            
           }
        
     }
   if (check) Order_Open();
   return(0);
  }
//+------------------------------------------------------------------+

void Order_Open(){
   if (OrdersTotal()<=1) {
      OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"",20080421,0);
      OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"",20080421,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 ---