nevalyashka_stopup

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

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
7 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 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%
NZD/USD Jan 2025 - Jul 2025
1.56
Total Trades 23
Won Trades 18
Lost trades 5
Win Rate 78.26 %
Expected payoff 15.53
Gross Profit 1000.00
Gross Loss -642.90
Total Net Profit 357.10
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
1.61
Total Trades 73
Won Trades 60
Lost trades 13
Win Rate 82.19 %
Expected payoff 17.34
Gross Profit 3325.00
Gross Loss -2059.00
Total Net Profit 1266.00
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
1.15
Total Trades 137
Won Trades 108
Lost trades 29
Win Rate 78.83 %
Expected payoff 3.85
Gross Profit 3990.93
Gross Loss -3463.77
Total Net Profit 527.16
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
207.11
Total Trades 8121
Won Trades 8110
Lost trades 11
Win Rate 99.86 %
Expected payoff 49.73
Gross Profit 405806.30
Gross Loss -1959.40
Total Net Profit 403846.90
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 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%
USD/CAD 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%
NZD/USD Oct 2024 - Jan 2025
0.61
Total Trades 9
Won Trades 5
Lost trades 4
Win Rate 55.56 %
Expected payoff -21.29
Gross Profit 300.00
Gross Loss -491.60
Total Net Profit -191.60
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.23
Total Trades 25
Won Trades 19
Lost trades 6
Win Rate 76.00 %
Expected payoff 8.25
Gross Profit 1087.50
Gross Loss -881.30
Total Net Profit 206.20
-100%
-50%
0%
50%
100%

Comments