Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
1 Views
0 Downloads
0 Favorites
HL_MA_v04
//+------------------------------------------------------------------+ 
//|                                                     High&Low.mq4 | 
//|                                  Copyright © 2007, Shadow Trader | 
//|                                   e-mail: ShadowTrader@fxmail.ru | 
//+------------------------------------------------------------------+ 
// Ýêñïåðò ïðåäíàçíà÷åí äëÿ ðàáîòû íà äíåâêàõ.
// Ïàðàìåòðû óñòàíîâëåíû äëÿ ïàðû EURUSD
extern int ma_period = 20;
extern double SL_percent_of_channel = 2.1;
double lots   = 0.1;
double sl;
double tp;


int init ()
{ 
   return(0);
} 

int deinit()
{
   return(0);
}

int day=1;

int start()
{
   if (AccountFreeMargin() < 120)
      return (0);

   double mah = iMA(Symbol(), 0, ma_period, 0, MODE_LWMA, PRICE_HIGH, 1);
   double mal = iMA(Symbol(), 0, ma_period, 0, MODE_LWMA, PRICE_LOW,  1);
      
   if (OrdersTotal() > 0)
   {
      if (Volume[0]>day)
         return (0);
      else
      {
         for (int i = 0; i < OrdersTotal(); i++)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE)
            {
               if (OrderType() == OP_BUY)
               {
                  if (OrderStopLoss() < mal)
                      OrderModify(OrderTicket(), Ask, mal, OrderTakeProfit(), 0, Gold);
               }

               if (OrderType() == OP_SELL)
               {
                  if (OrderStopLoss() > mah)
                      OrderModify(OrderTicket(), Bid, mah, OrderTakeProfit(), 0, Green);
               }
            }
         }
         return (0);
      }
   }

   // Ïîêóïêà
   if ( Close[1] > mah && Low [0] > mah )
   {
      sl = Ask-SL_percent_of_channel*(mah-mal);
      tp = Ask + (mah - mal);
      OrderSend(Symbol(), OP_BUY, lots, Ask, 3, sl, tp, "", 0, 0, Blue);
   }

   // Ïðîäàæà
   if ( Close[1] < mal && High[0] < mal )
   {
      sl = Bid+SL_percent_of_channel*(mah-mal);
      tp = Bid - (mah - mal);
      OrderSend(Symbol(), OP_SELL, lots, Bid, 3, sl, tp, "", 0, 0, Red);
   }

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