DayTrading2

Author: Copyright � 2005, NazFunds Company
Profit factor:
0.30
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Indicators Used
MACD HistogramStochastic oscillatorParabolic Stop and Reverse systemMomentum indicator
Miscellaneous
It issuies visual alerts to the screen
11 Views
0 Downloads
0 Favorites
DayTrading2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                   DayTrading.mq4 |
//|                               Copyright © 2005, NazFunds Company |
//|                                          http://www.nazfunds.com |
//|                                Translated/updated to MT4: Turcol |
//|                 Use it on 5 min charts with 20/pips profit limit |
//|        Do not place any stop loss. No worries, check the results |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, NazFunds Company"
#property link      "http://www.nazfunds.com"
#include <stdlib.mqh>

extern double lots         = 0.1;           // 
extern double trailingStop = 15;            // trail stop in points
extern double takeProfit   = 20;            // recomended  no more than 20
extern double stopLoss     = 0;             // do not use s/l
extern double slippage     = 3;             // Could be higher with some brokers
extern string nameEA       = "DayTrading";  // To "easy read" which EA place an specific order
extern int magicEA         = 19000;         // Magic EA identifier. Allows for several co-existing EA with different input values

double macdHistCurrent, macdHistPrevious, macdSignalCurrent, macdSignalPrevious;
double stochHistCurrent, stochHistPrevious, stochSignalCurrent, stochSignalPrevious;
double sarCurrent, sarPrevious, momCurrent, momPrevious;
double realTP, realSL;
bool isBuying = false, isSelling = false, isClosing = false;
int cnt, ticket;

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

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

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   // Check for invalid bars and takeprofit
   if(Bars < 200) {
      Print("Not enough bars for this strategy - ", nameEA);
      return(0);
   }
   calculateIndicators();                      // Calculate indicators' value   
   
   // Control open trades
   int totalOrders = OrdersTotal();
   int numPos = 0;
      
   for(cnt=0; cnt<totalOrders; cnt++) {        // scan all orders and positions...
      OrderSelect(cnt, SELECT_BY_POS);         // the next line will check for ONLY market trades, not entry orders
      if(OrderSymbol() == Symbol() && OrderType() <= OP_SELL && OrderMagicNumber() == magicEA) {   // only look for this symbol, and only orders from this EA      
         numPos++;
         if(OrderType() == OP_BUY) {           // Check for close signal for bought trade
            if(isSelling || isClosing) {
               OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Violet);   // Close bought trade
               prtAlert("Day Trading: Closing BUY order");
            }         
            if(trailingStop > 0) {             // Check trailing stop
               if(Bid-OrderOpenPrice() > trailingStop*Point) {
                  if(OrderStopLoss() < (Bid - trailingStop*Point)) {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-trailingStop*Point,OrderTakeProfit(),0,Blue);
                     prtAlert("Day Trading: Modifying BUY order");
                  }
               }
            }
         } else {                              // Check sold trade for close signal
            if(isBuying || isClosing) {
               OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Violet);
               prtAlert("Day Trading: Closing SELL order");
            }
            if(trailingStop > 0) {             // Control trailing stop
               if(OrderOpenPrice() - Ask > trailingStop*Point) {
                  if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + trailingStop*Point) {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+trailingStop*Point,OrderTakeProfit(),0,Red);
                     prtAlert("Day Trading: Modifying SELL order");
                  }
               }           
            } 
         }
      }
   }
   
   // If there is no open trade for this pair and this EA
   if(numPos < 1) {   
      if(AccountFreeMargin() < 1000*lots) {
         Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA);
         return(0);
      }
      if(isBuying && !isSelling && !isClosing) {  // Check for BUY entry signal
         if(stopLoss > 0)
            realSL = Ask - stopLoss * Point;
         if(takeProfit > 0)
            realTP = Ask + takeProfit * Point;
         ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,realSL,realTP,nameEA+" - Magic: "+magicEA+" ",magicEA,0,Red);  // Buy
         if(ticket < 0) {
            Print("OrderSend (" + nameEA + ") failed with error #" + GetLastError() + " --> " + ErrorDescription(GetLastError()));
         } else {
            prtAlert("Day Trading: Buying"); 
         }
      }
      if(isSelling && !isBuying && !isClosing) {  // Check for SELL entry signal
         if(stopLoss > 0)
            realSL = Bid + stopLoss * Point;
         if(takeProfit > 0)
            realTP = Bid - takeProfit * Point;
         ticket = OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,realSL,realTP,nameEA+" - Magic: "+magicEA+" ",magicEA,0,Red); // Sell
         if(ticket < 0) {
            Print("OrderSend (" + nameEA + ") failed with error #" + GetLastError() + " --> " + ErrorDescription(GetLastError()));
         } else {
            prtAlert("Day Trading: Selling"); 
         }
      }
   }
   return(0);
}

