Author: Copyright � 2010, Dm_Michael
Orders Execution
It automatically opens orders when conditions are reached
Indicators Used
Moving average indicatorRelative strength index
0 Views
0 Downloads
0 Favorites
a_Sidus
//+------------------------------------------------------------------+
//|                                                      a_Sidus.mq4 |
//|                                     Copyright © 2010, Dm_Michael |
//|                                                   mhs_86@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Dm_Michael"
#property link      "mhs_86@mail.ru"

//---- input parameters
extern int       Fast_MA=14;
extern int       Middle_MA=21;
extern int       Slow_MA=35;
extern int       rsi_period=22;
extern double    lots=0.01;
extern string    note="äëÿ 5õ çíàêîâ, âñå çíà÷åíèÿ *10";
extern int       offset=13;
extern int       TP=750;
extern double    delta=0.00005;
//extern int       SL=200;

int magic = 26022010;
datetime new_time;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   // 1. îïðåäåëÿåì äàííûå=====================================================
   double ma42_0 = NormalizeDouble(iMA(Symbol(), 0, Slow_MA, 0, 1, 0, 1), Digits);
   double ma42_1 = NormalizeDouble(iMA(Symbol(), 0, Slow_MA, 0, 1, 0, 2), Digits);
   double dif_ma42 = ma42_0 - ma42_1;
   //----
   double ma21_0 = NormalizeDouble(iMA(Symbol(), 0, Middle_MA, 0, 1, 0, 1), Digits);
   double ma21_1 = NormalizeDouble(iMA(Symbol(), 0, Middle_MA, 0, 1, 0, 2), Digits);
   double dif_ma21 = ma21_0 - ma21_1;
   //----
   double ma14_0 = NormalizeDouble(iMA(Symbol(), 0, Fast_MA, 0, 1, 0, 1), Digits);
   double ma14_1 = NormalizeDouble(iMA(Symbol(), 0, Fast_MA, 0, 1, 0, 2), Digits);
   double dif_ma14 = ma14_0 - ma14_1;
   //----
   double rsi17_0 = NormalizeDouble(iRSI(Symbol(), 0, rsi_period, 0, 1), Digits);
   double rsi17_1 = NormalizeDouble(iRSI(Symbol(), 0, rsi_period, 0, 2), Digits);
   double dif_rsi17 = rsi17_0 - rsi17_1;
   //----
   Comment("dif42 = "+dif_ma42, "\nma42_0="+ma42_0, " ma42_1="+ma42_1,
       "\n\ndif21 = "+dif_ma21, "\nma21_0="+ma21_0, " ma21_1="+ma21_1,
       "\n\ndif14 = "+dif_ma14, "\nma14_0="+ma14_0, " ma14_1="+ma14_1,
       "\n\ndifrsi = "+dif_rsi17, "\nrsi17_0="+rsi17_0, " rsi_17_1="+rsi17_1);
   // 1. ======================================================================
   
   // 2. îòêðûòèå ïîçèöèé =====================================================
   if(new_time!=Time[0])
   {
      // 2.1 îòêðûòèå áàé
      if(rsi17_1<50 && rsi17_0>50)
         {
          if(dif_ma42>delta && dif_ma21>delta && dif_ma14>delta)
            {
             OrderSend(Symbol(), OP_BUY, lots, NormalizeDouble(Ask,Digits), 3, Low[1]-offset*Point, Ask+TP*Point, "BUY_sidus", magic, 0, CLR_NONE);
            }
         }
      //=================
      // 2.2 îòêðûòèå ñåëë
      if(rsi17_1>50 && rsi17_0<50)
         {
          if(dif_ma42<delta && dif_ma21<delta && dif_ma14<delta)
            {
             OrderSend(Symbol(), OP_SELL, lots, NormalizeDouble(Bid, Digits), 3, High[1]+offset*Point, Bid-TP*Point, "SELL_sidus", magic, 0, CLR_NONE);
            }
         }
      //==================
   new_time = Time[0];
   }
   // 2. ======================================================================
   
   // 3. òðåéëèíã ïîçèöèé =====================================================
   
   //==========================================================================
//----
   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 ---