FxIgorDynBOSystem1-1ea

Author: Copyright � 2006, MetaQuotes Software Corp.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
110.00 %
Total Trades 87
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 0.09
Gross Profit 90.29
Gross Loss -82.21
Total Net Profit 8.08
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
83.00 %
Total Trades 87
Won Trades 44
Lost trades 43
Win Rate 0.51 %
Expected payoff -0.27
Gross Profit 118.42
Gross Loss -141.97
Total Net Profit -23.55
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
106.00 %
Total Trades 81
Won Trades 39
Lost trades 42
Win Rate 0.48 %
Expected payoff 0.05
Gross Profit 68.87
Gross Loss -64.75
Total Net Profit 4.12
-100%
-50%
0%
50%
100%
FxIgorDynBOSystem1-1ea
//+------------------------------------------------------------------+
//|                                            FXIgorSystem1.1.mq4   |
//|                                               Diego G. Almeida   |
//|           Magic number and MM added by Project1972               |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


extern double lots= 0.01; // 0.01 is a single micro lot
extern bool MM = false;       // if true the lots size will increase based on account balance 
extern int risk=1;           // percent of account balance to risk on each trade (only if mm is enabled)
extern double MinLots=0.1;   // minimal lots you want to trade or your broker allow (only if mm is enabled)
extern double MAXLots=10;    // max lots you want to trade or your broker allow (only if mm is enabled)               
//extern double takeProfit   = 0;                         
extern double slippage     = 10;
int      MagicNumber = 123787;
extern int hourtoclose = 20; //default 18 Alpari Fibogroup and MIG, 19 Northfinance and FXDD, 17 IBFX
double highday=0,lowday=0,h=0,l=0,media=0,mediacalc=0,pcompra=0,pvenda=0,TrailingStop=0,lotsi=0,stopLoss=0;
int cnt,dia=0,op=0,limitepos=0;
int init() 
{
   return(0);
}
int start()
{

if (MM==true) {{ lotsi=NormalizeDouble(AccountBalance()*risk/100000.0,1); }
if (lotsi<MinLots){ lotsi=MinLots; }
if (lotsi>MAXLots){ lotsi=MAXLots; }
}
else { lotsi=lots; }   
if(AccountFreeMargin() < 1000*lotsi) {
  Print("Not enough money to trade ");
      return(0); }
           
int orders=0,horas=0;
if(Day() != dia)
{
int R1=0,R5=0,R10=0,R20=0,RAvg=0;
int i=0;

   R1 =  (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   for(i=1;i<=5;i++)
      R5    =    R5  +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=10;i++)
      R10   =    R10 +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=20;i++)
      R20   =    R20 +  (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;

   R5 = R5/5;
   R10 = R10/10;
   R20 = R20/20;
   RAvg  =  (R1+R5+R10+R20)/4;    
   media=RAvg/2;
   mediacalc=MathCeil(media);
   TrailingStop=mediacalc;
   stopLoss=mediacalc;
   h=0;
   l=0;
   dia=Day();
   op=0;
   limitepos=0;
}
   highday=iHigh(NULL,PERIOD_D1,0);
   lowday=iLow(NULL,PERIOD_D1,0);

if(highday > h)
   h=highday;
if(lowday < l)
   l=lowday;
Print("Trailing stop ",TrailingStop);
Print("Mediacalc ",mediacalc);

horas=hourtoclose - Hour();

int total=OrdersTotal();
  if(total>0)
   { 
   for(cnt=0;cnt<total;cnt++)
   {
      if(OrderSymbol() == Symbol() && OrderType() == OP_BUY)
      {
         op=1;
      }
      if(OrderSymbol() == Symbol() && OrderType() == OP_SELL)
      {
         op=2;
      }
   } 
   for(cnt=0;cnt<total;cnt++)
    {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
      {
      if(TrailingStop > 0) {             
               if(Bid-OrderOpenPrice() > TrailingStop*Point)
                {
                  if(OrderStopLoss() < (Bid - TrailingStop*Point))
                     //if(OrderTakeProfit() == 0)
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Blue);
               }
            }
         
      }   else {                              
            if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
            {
            if(TrailingStop > 0) {             
               if(OrderOpenPrice() - Ask > TrailingStop*Point)
                {
                  if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStop*Point)
                     //if(OrderTakeProfit() == 0)
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Red);
                }           
            }
          } 
        }
      if(OrderSymbol()==Symbol() && OrderType() == OP_BUY && OrderMagicNumber()==MagicNumber)
      {
         if(Hour() >= hourtoclose && Hour() < 23)
            OrderClose(OrderTicket(),OrderLots(),Bid,3,Lime);
         orders=1;
      }
      if(OrderSymbol()==Symbol() && OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber)
      {
         if(Hour() >= hourtoclose && Hour() < 23)
            OrderClose(OrderTicket(),OrderLots(),Ask,3,Lime);
          orders=1;
      }
    
   
    }

  } 
else
{
   //horas=hourtoclose - Hour();
   if(horas >= 1)
   {
   
      if(orders == 0 && op == 2 && limitepos <2)
      {
         OrderSend(Symbol(),OP_BUY,lotsi,Ask,slippage,Ask-stopLoss*Point,0,"Power:Buy",MagicNumber,0,Lime);
         limitepos+=1;
      }
      if(orders == 0 && op == 1 && limitepos <2)
      {
         OrderSend(Symbol(),OP_SELL,lotsi,Bid,slippage,Bid+stopLoss*Point,0,"Power:Sell",MagicNumber,0,Red);
         limitepos+=1;
      }
   }
}

if(horas >=1)
{

if(orders == 0 && op == 0 && limitepos <2)
{
   pcompra=lowday+mediacalc*Point;
   pvenda=highday-mediacalc*Point;
   
   Comment("\n Break Channel: ",mediacalc," pips \n Buying Price: ",pcompra,"\n Selling Price: ",pvenda,"\n Lots: ",lotsi);
   
   Print("Buying Price: ",pcompra);
   Print("Selling Price: ",pvenda);
   Print("Lots: ",lotsi);
   if(Bid >= pcompra)
   {
      Print("Buy");
      OrderSend(Symbol(),OP_BUY,lotsi,Ask,slippage,Ask-stopLoss*Point,0,"Power:Buy",MagicNumber,0,Lime);      
      limitepos+=1;
   }

if(Bid <= pvenda)
{
      Print("Sell");
      OrderSend(Symbol(),OP_SELL,lotsi,Bid,slippage,Bid+stopLoss*Point,0,"Power:Sell",MagicNumber,0,Red);
      limitepos+=1;
}

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