Download MetaTrader 5

Why this simple expert goes on lose? When is downtrent ;)

To add comments, please log in or register
persy5
18
persy5  
//+------------------------------------------------------------------+
//|                                                            3.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
#include <Trade/Trade.mqh>
#include <Trade/PositionInfo.mqh>
#include <Trade/OrderInfo.mqh>

CTrade m_Trade;
CPositionInfo m_Position;
COrderInfo m_Order;
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
if( !(PositionsTotal() || OrdersTotal())){
   double xxx = SymbolInfoDouble(_Symbol,SYMBOL_BID);
    m_Trade.Sell(0.1,_Symbol,xxx,xxx+0.001,xxx-0.001);
    }
  }
//+------------------------------------------------------------------+
//| Tester function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//---
   double ret=0.0;
//---

//---
   return(ret);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
Alain Verleyen
Moderator
33629
Alain Verleyen  
persy5:
Because your SL is hit before your TP more often than reverse.
To add comments, please log in or register