20-pips-per-day_v1.2

Author: Copyright � 2007, LEGRUPO Version 1.2
Price Data Components
Series array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each bar
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

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
20.00 %
Total Trades 2246
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.46
Gross Profit 801.80
Gross Loss -4090.00
Total Net Profit -3288.20
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
20-pips-per-day_v1.2
//+------------------------------------------------------------------+
//|                                              20-pips-per-day.mq4 |
//|                                        Copyright © 2007, LEGRUPO |
//|                                           http://www.legrupo.com |
//|                                                     Version: 1.2 |
//| History:                                                         |
//| 1.0 => Release version to the public                             |
//| 1.1 =>  bugs fixed by Dave (dmieluk@exemail.com.au):             |
//|         1) StopLoss was wrong;                                   |
//|         2) StopLoss was conflicting with each other;             |
//|         3) The is_able_to_continue is now much better coded;     |
//|         3.1) The is_able_to_continue now works on any pair;      |
//|         4) Now the errors have descriptions instead of numbers.  |
//| 1.2 => LASTRUN now is display in human readable format by Dave.  |
//+------------------------------------------------------------------+

#include <stderror.mqh>
#include <stdlib.mqh>

#property copyright "Copyright © 2007, LEGRUPO Version 1.2"
#property link      "http://www.legrupo.com"

extern double TakeProfit = 40;
extern double StopLoss = 20;
extern double StopAndReverseOnLossOf = 100;
extern int MinimumToContinue = 100; // pips the daily bar must have
extern double LotSize = 0.1;
extern double Slippage = 15;
extern string BuyComment = "20 pips per day BUY";
extern string SellComment = "20 pips per day SELL";
extern color clOpenBuy = Blue;
extern color clOpenSell = Red;
static int LASTRUN_v1_1; // verifica se uma nova bar for aberta
int ticket_buy, ticket_sell = 0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
int total_orders = OrdersTotal();

if (LASTRUN_v1_1==Time[0])
   return(0);
   LASTRUN_v1_1 = Time[0];
    Alert("EA Start 20-pips-per-day:", TimeDay(LASTRUN_v1_1),"/",TimeMonth(LASTRUN_v1_1),"/",TimeYear(LASTRUN_v1_1));
    
   double curr_open = iOpen(NULL, 0, 0);
   double last_high = iHigh(NULL, 0, 1);
   double last_low = iLow(NULL, 0, 1);
   double last_close = iClose(NULL, 0, 1);
   
   double is_able_to_continue = (last_high - last_low)*MathPow(10,Digits);

   Print("is_able_to_continue: ", is_able_to_continue);
   if (is_able_to_continue < MinimumToContinue) {
      return(0);
   }

   //if (total_orders == 0) {
      ticket_buy = OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage,Ask-(StopLoss*Point),Ask+(TakeProfit*Point),BuyComment,0,0,clOpenBuy);
      if (ticket_buy < 0) {
            Alert("Open BUY order error: ", ErrorDescription(GetLastError()));
      }
      
      ticket_sell = OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slippage,Bid+(StopLoss*Point),Bid-(TakeProfit*Point),SellComment,0,0,clOpenSell); 
      if (ticket_sell < 0) {
            Alert("Open SELL order error: ", ErrorDescription(GetLastError()));
      }
   //}
//----
   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 ---