HedgeHogUltra_v1

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
54.00 %
Total Trades 100
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -5.89
Gross Profit 686.00
Gross Loss -1275.00
Total Net Profit -589.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
12.00 %
Total Trades 203
Won Trades 34
Lost trades 169
Win Rate 0.17 %
Expected payoff -18.40
Gross Profit 490.00
Gross Loss -4225.00
Total Net Profit -3735.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
50.00 %
Total Trades 130
Won Trades 61
Lost trades 69
Win Rate 0.47 %
Expected payoff -6.70
Gross Profit 854.00
Gross Loss -1725.00
Total Net Profit -871.00
-100%
-50%
0%
50%
100%
HedgeHogUltra_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                         HedgeHog |
//|                                     Copyright © 2006, Milan Volf |
//|                                                 milan@mmtop.info |
//+------------------------------------------------------------------+

//---- input parameters
extern int       Start=0;
extern int       Pips=14;
extern int       StopLoss=25;
extern int       TakeProfit=14;
extern int       PO_Mode=0; //Mode Pending Orders / 0-close when opposite is actived / 1-close at 23:55
extern double    Lots=1;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   //---- 
   int i,j,Ticket,StartTime,Bought=0,Sold=0,Closed;
   double Vol;
   string Text;
   
   //Setup comment
   Text="HH"+Symbol();

   //Check orders if any of them is actived
   if(PO_Mode==0){
      for (i=0;i<OrdersTotal();i++){
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderComment()==Text && OrderType()==OP_BUY) Bought++;
         if(OrderComment()==Text && OrderType()==OP_SELL) Sold++;
      }
      if(Bought==1 || Sold==1){ //delete opposite pending order when one is actived
         for (j=0;j<OrdersTotal();j++){
            OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
            if(OrderComment()==Text && (OrderType()==OP_SELLSTOP || OrderType()==OP_BUYSTOP)){
               OrderDelete(OrderTicket());
               PlaySound("expert.wav");
               Sleep(10000);
            }
         }
      }
   }
   //send pending orders if there isn't any
   if(CurTime()>= StrToTime(Start+":00") && CurTime()<StrToTime(Start+":00")+300){
      //Check Orders
      for (i=0;i<OrdersTotal();i++){
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderComment()==Text && OrderType()==OP_BUYSTOP && OrderOpenTime()>CurTime()-3600) Bought++;
         if(OrderComment()==Text && OrderType()==OP_SELLSTOP && OrderOpenTime()>CurTime()-3600) Sold++;
      }
      if(Bought==0){ //no buy order
         if(GlobalVariableGet("Closed")==1) Vol=2*Lots; else Vol=Lots;
         Ticket=OrderSend(Symbol(),OP_BUYSTOP,Vol,Ask+Pips*Point,3,Ask+(Pips-StopLoss)*Point,Ask+(Pips+TakeProfit)*Point,Text,0,0,Green);
         PlaySound("expert.wav");
         Sleep(10000);
      }
      if(Sold==0){ //no sell order
         if(GlobalVariableGet("Closed")==2) Vol=2*Lots; else Vol=Lots;
         OrderSend(Symbol(),OP_SELLSTOP,Vol,Bid-Pips*Point,3,Bid+(StopLoss-Pips)*Point,Bid-(Pips+TakeProfit)*Point,Text,0,0,Green);
         PlaySound("expert.wav");
         Sleep(10000);
      }
      if(GlobalVariableCheck("Closed")) GlobalVariableDel("Closed");
   }

   //Manage opened orders
   for (i=0;i<OrdersTotal();i++){
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      //close open position after 2 days
      if(OrderComment()==Text && CurTime()>=OrderOpenTime()+2*24*3600-300){
         if(OrderType()==OP_BUY){
            OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
            PlaySound("expert.wav");
            GlobalVariableSet("Closed",1);
            Sleep(10000);
         }
         if(OrderType()==OP_SELL){
            OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
            PlaySound("expert.wav");
            GlobalVariableSet("Closed",2);
            Sleep(10000);
         }
      }
      if(PO_Mode==1){
         if(CurTime()>StrToTime("23:55")){
            if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP){
               OrderDelete(OrderTicket());
               PlaySound("expert.wav");
               GlobalVariableSet("Closed",1);
               Sleep(10000);
            }
         }
      }
   }
   
   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 ---