Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
77.00 %
Total Trades 127
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.73
Gross Profit 720.00
Gross Loss -940.00
Total Net Profit -220.00
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
0.00 %
Total Trades 130
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -14.45
Gross Profit 0.00
Gross Loss -1878.44
Total Net Profit -1878.44
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
70.00 %
Total Trades 130
Won Trades 79
Lost trades 51
Win Rate 0.61 %
Expected payoff -2.38
Gross Profit 711.00
Gross Loss -1020.00
Total Net Profit -309.00
-100%
-50%
0%
50%
100%
weekly_Day
//*/
//2 îðäåðà â ñóòêè.mq4
//© 2003-2006 Mandor ®
//E-mail: mandorr@gmail.com
//Ðåçóëüòàò ðàáîòû ñîâåòíèêà íå çàâèñèò îò èñïîëüçóåìîãî ïåðèîäà
// íà÷àëå ÷àñà StartHour óñòàíàâëèâàþòñÿ íîâûå îòëîæåííûå îðäåðà
//Range: ðàññòîÿíèå îò òåêóùåé öåíû äî öåíû îòëîæåííîãî îðäåðà
//OrderExpirationDays: âðåìÿ æèçíè îòëîæåííîãî îðäåðà â äíÿõ
//UseMM: èñïîëüçîâàòü Money Management. Ðåêîìåíäóåòñÿ âêëþ÷èòü (UseMM=true)
//PercentMM: ïðîöåíò îò ñâîáîäíûõ ñðåäñòâ äëÿ âû÷èñëåíèÿ íîâîé ïîçèöèè
//MinLots: ìèíèìàëüíî äîïóñòèìûé ðàçìåð ïîçèöèè ó äèëåðà
//MinStop: ìèíèìàëüíî äîïóñòèìîå ðàññòîÿíèå îò òåêóùåé öåíû äî îòëîæåííîãî îðäåðà, ñòîï ëîññà èëè òåéê ïðîôèòà ó äèëåðà
//ShiftGMT: âðåìÿ äèëåðà ìèíóñ âðåìÿ ïî Ãðèíâè÷ó (äëÿ Alpari = 1, äëÿ FXTeam = 2, äëÿ FIBO = 1, äëÿ LiteForex = 2)
//*/


// Parametres
extern int StartHour=13;
extern int Range=40;
extern int TakeProfit=90;
extern int StopLoss=200;
extern double Lots=0.1;
extern double OrderExpirationDays=7;
extern bool UseMM=false;
extern int PercentMM=20;
extern double MinLots=0.1;
extern int MinStop=11;
extern int ShiftGMT=1;


// Variables
int result;
int err;
int i;
int hour;
int set_buy_stop=0;
int set_sell_stop=0;
double volume;
double range;
double price;
double loss;
double profit;


// When new quotations are received this function is executed
void start()
   {
   if (Bars<100 || IsTradeAllowed()==false) return;
   if (Range<=0 || ShiftGMT<-23 || ShiftGMT>23) return;
   if (DeleteOldOrders()>0) return;
   hour=Hour()-ShiftGMT;
   if (hour==StartHour)
      {
      if (set_buy_stop==0 && TotalBuyStop()==0)
         {
         if (SetBuyStop()>0) {set_buy_stop=1; return;}
         }
      if (set_sell_stop==0 && TotalSellStop()==0)
         {
         if (SetSellStop()>0) {set_sell_stop=1; return;}
         }
      }
   else
      {
      set_buy_stop=0;
      set_sell_stop=0;
      }
   }


// Deleting of old pending orders
int DeleteOldOrders()
   {
   result=0;
   for (i=0;i<OrdersTotal();i++)
      {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderType()!=OP_BUYSTOP && OrderType()!=OP_SELLSTOP) continue;
      if (CurTime()-OrderOpenTime()<86400*OrderExpirationDays) continue;
         {
         if (OrderDelete(OrderTicket())) result=1;
         else {err=GetLastError(); Print("Delete of pending order failed with error #",err);}
         break;
         }
      }
   return(result);
   }


// Set a Buy Stop order
int SetBuyStop()
   {
   result=0;
   volume=LotsCounting();
   if (Range<MinStop) range=MinStop*Point; else range=Range*Point; 
   price=Ask+range;
   loss=0; if (StopLoss>0) loss=price-StopLoss*Point;
   profit=0; if (TakeProfit>0) profit=price+TakeProfit*Point;
   if (OrderSend(Symbol(),OP_BUYSTOP,volume,price,0,loss,profit,"Open by expert",0,0)>0) result=1;
   else {err=GetLastError(); Print("Set a pending order failed with error #",err);}
   return(result);
   }


// Set a Sell Stop order
int SetSellStop()
   {
   result=0;
   volume=LotsCounting();
   if (Range<MinStop) range=MinStop*Point; else range=Range*Point; 
   price=Bid-range;
   loss=0; if (StopLoss>0) loss=price+StopLoss*Point;
   profit=0; if (TakeProfit>0) profit=price-TakeProfit*Point;
   if (OrderSend(Symbol(),OP_SELLSTOP,volume,price,0,loss,profit,"Open by expert",0,0)>0) result=1;
   else {err=GetLastError(); Print("Set a pending order failed with error #",err);}
   return(result);
   }


// Buy Stop count
int TotalBuyStop()
   {
   result=0;
   for(i=0;i<OrdersTotal();i++)
      {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if (OrderSymbol()!=Symbol()) continue;
      if (TimeDay(OrderOpenTime())!=Day()) continue;
      if (OrderType()==OP_BUYSTOP ) result++;
      }
   return(result);
   }


// Sell Stop count
int TotalSellStop()
   {
   result=0;
   for(i=0;i<OrdersTotal();i++)
      {
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if (OrderSymbol()!=Symbol()) continue;
      if (TimeDay(OrderOpenTime())!=Day()) continue;
      if (OrderType()==OP_SELLSTOP) result++;
      }
   return(result);
   }


// Account lots
double LotsCounting()
   {
   volume=Lots;
   if (UseMM) volume=NormalizeDouble((PercentMM*AccountFreeMargin()/100000),1);
   if (volume<MinLots) volume=MinLots;
   return(volume);
   }


// End

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