void calculateIndicators() {    // Calculate indicators' value   
   macdHistCurrent     = iMACD(NULL,0,12,26,9,PRICE_OPEN,MODE_MAIN,0);   
   macdHistPrevious    = iMACD(NULL,0,12,26,9,PRICE_OPEN,MODE_MAIN,1);   
   macdSignalCurrent   = iMACD(NULL,0,12,26,9,PRICE_OPEN,MODE_SIGNAL,0); 
   macdSignalPrevious  = iMACD(NULL,0,12,26,9,PRICE_OPEN,MODE_SIGNAL,1); 
   stochHistCurrent    = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0);
   stochHistPrevious   = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1);
   stochSignalCurrent  = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);
   stochSignalPrevious = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,1);
   sarCurrent          = iSAR(NULL,0,0.02,0.2,0);           // Parabolic Sar Current
   sarPrevious         = iSAR(NULL,0,0.02,0.2,1);           // Parabolic Sar Previuos
   momCurrent          = iMomentum(NULL,0,14,PRICE_OPEN,0); // Momentum Current
   momPrevious         = iMomentum(NULL,0,14,PRICE_OPEN,1); // Momentum Previous
   
   // Check for BUY, SELL, and CLOSE signal
   isBuying  = (sarCurrent<=Ask && sarPrevious>sarCurrent && momCurrent<100 && macdHistCurrent<macdSignalCurrent && stochHistCurrent<35);
   isSelling = (sarCurrent>=Bid && sarPrevious<sarCurrent && momCurrent>100 && macdHistCurrent>macdSignalCurrent && stochHistCurrent>60);
   isClosing = false;
}

void prtAlert(string str = "") {
   Print(Symbol() + " - " + str);
   Alert(Symbol() + " - " + str);
   // SpeechText(addSpaces(Symbol()) + " - " + str,SPEECH_ENGLISH);
   // SendMail(Symbol(),str);
}

//string addSpaces(string str = "") {
//   int length = StringLen(str);
//   string sp  = "";
//   for(int i=0; i<length; i++)
//      sp = sp + StringSubstr(str,i,1) + " ";
//   return (sp);
//}
//+------------------------------------------------------------------+

Profitability Reports

