Author: space_cowboy
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
144.00 %
Total Trades 20
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 57.10
Gross Profit 3751.00
Gross Loss -2609.00
Total Net Profit 1142.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
113.00 %
Total Trades 14
Won Trades 10
Lost trades 4
Win Rate 0.71 %
Expected payoff 36.57
Gross Profit 4441.00
Gross Loss -3929.00
Total Net Profit 512.00
-100%
-50%
0%
50%
100%
Pipso
//+------------------------------------------------------------------+
//|                                                           MC.mq4 |
//|                                                     space_cowboy |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "space_cowboy"
#property link      "http://www.metaquotes.net"

//---- input parameters
extern int start=21;//÷àñ íà÷àëà ðàáîòû
extern int end=9;//÷àñ îêîí÷àíèÿ ðàáîòû (ïëþñ ê íà÷àëüíîìó)
extern int period=36; //ïåðèîä äëÿ ïîñòîðîåíèÿ êàíàëà â áàðàõ
extern double SLpp=300; //ñòîï â ïðîöåíòàõ îò ðàçìàõà êàíàëà

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int spread, stoplevel, freeze;
int handle;
int init()
  {
//----
  stoplevel=MarketInfo(Symbol(), MODE_STOPLEVEL)+1;
  spread=MarketInfo(Symbol(), MODE_SPREAD);
  freeze=MarketInfo(Symbol(), MODE_FREEZELEVEL)+1; 
  SLpp/=100;

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int tmp, tc, st, et, dtmp;
int objs=0;
double high, low, raz;
bool op=false, work=false;
int start()
  {
//----
  tc=TimeCurrent(); 
  //***********************
  int d1bars=iBars(NULL,PERIOD_D1);
  if(tc>=et)
   { 
   if(dtmp!=d1bars)
    {
    int dow=0;
    if(start+end > 24) {dow=DayOfWeek();}
    int dt=iTime(NULL,PERIOD_D1,0);
    st=dt+start*3600;
    et=dt+(start+end)*3600;
    if(dow==5) et+=172800;
    }
   dtmp=d1bars; 
   }
   
  if(tc>=st && tc<=et) work=true; 
  else work=false;
  //***********************


   if(tmp!=Bars)
    {
    high=High[iHighest(NULL,0,MODE_HIGH,period,1)];
    low=Low[iLowest(NULL,0,MODE_LOW,period,1)];
    raz=((high-low)/Point)*SLpp;
    if(raz<stoplevel) raz=stoplevel;
    }
   tmp=Bars; 
   
   if(Bid>=high)
    {
    close_all(true);
    if(work && OrdersTotal()==0) sell();
    }
    
   if(Bid<=low)
    {
    close_all(false);
    if(work && OrdersTotal()==0) buy();
    } 
//----
   return(0);
  }
//+------------------------------------------------------------------+
int sell()
{
int t=-1;
t=OrderSend(Symbol(),OP_SELL,1,Bid,0,NormalizeDouble(Ask+raz*Point, Digits),0,"order_sell",29072007,0,0x0000FF);
return(t);
}

int buy()
{
int t=-1;
t=OrderSend(Symbol(),OP_BUY,1,Ask,0,NormalizeDouble(Bid-raz*Point, Digits),0,"order_buy",19072007,0,0xFF0000);
return(t);
}

void close_all(bool fl)
{
int tot=OrdersTotal();
for(int i=0;i<tot;i++)
 {
 OrderSelect(i,SELECT_BY_POS);
 if(OrderType()==0 && fl) OrderClose(OrderTicket(),OrderLots(),Bid,0);
 if(OrderType()==1 && !fl) OrderClose(OrderTicket(),OrderLots(),Ask,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 ---