3_lccfpgubwykd__www_forex-instruments_info

Author: Copyright 2005, Gordago Software Corp.
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
3_lccfpgubwykd__www_forex-instruments_info
//+------------------------------------------------------------------
//| Copyright 2005, Gordago Software Corp.                           |
//| http://www.gordago.com                                           |  
//|------------------------------------------------------------------
#property copyright "Copyright 2005, Gordago Software Corp."
#property link "http://www.gordago.com"
//----
extern double lStopLoss=17;
extern double sStopLoss=40;
extern double lTrailingStop=88;
extern double sTrailingStop=76;
extern double Lots=0.1;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  int start()
  {
   int cnt, ticket;
     if(Bars<100)
     {
      Print("bars less than 100");
      return(0);
     }
     if(lStopLoss<10)
     {
      Print("StopLoss less than 10");
      return(0);
     }
     if(sStopLoss<10)
     {
      Print("StopLoss less than 10");
      return(0);
     }
   double diMACD0=iMACD(NULL,60,22,27,9,PRICE_CLOSE,MODE_MAIN,0);
   double diMACD1=iMACD(NULL,60,22,27,9,PRICE_CLOSE,MODE_MAIN,1);
   double diMACD2=iMACD(NULL,60,22,27,9,PRICE_CLOSE,MODE_MAIN,0);
   double diStochastic3=iStochastic
   (NULL,15,5,3,11,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0);
   double d4=(26);
   double diStochastic5=iStochastic
   (NULL,15,5,3,11,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0);
   double diStochastic6=iStochastic
   (NULL,15,5,3,11,MODE_EMA,PRICE_CLOSE,MODE_MAIN,1);
   double diClose7=iClose(NULL,1,0);
   double diHigh8=iHigh(NULL,1,1);
   double diMACD9=iMACD(NULL,60,19,77,9,PRICE_CLOSE,MODE_MAIN,0);
   double diMACD10=iMACD(NULL,60,19,77,9,PRICE_CLOSE,MODE_MAIN,1);
   double diMACD11=iMACD(NULL,60,19,77,9,PRICE_CLOSE,MODE_MAIN,1);
   double diStochastic12=iStochastic(NULL,15,9,3,19,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0);
   double d13=(70);
   double diClose14=iClose(NULL,1,0);
   double diLow15=iLow(NULL,1,1);
//----
   int total=OrdersTotal();
     if(total<1)
     {
        if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);
        }
        if ((diMACD0>diMACD1 && diMACD2<0 && diStochastic3<d4 && diStochastic5>diStochastic6 && diClose7>diHigh8))
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-lStopLoss*Point,0, "gordago simple",16384,0,Green);
           if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError());
         return(0);
        }
        if ((diMACD9<diMACD10 && diMACD11>0 && diStochastic12>d13 && diClose14<diLow15))
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+sStopLoss*Point,0,"gordagosample",16384,0,Red);
           if(ticket>0) 
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError());
         return(0);
        }
     }
     for(cnt=0;cnt<total;cnt++) 
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
        if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) 
        {
           if(OrderType()==OP_BUY)
           {
              if(lTrailingStop>0) 
              {
                 if(Bid-OrderOpenPrice()>Point*lTrailingStop) 
                 {
                    if(OrderStopLoss()<Bid-Point*lTrailingStop) 
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*lTrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
            }
            else
            {
              if(sTrailingStop>0) 
              {
                 if((OrderOpenPrice()-Ask)>(Point*sTrailingStop)) 
                 {
                  if((OrderStopLoss()>(Ask+Point*sTrailingStop)) ||
                      (OrderStopLoss()==0)) 
                      {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*sTrailingStop,OrderTakeProfit(),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 ---