GBP/CAD Jan 2025 - Jul 2025
2.50
Total Trades 35
Won Trades 34
Lost trades 1
Win Rate 97.14 %
Expected payoff 0.78
Gross Profit 45.44
Gross Loss -18.19
Total Net Profit 27.25
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
2.23
Total Trades 14
Won Trades 13
Lost trades 1
Win Rate 92.86 %
Expected payoff 0.81
Gross Profit 20.50
Gross Loss -9.20
Total Net Profit 11.30
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.81
Total Trades 14
Won Trades 13
Lost trades 1
Win Rate 92.86 %
Expected payoff -0.45
Gross Profit 26.10
Gross Loss -32.36
Total Net Profit -6.26
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.52
Total Trades 15
Won Trades 14
Lost trades 1
Win Rate 93.33 %
Expected payoff -1.75
Gross Profit 28.00
Gross Loss -54.30
Total Net Profit -26.30
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.49
Total Trades 17
Won Trades 16
Lost trades 1
Win Rate 94.12 %
Expected payoff -1.74
Gross Profit 28.10
Gross Loss -57.60
Total Net Profit -29.50
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.37
Total Trades 19
Won Trades 18
Lost trades 1
Win Rate 94.74 %
Expected payoff -2.48
Gross Profit 28.20
Gross Loss -75.40
Total Net Profit -47.20
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.32
Total Trades 7
Won Trades 6
Lost trades 1
Win Rate 85.71 %
Expected payoff -4.56
Gross Profit 14.98
Gross Loss -46.91
Total Net Profit -31.93
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.16
Total Trades 14
Won Trades 12
Lost trades 2
Win Rate 85.71 %
Expected payoff -5.82
Gross Profit 16.06
Gross Loss -97.57
Total Net Profit -81.51
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.15
Total Trades 16
Won Trades 15
Lost trades 1
Win Rate 93.75 %
Expected payoff -5.86
Gross Profit 17.14
Gross Loss -110.93
Total Net Profit -93.79
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.11
Total Trades 33
Won Trades 31
Lost trades 2
Win Rate 93.94 %
Expected payoff -9.55
Gross Profit 38.80
Gross Loss -353.79
Total Net Profit -314.99
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.09
Total Trades 19
Won Trades 17
Lost trades 2
Win Rate 89.47 %
Expected payoff -8.03
Gross Profit 14.97
Gross Loss -167.55
Total Net Profit -152.58
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.08
Total Trades 8
Won Trades 7
Lost trades 1
Win Rate 87.50 %
Expected payoff -14.03
Gross Profit 10.10
Gross Loss -122.30
Total Net Profit -112.20
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.07
Total Trades 9
Won Trades 7
Lost trades 2
Win Rate 77.78 %
Expected payoff -18.31
Gross Profit 12.20
Gross Loss -177.00
Total Net Profit -164.80
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.05
Total Trades 26
Won Trades 24
Lost trades 2
Win Rate 92.31 %
Expected payoff -23.77
Gross Profit 31.11
Gross Loss -649.23
Total Net Profit -618.12
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.05
Total Trades 36
Won Trades 29
Lost trades 7
Win Rate 80.56 %
Expected payoff -17.81
Gross Profit 35.39
Gross Loss -676.69
Total Net Profit -641.30
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.04
Total Trades 10
Won Trades 8
Lost trades 2
Win Rate 80.00 %
Expected payoff -22.09
Gross Profit 10.06
Gross Loss -230.95
Total Net Profit -220.89
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.00
Total Trades 13
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 1.62
Gross Profit 21.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.00
Total Trades 32
Won Trades 32
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.66
Gross Profit 53.20
Gross Loss 0.00
Total Net Profit 53.20
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.00
Total Trades 29
Won Trades 29
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.68
Gross Profit 48.80
Gross Loss 0.00
Total Net Profit 48.80
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.00
Total Trades 26
Won Trades 26
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.64
Gross Profit 42.70
Gross Loss 0.00
Total Net Profit 42.70
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.00
Total Trades 35
Won Trades 35
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.13
Gross Profit 39.71
Gross Loss 0.00
Total Net Profit 39.71
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 5
Won Trades 5
Lost trades 0
Win Rate 100.00 %
Expected payoff 2.00
Gross Profit 10.00
Gross Loss 0.00
Total Net Profit 10.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.00
Total Trades 6
Won Trades 6
Lost trades 0
Win Rate 100.00 %
Expected payoff 2.00
Gross Profit 12.00
Gross Loss 0.00
Total Net Profit 12.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 13
Won Trades 13
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.27
Gross Profit 16.56
Gross Loss 0.00
Total Net Profit 16.56
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.00
Total Trades 24
Won Trades 24
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.77
Gross Profit 42.50
Gross Loss 0.00
Total Net Profit 42.50
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.00
Total Trades 18
Won Trades 18
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.72
Gross Profit 30.90
Gross Loss 0.00
Total Net Profit 30.90
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 27
Won Trades 27
Lost trades 0
Win Rate 100.00 %
Expected payoff 1.36
Gross Profit 36.71
Gross Loss 0.00
Total Net Profit 36.71
-100%
-50%
0%
50%
100%

Comments