bless_FiFtHeLeMeNt_noTG_1.0.1

Author: Copyright � 2007, FiFtHeLeMeNt.
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
18.00 %
Total Trades 146
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -35.94
Gross Profit 1128.20
Gross Loss -6375.90
Total Net Profit -5247.70
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
14.00 %
Total Trades 139
Won Trades 76
Lost trades 63
Win Rate 0.55 %
Expected payoff -56.00
Gross Profit 1297.30
Gross Loss -9081.50
Total Net Profit -7784.20
-100%
-50%
0%
50%
100%
bless_FiFtHeLeMeNt_noTG_1.0.1
//+------------------------------------------------------------------+
//|                                    bless_FiFtHeLeMeNt_noTG_1.0.1 |
//|                                   Copyright © 2007, FiFtHeLeMeNt |
//|                                         fifthelement80@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, FiFtHeLeMeNt."
#property link      "http://www.irxfx.com"

extern int MinGS=20;
extern int TP=27;
extern double lot=0.1;
extern int MaxTrades=7;

int magic;
double lot2;
datetime tob,tos; //Time Out Buy & Sell

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----


   
//----
   return(0);
  }
  
int init()
  {
   if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") { magic = 211001; }
   if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") { magic = 211002; }
   if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") { magic = 211003; }
   if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") { magic = 211004; }
   if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") { magic = 211005; }
   if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") { magic = 211006; }
   if (Symbol() == "EURCADm" || Symbol() == "EURCAD") { magic = 211007; }
   if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") { magic = 211008; }
   if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") { magic = 211009; }
   if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") { magic = 211010; }
   if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") { magic = 211011; }
   if (Symbol() == "GBPCHFm" || Symbol() == "GBPCHF") { magic = 211012; }
   if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") { magic = 211013; }
   if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") { magic = 211014; }
   if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") { magic = 211015; }
   if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") { magic = 211016; }
   if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") { magic = 211017; }
   if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") { magic = 211018; }
   if (Symbol() == "USDCADm" || Symbol() == "USDCAD") { magic = 211019; }
   if (magic == 0) { magic = 211999; }
   return (0);
   return(0);
  }

void OpenBuy()
 {
    int ticket,err;
        if (!GlobalVariableCheck("InTrade")) {
               GlobalVariableSet("InTrade", CurTime());  // set lock indicator
               ticket = OrderSend(Symbol(),OP_BUY,lot2,Ask,1,0,Ask+TP*Point,"EA Order",magic,0,Blue);
               GlobalVariableDel("InTrade");   // clear lock indicator
        }
 }

void OpenSell()
 {
    int ticket,err;
        if (!GlobalVariableCheck("InTrade")) {
               GlobalVariableSet("InTrade", CurTime());  // set lock indicator
               ticket = OrderSend(Symbol(),OP_SELL,lot2,Bid,1,0,Bid-TP*Point,"EA Order",magic,0,Red);
               GlobalVariableDel("InTrade");   // clear lock indicator
        }
 }


void ManageBuy() 
 {
   int lasttradetime = 0;
   double lastopenprice=0;
   double maxlots = 0;
   double lasttp=0;
   int lastordertype=-1;
   int lastorderticket=0;
   int y=0; 

   for (y = 0; y < OrdersTotal(); y++)
   {
      OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
      if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY)) { continue; }
      if (OrderOpenTime() > lasttradetime) { 
        lasttradetime = OrderOpenTime();
        lastopenprice = OrderOpenPrice();
        lastordertype=OrderType();
        lastorderticket=OrderTicket();
        lasttp=OrderTakeProfit();
      }     
      if (OrderLots() > maxlots) { maxlots = OrderLots(); }
   }
   
   int lvl=MathLog(maxlots/lot)/MathLog(2)+1;

   if (lvl<0) lvl=0;
   
   lot2=lot*MathPow(2,lvl);
   
   if (lvl==0) OpenBuy();
   
   if ((lastopenprice-Ask>MinGS*Point) && (lvl<MaxTrades)) {
     OpenBuy();
     return(0);
   }

/////////// TP
/*
   double sumlots=0;
   double sump=0;
   double avgp=0;
   for (y = 0; y < OrdersTotal(); y++)
   {
      OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
      if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY)) { continue; }
      sumlots=sumlots+OrderLots();
      sump=OrderOpenPrice()*OrderLots()+sump;
   }
   
   if (sumlots>0) {
     avgp=NormalizeDouble(sump/sumlots,Digits);
     double tpp=NormalizeDouble(TP/10/sumlots*Point+avgp,Digits);
     
     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY) || (OrderTakeProfit()==tpp)) { continue; }
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tpp,0,Red);
     }
     
     
   }
 */  

     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY) || (OrderTakeProfit()==lasttp) || (lasttp==0)) { continue; }
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),lasttp,0,Blue);
     }

   
}
    
void ManageSell() 
 {
   int lasttradetime = 0;
   double lastopenprice=0;
   double maxlots = 0;
   double lasttp=0;
   int lastordertype=-1;
   int lastorderticket=0;
   int y=0; 

   for (y = 0; y < OrdersTotal(); y++)
   {
      OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
      if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL)) { continue; }
      if (OrderOpenTime() > lasttradetime) { 
        lasttradetime = OrderOpenTime();
        lastopenprice = OrderOpenPrice();
        lastordertype=OrderType();
        lastorderticket=OrderTicket();
        lasttp=OrderTakeProfit();
      }     
      if (OrderLots() > maxlots) { maxlots = OrderLots(); }
   }
   
   int lvl=MathLog(maxlots/lot)/MathLog(2)+1;

   if (lvl<0) lvl=0;
   
   lot2=lot*MathPow(2,lvl);
   
   if (lvl==0) OpenSell();
   
   if ((Bid-lastopenprice>MinGS*Point) && (lastopenprice>0) && (lvl<MaxTrades)) {
     OpenSell();
     return(0);
   }

/////////// TP
/*   double sumlots=0;
   double sump=0;
   double avgp=0;
   for (y = 0; y < OrdersTotal(); y++)
   {
      OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
      if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL)) { continue; }
      sumlots=sumlots+OrderLots();
      sump=OrderOpenPrice()*OrderLots()+sump;
   }
   
   if (sumlots>0) {
     avgp=NormalizeDouble(sump/sumlots,Digits);
     double tpp=NormalizeDouble(-TP/10/sumlots*Point+avgp,Digits);
     
     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL) || (OrderTakeProfit()==tpp)) { continue; }
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tpp,0,Red);
     }
     
     
   }
 */ 
 
      for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL) || (OrderTakeProfit()==lasttp) || (lasttp==0)) { continue; }
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),lasttp,0,Red);
     }
 
   
 }

  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----

  ManageBuy();
  
  ManageSell();


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