1$ a Day (100 in 30)

Author: Copyright � 2007, GwadaTradeBoy Corp.
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 reachedIt Closes Orders by itself
1 Views
0 Downloads
0 Favorites
1$ a Day (100 in 30)
//+------------------------------------------------------------------+
//|                                         1$ a Day (100 in 30).mq4 |
//|                            Copyright © 2007, GwadaTradeBoy Corp. |
//|                                            racooni_1975@yahoo.fr |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, GwadaTradeBoy Corp."
#property link      "racooni_1975@yahoo.fr"

//---- Variables
string   comment_text      = "";
int      Magic             = 20080920;
int      PriceStep2        = 20;
int      PriceStep3        = 10;
int      total             = 0;
int      cnt               = 0;
int      TakeProfitStep1, TakeProfitStep2, TakeProfitStep3;
int      ticket;
double   OpenPrice, OpenVolume;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
   {
//----
      if (Symbol()=="EURUSD") {TakeProfitStep1 = 30; TakeProfitStep2 = 20; TakeProfitStep3 = 10;}
      if (Symbol()=="GBPUSD") {TakeProfitStep1 = 30; TakeProfitStep2 = 20; TakeProfitStep3 = 10;}
      if (Symbol()=="NZDUSD") {TakeProfitStep1 = 30; TakeProfitStep2 = 20; TakeProfitStep3 = 10;}
      if (Symbol()=="USDJPY") {TakeProfitStep1 = 31; TakeProfitStep2 = 21; TakeProfitStep3 = 11;}
      if (Symbol()=="GBPJPY") {TakeProfitStep1 = 31; TakeProfitStep2 = 21; TakeProfitStep3 = 11;}
      if (Symbol()=="GBPNZD") {TakeProfitStep1 = 75; TakeProfitStep2 = 50; TakeProfitStep3 = 25;}
//----
      return(0);
   }

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
   {
//----
   
//----
      return(0);
   }

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
   {
//----
      if (Symbol()=="EURUSD") {TakeProfitStep1 = 30; TakeProfitStep2 = 20; TakeProfitStep3 = 10;}
      if (Symbol()=="GBPUSD") {TakeProfitStep1 = 30; TakeProfitStep2 = 20; TakeProfitStep3 = 10;}
      if (Symbol()=="NZDUSD") {TakeProfitStep1 = 30; TakeProfitStep2 = 20; TakeProfitStep3 = 10;}
      if (Symbol()=="USDJPY") {TakeProfitStep1 = 31; TakeProfitStep2 = 21; TakeProfitStep3 = 11;}
      if (Symbol()=="GBPJPY") {TakeProfitStep1 = 31; TakeProfitStep2 = 21; TakeProfitStep3 = 11;}
      if (Symbol()=="GBPNZD") {TakeProfitStep1 = 75; TakeProfitStep2 = 50; TakeProfitStep3 = 25;}
      total = OrdersTotal();
      for (cnt = total ; cnt >=0 ; cnt--)
         {
            OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
            if (OrderComment() == "123*1" && OrderTakeProfit() == 0)
               {
                  if(OrderType() == OP_BUY)
                     {
                        OpenPrice = OrderOpenPrice();
                        OpenVolume = OrderLots();
                        ticket = OrderModify(OrderTicket(),OrderOpenPrice(),0,OpenPrice + Point * TakeProfitStep1,0,Blue);
                        if(ticket <= 0)
                           Print("Error = ",GetLastError());
                        else
                           {
                              ticket = OrderSend(Symbol(),OP_BUYSTOP,OpenVolume * 2,OpenPrice + Point * PriceStep2,0,0,(OpenPrice + Point * PriceStep2) + Point * TakeProfitStep2,"123*2",Magic,0,Green);
                              if(ticket <= 0)
                                 Print("Error = ",GetLastError());
                              else
                                 {
                                    ticket = OrderSend(Symbol(),OP_BUYSTOP,OpenVolume * 3,OpenPrice + Point * PriceStep3,0,0,(OpenPrice + Point * PriceStep3) + Point * TakeProfitStep3,"123*3",Magic,0,Green);
                                    if(ticket <= 0)
                                       Print("Error = ",GetLastError());
                                 }
                           }
                     }
                  if(OrderType() == OP_SELL) 
                     {
                        OpenPrice = OrderOpenPrice();
                        OpenVolume = OrderLots();
                        ticket = OrderModify(OrderTicket(),OrderOpenPrice(),0,OpenPrice - Point * TakeProfitStep1,0,Blue);
                        if(ticket <= 0)
                           Print("Error = ",GetLastError());
                        else
                           {
                              ticket = OrderSend(Symbol(),OP_SELLSTOP,OpenVolume * 2,OpenPrice - Point * PriceStep2,0,0,(OpenPrice - Point * PriceStep2) - Point * TakeProfitStep2,"123*2",Magic,0,Red);
                              if(ticket <= 0)
                                 Print("Error = ",GetLastError());
                              else
                                 {
                                    ticket = OrderSend(Symbol(),OP_SELLSTOP,OpenVolume * 3,OpenPrice - Point * PriceStep3,0,0,(OpenPrice - Point * PriceStep3) - Point * TakeProfitStep3,"123*3",Magic,0,Red);
                                    if(ticket <= 0)
                                       Print("Error = ",GetLastError());
                                 }
                           }
                     }
               }
//            else
            if (OrderComment() == "321")
               {
                  switch (OrderLots() / MarketInfo(Symbol(),MODE_MINLOT))
                     {
                        case 6:
                           if(OrderType()==OP_BUY)
                              OrderClose(OrderTicket(),((OrderLots() / 6) * 3),OrderOpenPrice()+ Point * TakeProfitStep3,0,Violet);
                           if(OrderType()==OP_SELL) 
                              OrderClose(OrderTicket(),((OrderLots() / 6) * 3),OrderOpenPrice()- Point * TakeProfitStep3,0,Violet);
                        break;
                        case 3:
                           if(OrderType()==OP_BUY)
                              OrderClose(OrderTicket(),((OrderLots() / 3) * 2),OrderOpenPrice()+ Point * TakeProfitStep2,0,Violet);
                           if(OrderType()==OP_SELL) 
                              OrderClose(OrderTicket(),((OrderLots() / 3) * 2),OrderOpenPrice()- Point * TakeProfitStep2,0,Violet);
                        break;
                        case 1:
                           if(OrderType()==OP_BUY)
                              OrderClose(OrderTicket(),OrderLots(),OrderOpenPrice()+ Point * TakeProfitStep1,0,Violet);
                           if(OrderType()==OP_SELL) 
                              OrderClose(OrderTicket(),OrderLots(),OrderOpenPrice()- Point * TakeProfitStep1,0,Violet);
                        break;
                     }
               }   
         }
//----
      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 ---