Author: Jacob Yego
Profit factor:
0.54

The LBS V 1.0 script is an automated trading tool designed to manage currency positions based on specific time-based triggers and volatility measurements. It automates the process of identifying entry points, calculating risk parameters, and managing active trades to protect profits.

Core Operational Logic

Risk and Position Management The system begins by evaluating your account's financial health before executing any actions. It checks the available free margin against your desired trade size. If the account balance is insufficient to support a new trade based on your set leverage and lot requirements, the script will alert you rather than attempting a risky trade. Additionally, it calculates the appropriate trade volume (Lots) based on either a fixed amount or a dynamic calculation tied to your total account balance and risk tolerance.

Entry Conditions and Timing The script is designed to be time-sensitive. It specifically monitors the market clock to identify a designated "Trigger Time." Once this specific hour is reached, the system looks for opportunities to place orders. It ensures that it only initiates new positions if there are currently no active trades on the specific currency pair, preventing over-exposure.

Price Calculation and Volatility To determine where to enter a trade, the script analyzes recent market data (specifically the previous 15-minute candle). It uses a technical indicator known as the Average True Range (ATR) to measure current market volatility. By factoring in this volatility along with the current "Spread" (the difference between buying and selling prices), it calculates precise entry levels for both Buy Stop and Sell Stop orders.

Trade Execution Styles The logic supports two primary styles of trade placement:

  • Buy Stops: Placed above recent highs, targeting upward movement.
  • Sell Stops: Placed below recent lows, targeting downward movement.
  • Market Orders: The system can also execute direct Sell orders at current market prices with predefined targets.

Dynamic Profit Protection A key feature of this script is the "Trailing Stop" mechanism. Once a trade moves into a profitable position, the script actively "trails" the price. If the market moves in your favor by a specific distance, the system automatically moves the Stop Loss order to lock in those gains. This allows the trade to remain open as long as it stays profitable, while automatically closing the position if the market reverses against you, thereby securing a portion of the profit.

Price Data Components
Series array that contains open time of each barSeries 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 automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Indicator of the average true range
Miscellaneous
It issuies visual alerts to the screen
15 Views
0 Downloads
0 Favorites
LBS V12_v1
//+--------------------------------------------------------------------+
//|                                                      LBS V 1.0.mq4 |
//|                                                       Jacob Yego   |
//|                                                                    |
//+--------------------------------------------------------------------+
#property copyright "Jacob Yego"
#property link      "PointForex"
//----
extern int LotSize=10000; //Currency amount per Lot
extern int Leverage=0;    //Set to your Risk tolerance
extern int TrailingStop= 20;
extern int Slippage=5;
extern int TakeProfit=100;
extern int Triggertime=9;
extern int Lots=1;
// initialize internal variables
  double OpenBuy,SlBuy,OpenSell,SlSell,TpBuy,TpSell;
  //double SS1,SS2,SS3,S1,S2,S3;//for use to develop 3 wave system
  //double BS1,BS2,BS3,B1,B2,B3;// for use to develop 3 wave system
  double ATR,h,m,total,cnt,ticket,Spread;
  double time,NewPrice=0;
  double PriceOpen, Buy_Sl, Buy_Tp, LotMM;
  string symbol;
  //int gear1=2;//develop strategy to open 2nd order with take profit TP*gear1
  //int gear2=3; //develop strategy to open 3rd order with take profit TP*gear2
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   ATR=iATR(NULL,0,3,1);
//----
   //  SetLotsMM
   if(Leverage > 0)LotMM=MathMax(MathFloor(AccountBalance()*Leverage/LotSize),1)*LotSize/100000;
   else LotMM=Lots;
//----
   if(AccountFreeMargin() < LotSize/AccountLeverage()*LotMM)
     {
      Alert("Not enough money to open trade. Free Margin = ",
      AccountFreeMargin(),". Number of Lots in trade = ",LotMM);
      return(-1);
     }
   //+------------------------------------------------------------------+
   //|Place New Order                                                   |
   //+------------------------------------------------------------------+
   symbol=Symbol();
   Spread=MarketInfo (symbol, MODE_ASK) - MarketInfo (symbol, MODE_BID);
   time=TimeHour(CurTime());
   total=OrdersTotal();
