ShadowTrader 1.2_D1_EURUSD

Author: Copyright � 2005, MetaQuotes Software Corp.
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Fractals
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
66.00 %
Total Trades 724
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -0.15
Gross Profit 209.34
Gross Loss -319.29
Total Net Profit -109.95
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
84.00 %
Total Trades 827
Won Trades 320
Lost trades 507
Win Rate 0.39 %
Expected payoff -0.07
Gross Profit 287.12
Gross Loss -343.01
Total Net Profit -55.89
-100%
-50%
0%
50%
100%
ShadowTrader 1.2_D1_EURUSD
//+------------------------------------------------------------------+
//|                                                   ShadowTrader   |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|                                                             v1.2 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern double Lots     = 0.01;
extern int TakeProfit  =   90;
extern int StopLoss    =   30;
extern int hour        =   12; // 12 is for GMT+2 The time, after which the order will be closed
extern int limit       =    2; // Level of setting the postponed order

static int magicNumber = 23456;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
   return(0);
}

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

static datetime prev_min = D'1.1.1'; // Previous minimum
static datetime prev_max = D'1.1.1'; // Previous maximum

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
   double iFractals_up = 0; // Maximum
   double iFractals_lo = 0; // Minimum
   double TP = 0, SL = 0, price = 0;
   bool order_buy  = false,
        order_sell = false;

   // If there are 2 open orders - no longer it is discovered
   for (int cnt = 0; cnt < OrdersTotal(); cnt++)
   {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) == false)
         continue;
         
      if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != magicNumber))
         continue;

      if ((OrderType() != OP_SELL) && (OrderType() != OP_BUY))
         continue;

      switch (OrderType())
      {
         case OP_BUY :
         {
            price     = Bid; 
            order_buy = true;
         } break;
         
         case OP_SELL: 
         { 
            price      = Ask; 
            order_sell = true;
         } break;
      }
            
      // The time elapsed...
      if ((CurTime() - OrderOpenTime()) > hour * 3600)
      {
         OrderClose(OrderTicket(), OrderLots(), price, 3, Red);
         return (0);
      }
   }
   
   // Free Margin remainder
   if (AccountFreeMargin() < 1000 * Lots)
      return (0);
   
   for (int i = 0; i < Bars; i++)
   {
     iFractals_up = iFractals(NULL, 0, MODE_UPPER, i);
     iFractals_lo = iFractals(NULL, 0, MODE_LOWER, i);

      if ((iFractals_up != 0) || (iFractals_lo != 0))
         break;
   }

   // New maximum ?
   if ((iFractals_up != 0) && (Time[i] != prev_max) && (i < 3) && (order_buy == false))
   {
      prev_max = Time[i];
      
      // Let us open the postponed order.
      price = High[i] + limit * Point;
      SL    = price - StopLoss   * Point;
      TP    = price + TakeProfit * Point;      
      OrderSend(Symbol(), OP_BUYSTOP, Lots, price, 3, SL, TP, "OP_BUYSTOP", magicNumber, 0, Blue);
      
      Sleep(10000);
      
      // Let us open the basic order.
      SL = Bid + StopLoss   * Point;
      TP = Bid - TakeProfit * Point;
      OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, price, TP, "OP_SELL", magicNumber, 0, Blue);
   }

   // New minimum ?
   if ((iFractals_lo != 0) && (Time[i] != prev_min) && (i < 3) && (order_sell == false))
   {
      prev_min = Time[i];

      // Let us open the postponed order.
      price = Low[i] - limit * Point;
      SL    = price + StopLoss   * Point;
      TP    = price - TakeProfit * Point;
      OrderSend(Symbol(), OP_SELLSTOP, Lots, price, 3, SL, TP, "OP_SELLSTOP", magicNumber, 0, Blue);      

      Sleep(10000);

      SL = Ask - StopLoss   * Point;
      TP = Ask + TakeProfit * Point;
      OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, price, TP, "OP_BUY", magicNumber, 0, Yellow);
   }
   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 ---