Author: fortrader
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
30.00 %
Total Trades 3076
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.55
Gross Profit 2045.00
Gross Loss -6803.10
Total Net Profit -4758.10
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
12.00 %
Total Trades 2425
Won Trades 1255
Lost trades 1170
Win Rate 0.52 %
Expected payoff -3.63
Gross Profit 1255.00
Gross Loss -10052.00
Total Net Profit -8797.00
-100%
-50%
0%
50%
100%
10pips
//+------------------------------------------------------------------+
//|                                                       10pips.mq4 |
//|                                                        fortrader |
//|                                                 www.fortrader.ru |
//+------------------------------------------------------------------+
#property copyright "fortrader"
#property link      "www.fortrader.ru"

extern int       TakeProfit_Buy = 10;
extern int       StopLoss_Buy = 50;
extern int       TrailingStop_Buy = 50;
extern int       TakeProfit_Sell = 10;
extern int       StopLoss_Sell = 50;
extern int       TrailingStop_Sell = 50;
extern double     Lots = 0.1;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
  if (Volume[0] > 1) return(0);
// Îáúÿâëÿåì ïåðåìåííûå
int total, cnt;

  total=OrdersTotal();

  // Ïðîâåðêà ñðåäñòâ
  if(AccountFreeMargin()<(1000*Lots))
     {
       Print("We have no money. Free Margin = ", AccountFreeMargin());   
       return(0);  
     }
  if(total<1)
    {  
     // Îòêðûòèå ñäåëêîê
       OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss_Buy*Point,Ask+TakeProfit_Buy*Point,"Ïîêóïàåì",16384,0,Green);
       Sleep(10000);//10 ñåêóíä
       RefreshRates();
       OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss_Sell*Point,Bid-TakeProfit_Sell*Point,"Ïðîäàåì",16385,0,Red);
    }
  if(total==1)
    {
       OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
       if(OrderType()==OP_BUY)
         {
           OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss_Buy*Point,Ask+TakeProfit_Buy*Point,"Ïîêóïàåì",16384,0,Green);
         }
       if(OrderType()==OP_SELL)
         {
           OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss_Sell*Point,Bid-TakeProfit_Sell*Point,"Ïðîäàåì",16385,0,Red);
         }
    }   
  for(cnt=total-1;cnt>=0;cnt--)
     {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if(OrderType()==OP_BUY)
         {
           if(TrailingStop_Buy>0)  
             {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop_Buy) // Bid - öåíà ïîêóïêè
                 {
                   if(OrderStopLoss()<Bid-Point*TrailingStop_Buy)
                     {
                       OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop_Buy,OrderTakeProfit(),0,Green);
                       return(0);
                     }
                 }
             }
         }
       if(OrderType()==OP_SELL)
         {
           if(TrailingStop_Sell>0)  
             {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop_Sell))  // Ask - öåíà ïðîäàæè
                 {
                   if((OrderStopLoss()>(Ask+Point*TrailingStop_Sell)) || (OrderStopLoss()==0))
                     {
                       OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop_Sell,OrderTakeProfit(),0,Red);
                       return(0);
                     }
                 }
             }
         }
  
     }
   
//----
   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 ---