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
25.00 %
Total Trades 1674
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -3.56
Gross Profit 1967.00
Gross Loss -7925.10
Total Net Profit -5958.10
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
10.00 %
Total Trades 514
Won Trades 292
Lost trades 222
Win Rate 0.57 %
Expected payoff -7.79
Gross Profit 450.10
Gross Loss -4452.20
Total Net Profit -4002.10
-100%
-50%
0%
50%
100%
sovetnik
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

extern double Lots         = 0.1;   // Âåëè÷èíà ëîòà
extern int    MinProfit    = 10;    // Ïðèáûëü â ïóíêòàõ 
extern int    Step         = 0;   

double step;
int magic=3485632;

//+------------------------------------------------------------------+
int start(){

 int oo=0;
 double slp=99999,shp=0;
 double blp=99999,bhp=0;
 int bprofit=0,sprofit=0;
 int j=OrdersTotal()-1;
 for(int i=j;i>=0;i--){
  OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
  if(Symbol()==OrderSymbol() && magic==OrderMagicNumber() && OrderType()==OP_BUY){
   oo++;
   if(OrderOpenPrice()<blp) blp=OrderOpenPrice();
   if(OrderOpenPrice()>bhp) bhp=OrderOpenPrice();
   bprofit=bprofit+MathRound((OrderProfit()+OrderSwap())/MarketInfo(Symbol(),MODE_TICKVALUE)/MarketInfo(Symbol(),MODE_MINLOT));
  }
  if(Symbol()==OrderSymbol() && magic==OrderMagicNumber() && OrderType()==OP_SELL){
   oo++;
   if(OrderOpenPrice()<slp) slp=OrderOpenPrice();
   if(OrderOpenPrice()>shp) shp=OrderOpenPrice();
   sprofit=sprofit+MathRound((OrderProfit()+OrderSwap())/MarketInfo(Symbol(),MODE_TICKVALUE)/MarketInfo(Symbol(),MODE_MINLOT));
  }
 }
 
 Comment("Áàé Ïðîôèò=", bprofit," blp=", blp," bhp=",bhp," blp-step=",blp-step," bhp+step=",bhp+step,
         "\nÑåë Ïðîôèò=", sprofit," slp=", slp," shp=",shp," slp-step=",slp-step," shp+step=",shp+step);
 
 if(oo==0){
  RefreshRates();
  OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"pio_pir_buy",magic,0,Blue);
  OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"pio_pir_sell",magic,0,Magenta);
 }
 
 if(bprofit>=MinProfit){
  j=OrdersTotal()-1;
  for(i=j;i>=0;i--){
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   RefreshRates();
   if(Symbol()==OrderSymbol() && magic==OrderMagicNumber() && OrderType()==OP_BUY)
    OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
  }
 }

 if(sprofit>=MinProfit){
  j=OrdersTotal()-1;
  for(i=j;i>=0;i--){
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   RefreshRates();
   if(Symbol()==OrderSymbol() && magic==OrderMagicNumber() && OrderType()==OP_SELL)
    OrderClose(OrderTicket(),OrderLots(),Ask,3,Magenta);
  }
 }

 RefreshRates();
 if (Step==0) {step=(Ask-Bid)*2;} else {step=Step*Point;}
 
 RefreshRates();
 if(blp-step>=Bid)
  OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"pio_pir_buy",magic,0,Blue);
// if(bhp+step<=Bid)
//  OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"pio_pir_buy",magic,0,Blue);
// if(slp-step>=Ask)
//  OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"pio_pir_sell",magic,0,Magenta);
 if(shp+step<=Ask)
  OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"pio_pir_sell",magic,0,Magenta);

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