nevalyashka_stopup

Author: Copyright � 2016, ������� ��������
Profit factor:
12.30

This script, designed for the MetaTrader platform, is an automated trading system, also known as an "Expert Advisor," that operates based on a strategy called "Martingale." Here's how it works in plain language:

  1. Initial Setup: The script begins by setting up some initial parameters provided by the user. These include:

    • Stop Loss: The maximum amount of loss (in points) the script will allow for a single trade.
    • Take Profit: The amount of profit (in points) the script aims to achieve for a single trade.
    • Lot Size: The initial size (volume) of the trades it will place.
    • Martingale Coefficient: A multiplier used to increase the stop loss and take profit for subsequent trades after a losing trade.
    • Magic Number: A unique identifier to distinguish trades made by this script from other trades.
    • Stop After Profit: A switch to determine if the expert advisor will stop operating after it gets a profit. It also adjusts the "Stop Loss" and "Take Profit" values depending on the currency pair being traded.
  2. Trading Logic: The script continually monitors the market for trading opportunities, but only places a trade after a previous trade has closed. It operates in a loop by first looking at the currently open orders (trades). If the EA sees one of its trades already open, it stops and does nothing. If it doesn't see any trades open, it will analyze the history of past trades, particularly those placed by this specific script, using the "Magic Number" to identify them.

  3. Martingale Element (After a Loss): If the most recent trade closed with a loss, the script then performs the Martingale element of the strategy. The Martingale principle basically doubles down after losses, but in this case, the stop loss and take profit levels are increased. The new stop loss and take profit levels are based on the old stop loss/take profit amount, multiplied by the Martingale coefficient.

  4. Martingale Element (After a Win): If the most recent trade was profitable, and the "Stop After Profit" option is enabled, the script will shut itself down. Otherwise, the script resets to use the initial (smaller) "Stop Loss" and "Take Profit" values for the next trade.

  5. Trade Execution: After determining what trade to make, the script then performs the order to either buy or sell on the market depending on the last order opened.

    • If the last trade was a "buy", the script will make a "sell" trade.
    • If the last trade was a "sell", the script will make a "buy" trade. The script then places a market order, setting the stop loss and take profit according to the parameters calculated, and the "Magic Number" so it can track its own trades.

In essence, this script tries to recover from losses by increasing the stop loss and take profit on the next trade. This is a high-risk strategy, as a series of losing trades can rapidly deplete an account. It will trade only if there aren't any open orders done by itself on the market. It operates continuously, attempting to open a new position after each closed trade.

Orders Execution
Checks for the total of open ordersChecks for the total of closed ordersIt automatically opens orders when conditions are reached
10 Views
0 Downloads
0 Favorites
nevalyashka_stopup
//+------------------------------------------------------------------+
//|                                       Nevalyashka_Martingail.mq4 |
//|                               Copyright © 2010, Õëûñòîâ Âëàäèìèð |
//|                                                cmillion@narod.ru |
//|                                                                  |
//--------------------------------------------------------------------
#property copyright "Copyright © 2016, Õëûñòîâ Âëàäèìèð"
#property link      "cmillion@narod.ru"
#property version   "1.00"
#property strict
#property description "Ñîâåòíèê îòêðûâàåò ïîñëå óáûòêà îðäåðà ñ óâåëè÷åííûìè íà êîýôôèöèåíò ñòîïàìè"
//--------------------------------------------------------------------
extern int    stoploss     = 150,
              takeprofit   = 50;
extern double Lot          = 0.1;
extern double KoeffMartin  = 1.5;//êîýôôèöèåíò óâåëè÷åíèÿ ñòîïîâ
extern int    Magic        = 0;
extern bool   StopAfteProfit = false;//îñòàíîâêà ïîñëå ïðîôèòà
double sl=0,tp=0;
//--------------------------------------------------------------------
int OnInit()
  {
   if(Digits==5 || Digits==3)
     {
      stoploss*=10;
      takeprofit*=10;
     }
   sl=stoploss*Point;
   tp=takeprofit*Point;
   return(INIT_SUCCEEDED);
  }
