FXG_sStopLossOrders

Author: FXGeneral,� 2010
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
FXG_sStopLossOrders
//+------------------------------------------------------------------+
//|                                          FXG_sStopLossOrders.mq4 |
//|                                                 FXGeneral,© 2010 |
//|                                        http://www.fxgeneral.com/ |
//+------------------------------------------------------------------+

#property copyright "FXGeneral,© 2010"
#property link      "http://www.fxgeneral.com/"

#property show_inputs
extern int    lot_multiplier=1;
extern int    orders=5;
extern int    step=21;
extern int    TakeProfit=21;
extern int    StopLoss=21;
extern int    slippage=3;



 double fPointX()
 {
   double PointX = 0;
   if(Digits==5 || Digits==3) 
     {
      PointX = Point * 10;
     }
   if(Digits==4 || Digits==2) 
     {
      PointX = Point;
     }
   return(PointX);
 } 
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
int cnt,limit,ticket,type;
double stop,lot;
limit=OrdersTotal();
   for(cnt=0;cnt<limit;cnt++)
    {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderSymbol()==Symbol())
      {
       if (OrderType()==OP_BUY || OrderType()==OP_SELL) 
       {
        stop=OrderStopLoss();
        type=OrderType();
        lot=OrderLots();
       }
      }
    }
  if(stop==0) Alert("Îòñóòñòâóåò StopLoss ó îðäåðà #"+OrderTicket()+"");  
   for(int z = 0;z<orders;z++)
    {
     if(type==0)
      {
       ticket=OrderSend(Symbol(),OP_SELLSTOP,lot*lot_multiplier,
              NormalizeDouble(stop-z*step*fPointX(),Digits),slippage,
              NormalizeDouble(stop-z*step*fPointX()+StopLoss*fPointX(),Digits),
              NormalizeDouble(stop-z*step*fPointX()-TakeProfit*fPointX(),Digits),
              "FXG_sStopLossOrders Order# "+z+"",0,0,CLR_NONE);
       if(ticket<0)
           {
            Print(z,"  Îøèáêà îòêðûòèÿ îðäåðà #",GetLastError());
            return(0);
           }

      }
     if(type==1)
      {
       ticket=OrderSend(Symbol(),OP_BUYSTOP,lot*lot_multiplier,
              NormalizeDouble(stop+z*step*fPointX(),Digits),slippage,
              NormalizeDouble(stop+z*step*fPointX()-StopLoss*fPointX(),Digits),
              NormalizeDouble(stop+z*step*fPointX()+TakeProfit*fPointX(),Digits),"FXG_sStopLossOrders Order# "+z+"",0,0,CLR_NONE);
       if(ticket<0)
          {
           Print(z,"  Îøèáêà îòêðûòèÿ îðäåðà #",GetLastError());
           return(0);
          }
      }
    }  
   
   
//----
   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 ---