Author: � Maloma
Price Data Components
Series array that contains close prices for 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
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
5.00 %
Total Trades 419
Won Trades 10
Lost trades 409
Win Rate 0.02 %
Expected payoff -1.39
Gross Profit 30.00
Gross Loss -613.50
Total Net Profit -583.50
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
e-F5S_2
//+------------------------------------------------------------------+
//|                                  Expert for Fractals5+Signal.mq4 |
//+------------------------------------------------------------------+
#property copyright "© Maloma"

extern string _Parameters_Expert = "----- Ïàðàìåòðû ñîâåòíèêà";
extern double Lots = 0.1;
extern int    SL   = 15;
extern int    TP   = 30;
extern int    magic=4802454;
extern string _Parameters_Tral = "----- Ïàðàìåòðû òðàëà";
extern bool   Tral;
extern int    TStOp=10;
extern int    TStEp=5;
extern int    Bezubitok=0;
extern string _Parameters_MM = "----- Ïàðàìåòðû ìàíèìýíýäæìåíòà";
extern bool   MM;
extern double MaximumRisk        = 0.03;
extern double DecreaseFactor     = 3;
extern double hedg =2;

       double RLots;
       double SigUP=0, SigDN=0;
       int    CBars=0;
       bool   trend,old; 
       int    TotB,TotS;

double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/500,1);
//---- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>0) lot=NormalizeDouble(lot*hedg*losses,1);//NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//---- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }
  
void Tral()
{
 for(int i=OrdersTotal()-1;i>=0;i--)
    {
     OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
     if ((OrderSymbol()==Symbol()) && (OrderMagicNumber()==magic))
      {
       if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>TStOp*Point)
        {
         if (Bezubitok!=0 && Bid-OrderOpenPrice()>=Bezubitok*Point && OrderStopLoss()<OrderOpenPrice())
          {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+1*Point,OrderTakeProfit(),0,CLR_NONE);}
         if (Bid-OrderStopLoss()>=(TStOp+TStEp)*Point)
          {OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TStOp*Point,OrderTakeProfit(),0,CLR_NONE);}
        }
       if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>TStOp*Point)
        {
         if (Bezubitok!=0 && OrderOpenPrice()-Ask>=Bezubitok*Point && OrderStopLoss()>OrderOpenPrice())
          {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-1*Point,OrderTakeProfit(),0,CLR_NONE);}
         if (OrderStopLoss()-Ask>=(TStOp+TStEp)*Point)
          {OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TStOp*Point,OrderTakeProfit(),0,CLR_NONE);}
        }
      }
    }
 return(0);
}


void GetSignal(int i)
{

 if(High[3]>High[4] && High[3]>High[5] && High[3]>High[2] && High[3]>High[1])
  {SigUP=1;}
 else
  {SigUP=0;}
 
 if(Low[3]<Low[4] && Low[3]<Low[5] && Low[3]<Low[2] && Low[3]<Low[1])
  {SigDN=1;}
 else
  {SigDN=0;}
  
 return(0);
}

void Check4Close()
{
 int j=OrdersTotal();
 for (int i=j;i>=0;i--)
  {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if (Symbol()==OrderSymbol() && magic==OrderMagicNumber())
    if (OrderType()==OP_BUY && SigDN==1)
     OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
    if (OrderType()==OP_SELL && SigUP==1)
     OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
  }
 return(0);
}

void Total()
{
 TotB=0;
 TotS=0;
 int j=OrdersTotal();
 for (int i=j;i>=0;i--)
  {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if (Symbol()==OrderSymbol() && magic==OrderMagicNumber())
    if (OrderType()==OP_BUY) TotB++;
    if (OrderType()==OP_SELL) TotS++;
  }
 return(0); 
}

void start()
{
 if (Tral) Tral();
 if (Bars==CBars) {return(2);}
 GetSignal(1);
// if (SigUP==1 && SigDN==1) {} else Check4Close();
 if (MM) RLots=LotsOptimized(); else RLots=Lots;
 Total();
 if (SigUP==1 && TotB==0) OrderSend(Symbol(),OP_BUY,RLots,Ask,3,Ask-SL*Point,Ask+TP*Point,"e-4FATL",magic,0,Green);
 if (SigDN==1 && TotS==0) OrderSend(Symbol(),OP_SELL,RLots,Bid,3,Bid+SL*Point,Bid-TP*Point,"e-4FATL",magic,0,Red);
 CBars=Bars;
 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 ---