proboy_xonax

Author: Copyright 2015, Xonax.ru.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
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
0 Views
0 Downloads
0 Favorites
proboy_xonax
//+------------------------------------------------------------------+
//|                                                 ProBoy XonaX.mq4 |
//|                                        Copyright 2015, Xonax.ru. |
//|                                             https://www.xonax.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Xonax.ru."
#property link      "https://www.xonax.ru"
#property version   "1.00"
#property strict
//--- input parameters
input int      StLoss=50;
//--- ïîìèìî ñòîëîññà áóäåì 1 ðàç èñïîëüçîâàòü â êà÷åñòâå òðåéëèíãñòîïà, äëÿ ïåðåâîäà îðäåðà â áåçóáûòîê
input int      TProf=1000;
input int      TimeFr=240;
input double   Lot=0.1;
input int      Magik=100004;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double Dmax,Dmin;
   static datetime BarT=0; //ââåäåì ýòè ïåðåìåííûå,
   datetime TempT; // ÷òîáû âû÷èñëåíèÿ ïðîâîäèëèñü 1 ðàç çà óêàçàííûé òàéìôðåéì à íå â êàæäîì òèêå
   int total=OrdersTotal();
   Dmax=iHigh(NULL,TimeFr,1);
   Dmin=iLow(NULL,TimeFr,1);
   TempT=iTime(NULL,TimeFr,1);
   if(Bid>Dmax && BarT!=TempT)
     {
      int ticket=OrderSend(NULL,OP_BUY,Lot,Ask,30,Ask-StLoss*_Point,Ask+TProf*_Point,NULL,Magik,0,clrBlue);
      if(ticket<0)
        {
         Print("OrderSend error #",GetLastError());
        }
      BarT=TempT;
     }
   if(Ask<Dmin && BarT!=TempT)
     {
      int ticket=OrderSend(NULL,OP_SELL,Lot,Bid,30,Bid+StLoss*_Point,Ask-TProf*_Point,NULL,Magik,0,clrRed);
      if(ticket<0)
        {
         Print("OrderSend error #",GetLastError());
        }
      BarT=TempT;
     }
//--- Trailing Stop operation
   for(int cni=0;cni<total;cni++)
     {
      if(!OrderSelect(cni,SELECT_BY_POS,MODE_TRADES))
         continue;
      if(OrderMagicNumber()==Magik)
        {
         if(OrderType()==OP_BUY)
           {
            if(Bid-OrderOpenPrice()>_Point*StLoss)
              {
               if(OrderStopLoss()<OrderOpenPrice())
                 {
                  //--- modify order and exit
                  if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-_Point*StLoss,OrderTakeProfit(),0,clrBlue))
                     Print("OrderModify error ",GetLastError());
                  return;
                 }
              }
           }
         if(OrderType()==OP_SELL)
           {
            if((OrderOpenPrice()-Ask)>_Point*StLoss)
              {
               if(OrderStopLoss()>OrderOpenPrice())
                 {
                  //--- modify order and exit
                  if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*StLoss,OrderTakeProfit(),0,clrRed))
                     Print("OrderModify error ",GetLastError());
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+

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 ---