//--------------------------------------------------------------------
void OnTick()
  {
   int tip=0,i;
   for(i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            return;
           }
        }
     }
   for(i=OrdersHistoryTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderProfit()<0)
              {
               sl = MathAbs(OrderStopLoss()-OrderOpenPrice())*KoeffMartin;
               tp = MathAbs(OrderTakeProfit()-OrderOpenPrice())*KoeffMartin;
              }
            else
              {
               if(StopAfteProfit) ExpertRemove();
               sl=stoploss*Point;
               tp=takeprofit*Point;
              }
            tip=OrderType();
            break;
           }
        }
     }
   if(tip==OP_BUY)
      if(OrderSend(Symbol(),OP_SELL,Lot,Bid,3,NormalizeDouble(Ask+sl,Digits),NormalizeDouble(Bid-tp,Digits)," ",Magic,Blue)==-1)
         Print("Error ",GetLastError()," Bid=",DoubleToStr(Bid,Digits)," sl=",DoubleToStr(Ask+sl,Digits)," tp=",DoubleToStr(Bid-tp,Digits));
   if(tip==OP_SELL)
      if(OrderSend(Symbol(),OP_BUY,Lot,Ask,3,NormalizeDouble(Bid-sl,Digits),NormalizeDouble(Ask+tp,Digits)," ",Magic,Blue)==-1)
         Print("Error ",GetLastError()," Ask=",DoubleToStr(Ask,Digits)," sl=",DoubleToStr(Bid-sl,Digits)," tp=",DoubleToStr(Ask+tp,Digits));
   return;
  }
//-----------------------------------------------------------------

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
1.53
Total Trades 43
Won Trades 36
Lost trades 7
Win Rate 83.72 %
Expected payoff 10.60
Gross Profit 1312.95
Gross Loss -857.35
Total Net Profit 455.60
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.18
Total Trades 9
Won Trades 7
Lost trades 2
Win Rate 77.78 %
Expected payoff 7.40
Gross Profit 444.58
Gross Loss -377.94
Total Net Profit 66.64
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
2.90
Total Trades 10
Won Trades 9
Lost trades 1
Win Rate 90.00 %
Expected payoff 21.04
Gross Profit 320.85
Gross Loss -110.45
Total Net Profit 210.40
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.05
Total Trades 5
Won Trades 3
Lost trades 2
Win Rate 60.00 %
Expected payoff 1.56
Gross Profit 175.00
Gross Loss -167.20
Total Net Profit 7.80
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.31
Total Trades 22
Won Trades 17
Lost trades 5
Win Rate 77.27 %
Expected payoff 10.20
Gross Profit 950.00
Gross Loss -725.60
Total Net Profit 224.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.35
Total Trades 24
Won Trades 19
Lost trades 5
Win Rate 79.17 %
Expected payoff 8.29
Gross Profit 768.56
Gross Loss -569.52
Total Net Profit 199.04
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.02
Total Trades 24
Won Trades 18
Lost trades 6
Win Rate 75.00 %
Expected payoff 0.57
Gross Profit 678.98
Gross Loss -665.37
Total Net Profit 13.61
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
6.93
Total Trades 7
Won Trades 6
Lost trades 1
Win Rate 85.71 %
Expected payoff 36.67
Gross Profit 300.00
Gross Loss -43.30
Total Net Profit 256.70
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.07
Total Trades 122
Won Trades 94
Lost trades 28
Win Rate 77.05 %
Expected payoff 1.99
Gross Profit 3597.46
Gross Loss -3354.86
Total Net Profit 242.60
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.08
Total Trades 32
Won Trades 23
Lost trades 9
Win Rate 71.88 %
Expected payoff 3.65
Gross Profit 1638.90
Gross Loss -1521.97
Total Net Profit 116.93
-100%
-50%
0%
50%
100%

Comments