Modify-Fractals

Author: wsforex@list.ru
Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Fractals
0 Views
0 Downloads
0 Favorites
Modify-Fractals
//+------------------------------------------------------------------+
//|                                              Modify-Fractals.mq4 |
//+------------------------------------------------------------------+
//| HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH |
//| H\    \               http://wsforex.ru/                /    / H |
//| H )----)-----------------------------------------------(----(  H |
//| H/    /    Ïèøó òîðãîâûå ñèñòåìû íà çàêàç: wsforex.ru   \    \ H |
//| HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH |
//+------------------------------------------------------------------+

#property copyright "wsforex@list.ru"
#property link      "http://wsforex.ru/"
//+------------------------------------------------------------------+
//|       Àâòîð : Ñåðãåé   - ìîé ñàéò -  "http://wsforex.ru/"        |
//+------------------------------------------------------------------+
extern int       Bar = 30; // Êîëè÷åñòâî áàðîâ ñðåäè êîòîðûõ èùåì ôðàêòàë
//+------------------------------------------------------------------+
//|       Àâòîð : Ñåðãåé   - ìîé ñàéò -  "http://wsforex.ru/"        |
//+------------------------------------------------------------------+
int start()
  {
   bool   result;
   double stop_loss,point;
   int    cmd,total,error;
//----
   total=OrdersTotal();
   point=MarketInfo(Symbol(),MODE_POINT);
//----
   for(int i=0; i<total; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         //---- print selected order
         OrderPrint();
         cmd=OrderType();
         //---- buy or sell orders are considered
         if(cmd==OP_BUY || cmd==OP_SELL)
           {
            //---- modify first market order
            while(true)
              {
               if(cmd==OP_BUY)  stop_loss=FractalsDw();
               else  stop_loss=FractalsUp();
               result=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(stop_loss,Digits),OrderTakeProfit(),0,CLR_NONE);
               if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
               else error=0;
               if(error==135) RefreshRates();
               else break;
              }
             //---- print modified order (it still selected after modify)
             OrderPrint();
             break;
           }
        }
      else { Print( "Error when order select ", GetLastError()); break; }
     }
     Comment("Ñêðèïò çàêîí÷èë öèêë");
     Sleep(3000);
     Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
double FractalsDw(){
    for (int i=0; i<Bar; i++) {
    double fr = iFractals(Symbol(), 0, MODE_LOWER, i);
    if(fr==iLow(Symbol(),0,i))return (NormalizeDouble(fr,Digits));
    }
  return (0);
}
//+-----------------------------------------------------------------+
//|       Àâòîð : Ñåðãåé   - ìîé ñàéò -  "http://wsforex.ru/"       |
//+-----------------------------------------------------------------+
double FractalsUp(){
    for (int i=0; i<Bar; i++) {
    double fr = iFractals(Symbol(), 0, MODE_UPPER, i);
    if(fr==iHigh(Symbol(),0,i))return (NormalizeDouble(fr,Digits));
    }
  return (0);
}
//+-----------------------------------------------------------------+
//|       Àâòîð : Ñåðãåé   - ìîé ñàéò -  "http://wsforex.ru/"       |
//+-----------------------------------------------------------------+




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