//----
   if(total>0)
     {
      for(cnt=0;cnt<total;cnt++)
        {
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
         if(OrderSymbol()==Symbol())
//---
            return(0);
        }
     }
     if(total < 1)
     {
      ticket=0;
      if (time==Triggertime)
        {
         Print ("LBS BuyStop: ", Symbol(), " ", LotMM, " ", OpenBuy, " ", SlBuy, " ", TpBuy);
         OpenBuy=(iHigh(NULL, PERIOD_M15, 1) + 1*Point + Spread + ATR);
         SlBuy=(iLow (NULL,PERIOD_M15, 1) - 1*Point);
         TpBuy =(OpenBuy+30*Point);
         ticket=OrderSend (Symbol(), OP_BUYSTOP, Lots, OpenBuy, Slippage, SlBuy, TpBuy,
                             "LBS BuyStop", 0, 01969, Red);
        }
        if(total < 1)
        {
         if  (time==Triggertime)
           {
            Print ("LBS BuyStop: ", Symbol(), " ", LotMM, " ", OpenSell, " ", SlSell, " ", TpSell);
            OpenSell=(iLow(NULL, PERIOD_M15, 1) - 1*Point - Spread- ATR);
            SlSell=(iHigh (NULL,PERIOD_M15, 1) + 1*Point);
            TpSell= (OpenSell+30*Point);
            ticket=OrderSend (Symbol(), OP_SELLSTOP, Lots, OpenSell, Slippage, SlSell, TpSell,
                                   " LBS SellStop", 01969, 0, Green);
            ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+(30*Point),Bid-(TakeProfit*Point),"MaxMin Long",16384,0,Pink);
            //RUN TRAILING STOP: BUY
            OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
            if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
              {
               if(TrailingStop>0)
                 {
                  if(Bid-OrderOpenPrice()>Point*TrailingStop)
                    {
                     if(OrderStopLoss()<Bid-(Point*TrailingStop))
                       {
                        OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Point*TrailingStop),OrderTakeProfit(),0,Lime);
                        return(0);
                       }
                    }
                 }
              }
            //RUN TRAILING STOP: SELL
            OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
            if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
              {
               if(TrailingStop>0)
                 {
                  if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                    {
                     if(OrderStopLoss()>Ask+(Point*TrailingStop))
                       {
                        OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Point*TrailingStop),OrderTakeProfit(),0,Lime);
                        return(0);
                       }
                    }
                 }
              }
           }
        }
        //----
      return(0);
     }
  }
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
16 reports
EUR/USD Jul 2025 - Sep 2025
1.38
Total Trades 480
Won Trades 176
Lost trades 304
Win Rate 36.67 %
Expected payoff 10.07
Gross Profit 17600.00
Gross Loss -12768.00
Total Net Profit 4832.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.76
Total Trades 142
Won Trades 35
Lost trades 107
Win Rate 24.65 %
Expected payoff -7.75
Gross Profit 3500.00
Gross Loss -4601.00
Total Net Profit -1101.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.75
Total Trades 210
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -8.34
Gross Profit 5200.00
Gross Loss -6952.00
Total Net Profit -1752.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.73
Total Trades 434
Won Trades 104
Lost trades 330
Win Rate 23.96 %
Expected payoff -8.73
Gross Profit 10400.00
Gross Loss -14190.00
Total Net Profit -3790.00
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.60
Total Trades 352
Won Trades 72
Lost trades 280
Win Rate 20.45 %
Expected payoff -13.75
Gross Profit 7200.00
Gross Loss -12040.00
Total Net Profit -4840.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.56
Total Trades 409
Won Trades 84
Lost trades 325
Win Rate 20.54 %
Expected payoff -10.88
Gross Profit 5704.08
Gross Loss -10152.07
Total Net Profit -4447.99
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.55
Total Trades 297
Won Trades 60
Lost trades 237
Win Rate 20.20 %
Expected payoff -16.51
Gross Profit 6000.00
Gross Loss -10902.00
Total Net Profit -4902.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.53
Total Trades 171
Won Trades 34
Lost trades 137
Win Rate 19.88 %
Expected payoff -17.77
Gross Profit 3400.00
Gross Loss -6439.00
Total Net Profit -3039.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.50
Total Trades 279
Won Trades 49
Lost trades 230
Win Rate 17.56 %
Expected payoff -17.89
Gross Profit 4900.00
Gross Loss -9890.00
Total Net Profit -4990.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.49
Total Trades 167
Won Trades 33
Lost trades 134
Win Rate 19.76 %
Expected payoff -25.36
Gross Profit 4118.38
Gross Loss -8354.24
Total Net Profit -4235.86
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.48
Total Trades 153
Won Trades 29
Lost trades 124
Win Rate 18.95 %
Expected payoff -15.06
Gross Profit 2112.63
Gross Loss -4416.65
Total Net Profit -2304.02
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.41
Total Trades 240
Won Trades 39
Lost trades 201
Win Rate 16.25 %
Expected payoff -16.45
Gross Profit 2774.46
Gross Loss -6723.14
Total Net Profit -3948.68
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.38
Total Trades 376
Won Trades 83
Lost trades 293
Win Rate 22.07 %
Expected payoff -25.60
Gross Profit 5855.33
Gross Loss -15480.42
Total Net Profit -9625.09
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.26
Total Trades 245
Won Trades 48
Lost trades 197
Win Rate 19.59 %
Expected payoff -39.39
Gross Profit 3433.84
Gross Loss -13084.52
Total Net Profit -9650.68
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.25
Total Trades 312
Won Trades 49
Lost trades 263
Win Rate 15.71 %
Expected payoff -30.88
Gross Profit 3190.09
Gross Loss -12824.72
Total Net Profit -9634.63
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.05
Total Trades 91
Won Trades 7
Lost trades 84
Win Rate 7.69 %
Expected payoff -105.77
Gross Profit 499.85
Gross Loss -10124.97
Total Net Profit -9625.12
-100%
-50%
0%
50%
100%

Comments