Day Trading_PAMXA

Author: Copyright � 2009, SMERJ ORG
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyChecks for the total of closed orders
Indicators Used
Bill Williams Awesome oscillatorMovement directional indexStochastic oscillator
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
109.00 %
Total Trades 147
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 7.72
Gross Profit 13813.70
Gross Loss -12679.40
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
51.00 %
Total Trades 194
Won Trades 179
Lost trades 15
Win Rate 0.92 %
Expected payoff -42.42
Gross Profit 8627.50
Gross Loss -16857.50
Total Net Profit -8230.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
62.00 %
Total Trades 128
Won Trades 108
Lost trades 20
Win Rate 0.84 %
Expected payoff -39.16
Gross Profit 8040.00
Gross Loss -13052.40
Total Net Profit -5012.40
-100%
-50%
0%
50%
100%
Day Trading_PAMXA
//+------------------------------------------------------------------+
//|                                            Day Trading_PAMXA.mq4 |
//|                                      Copyright © 2009, SMERJ ORG |
//|                                            http://smerj.ucoz.org |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, SMERJ ORG"
#property link      "http://smerj.ucoz.org"

extern double TakeProfit = 25;
extern double Lots = 0;
extern double TrailingStop = 0;
extern double StopLoss = 50;
extern   bool     UseMM = true;
extern   bool     MicroAcct = false;
extern   double   Risk = 30;
double   var_96 = 0;
string   var_240 = "";

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  double stoc2k_0;
  double AO;
  double adx_0, adx_1;
  int cnt, ticket, total;

//server Time

Comment(var_240,"\nServer Time = ",TimeToStr(TimeCurrent(),TIME_MINUTES));
 
// initial data checks
   if(Bars<10)
     {
      Print("bars less than 10");
      return(0);  
     }
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return(0);
     }
     
// to simplify the coding and speed up access

AO=iAO(NULL,0,150);
adx_0=iADX(NULL,0,14,PRICE_TYPICAL,MODE_SIGNAL,0);
adx_1=iADX(NULL,0,14,PRICE_TYPICAL,MODE_SIGNAL,1);
stoc2k_0=iStochastic(NULL,0,5,3,3,MODE_SMA,NULL,MODE_MAIN,0);

// identifying open orders
   total=OrdersTotal();
   if(total<1)
   {
   if(AccountFreeMargin()<(1000*Lots))
   {
   Print("We have no money. Free Margin = ", AccountFreeMargin());
   return(0);  
   }
   
// check for long position (BUY) possibility
   if(AO<0 && adx_0 >= Ask && adx_1<adx_0 && stoc2k_0<20)
   {
   ticket=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,Ask+TakeProfit*Point,0,0,Green);
   if(ticket>0)
   Print("Day Trading_PAMXA Buying : ", Symbol());
   {
   if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
   } 
   return(0);
   }
   
// check for short position (SELL) possibility
   if(AO>0 && adx_0 >= Ask && adx_1<adx_0 && stoc2k_0>20)
   {
   ticket=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,Bid-TakeProfit*Point,0,0,Red);
   if(ticket>0)
   Print("Day Trading_PAMXA Selling : ", Symbol());
   {
   if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
   }
   return(0);
   }
   return(0);
   }
   
// control of open orders
   for(cnt=0;cnt<total;cnt++)
   {
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   if(OrderType()<=OP_SELL && 
   OrderSymbol()==Symbol())
   {
   if(OrderType()==OP_BUY)
   {

// long positions
   if(AO>0 && adx_0 >= Ask && adx_1<adx_0 && stoc2k_0>70)
   {
      OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
   return(0);
   }

// check for trailing stop
   if(TrailingStop>0)  
   {                 
   if(Bid-OrderOpenPrice()>Point*TrailingStop)
   {
   if(OrderStopLoss()<Bid-Point*TrailingStop)
   {
   OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
   return(0);
   }
   }
   }
   }
else

// short positions
   {
   if(AO<0 && adx_0 >= Ask && adx_1<adx_0 && stoc2k_0<35)
      {
   OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
   return(0);
   }

// check for trailing stop
   if(TrailingStop>0)  
   {                 
   if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
   {
   if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
   {
   OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
   return(0);
   }
   }
   }
   }
   }
   }
   return(0);
   }
   
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

double LotsOptimized()
{
if (UseMM == false) return(Lots);

double lots = Lots;
int    ordtotal = OrdersHistoryTotal();
int    losscnt = 0;
double var_LotsOptimized_16 = 0;
int    digits = 1;

if (MarketInfo(Symbol(),MODE_LOTSTEP) == 1.0) digits = 1;
if (MicroAcct == true) digits = 2;

lots = NormalizeDouble(AccountFreeMargin() * Risk / 100.0 / 1000.0,digits);

if (var_96 > 0.0)
   {
   for (int i = ordtotal - 1; i >= 0; i--)
      {
      if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == 0)
         {
         Print("Error in history!");
         break;
         }
      if ((OrderSymbol() != Symbol()) || (OrderType() > OP_SELL)) continue;
      if (OrderProfit() > 0.0) break;
      if (OrderProfit() < 0.0) losscnt++;
      }
   if (losscnt > 1) lots = NormalizeDouble(lots - lots * losscnt / var_96,1);
   }

if ((lots < 0.1) && (MicroAcct == false)) lots = 0.1;
if ((lots < 0.01) && (MicroAcct == true)) lots = 0.01;
if (lots > 50.0) lots = 50;
return(lots);
}

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 ---