VBS - Very Blondie System

Author: David
Profit factor:
1.10

Here's a breakdown of what this trading script does, explained in simple terms:

Overall Goal:

The script, named "Very Blondie System," is designed to automatically place and manage trades in the Forex market based on certain price movements. It aims to open new trades and close existing ones based on predefined rules.

How it Works:

  1. Initial Setup:

    • The script starts by checking if there's enough historical data available and if trading is allowed on the platform. If not, it stops.
    • It then looks at whether there are any open trades at all. If there aren't, it proceeds to check for opportunities to open new trades. If there are open trades, it proceeds to check conditions to close those trades.
  2. Opening New Trades (CheckForOpen):

    • The script identifies the highest and lowest price points over a specific recent period (defined by "PeriodX").
    • It calculates an initial trade size ("Lots") based on the account balance.
    • The script determines whether the current price has moved significantly above the recent highest price or below the recent lowest price (as determined by a factor of Limit).
      • If the price is significantly higher: It opens a "buy" trade (expecting the price to continue upwards). It also places several pending "buy limit" orders (orders to buy if the price drops to specific levels), spaced out according to a "Grid" parameter. The size of each successive pending order increases exponentially.
      • If the price is significantly lower: It opens a "sell" trade (expecting the price to continue downwards). Similarly, it places several pending "sell limit" orders (orders to sell if the price rises to specific levels), also spaced out according to the "Grid" parameter and with increasing size.
  3. Closing Existing Trades (CheckForClose):

    • Profit Target: It checks if the total profit from all open trades is greater than or equal to a specified amount ("Amount"). If so, it closes all open positions.
    • "LockDown" Feature: If the "LockDown" feature is enabled (LockDown > 0), the script attempts to protect profits on existing trades by adjusting the stop-loss. If the price has moved a certain distance in a profitable direction (determined by "LockDown"), it sets a stop-loss order to the opening price plus or minus one "Point". The stop-loss is like an emergency exit, if the market reverse it can avoid losing more than the LockDown point.
  4. Closing All Trades (CloseAll):

    • This function simply iterates through all open trades and closes them, regardless of their individual profit or loss. It closes buy trades at the current "bid" price and sell trades at the current "ask" price. It also cancels any pending orders.
  5. Calculating Profit (getProfit):

    • This function calculates the total profit from all open trades, including any swap fees (interest for holding positions overnight).

Key Parameters:

  • PeriodX: The period used to calculate the recent highest and lowest prices.
  • Limit: A multiplier that determines how much the price needs to move above or below the recent high/low before a trade is opened.
  • Grid: The spacing between the pending "limit" orders.
  • Amount: The profit target for closing all trades.
  • LockDown: The amount of profit a trade must have before a stop-loss is set to protect gains.
  • Slippage: The maximum acceptable difference between the requested price and the actual price when closing a trade.

In essence, the script tries to capitalize on price breakouts by opening initial trades and then adding to those positions with pending orders at specific intervals. It also incorporates a profit-taking mechanism and a feature to protect existing profits.

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 strategyIt Closes Orders by itself
7 Views
0 Downloads
0 Favorites
VBS - Very Blondie System
//+------------------------------------------------------------------+
//|                                    VBS - Very Blondie System.mq4 |
//|                                                            David |
//|                                               Broker77@gmail.com |
//+------------------------------------------------------------------+
#property copyright "David"
#property link      "broker77@gmail.com"
#define MAGICMA  20081109

extern int PeriodX = 60;
extern int Limit = 1000;

extern int Grid = 1500;
extern int Amount = 40;

extern int LockDown = 0;
int Slippage = 50;

//+------------------------------------------------------------------+
//| Start function                                                   |
//+------------------------------------------------------------------+
void start()
  {
//---- check for history and trading
   if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
   if(OrdersTotal()==0) CheckForOpen();
   else CheckForClose();
//----
  }
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
int CheckForOpen()
{
  double L = Low[iLowest(NULL,0,MODE_LOW,PeriodX,0)];
  double H = High[iHighest(NULL,0,MODE_HIGH,PeriodX,0)];
  double Lots = MathRound(AccountBalance()/100)/1000;
  
  if((H-Bid>Limit*Point))
    {OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,0,"",MAGICMA,0,CLR_NONE);
     for(int i=1; i<5; i++){OrderSend(Symbol(),OP_BUYLIMIT,MathPow(2,i)*Lots,Ask-i*Grid*Point,1,0,0,"",MAGICMA,0,CLR_NONE);}
    }
    
  if((Bid-L>Limit*Point))
    {OrderSend(Symbol(),OP_SELL,Lots,Bid,1,0,0,"",MAGICMA,0,CLR_NONE);
     for(int j=1; j<5; j++){OrderSend(Symbol(),OP_SELLLIMIT,MathPow(2,j)*Lots,Bid+j*Grid*Point,1,0,0,"",MAGICMA,0,CLR_NONE);}
    }
    
}  
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
int CheckForClose()
{
  if(getProfit()>=Amount){CloseAll();}
    
  if(LockDown>0)
  {
    for(int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--)
    {
      if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES)&&(LockDown>0))
      { int Pos=OrderType();
        if((Pos==OP_BUY)&&(Bid-OrderOpenPrice()>Point*LockDown)&&(OrderStopLoss() == 0))
        {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE);}
        if((Pos==OP_SELL)&&(OrderOpenPrice()-Ask>Point*LockDown)&&(OrderStopLoss() == 0))
        {OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point,OrderTakeProfit(),0,CLR_NONE);}
      }
    }
  } 

}  
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
double getProfit()
{
   double Profit = 0;
   for (int TradeNumber = OrdersTotal(); TradeNumber >= 0; TradeNumber--)
   {
     if (OrderSelect(TradeNumber, SELECT_BY_POS, MODE_TRADES))
     Profit = Profit + OrderProfit() + OrderSwap();
   }
   return (Profit);
}
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         
void CloseAll()
{
   bool   Result;
   int    i,Pos,Error;
   int    Total=OrdersTotal();
   
   if(Total>0)
   {
     for(i=Total-1; i>=0; i--) 
     {
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE) 
       {
         Pos=OrderType();
         if(Pos==OP_BUY)
         {Result=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, CLR_NONE);}
         if(Pos==OP_SELL)
         {Result=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, CLR_NONE);}
         if((Pos==OP_BUYSTOP)||(Pos==OP_SELLSTOP)||(Pos==OP_BUYLIMIT)||(Pos==OP_SELLLIMIT))
         {Result=OrderDelete(OrderTicket(), CLR_NONE);}
//-----------------------
         if(Result!=true) 
          { 
             Error=GetLastError(); 
             Print("LastError = ",Error); 
          }
         else Error=0;
//-----------------------
       }   
     }
   }
   return(0);
}
//---------------------------------------------------------------------------         
//---------------------------------------------------------------------------         

Profitability Reports

GBP/AUD Jul 2025 - Sep 2025
1.49
Total Trades 26
Won Trades 16
Lost trades 10
Win Rate 61.54 %
Expected payoff 22.58
Gross Profit 1782.44
Gross Loss -1195.39
Total Net Profit 587.05
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 7
Won Trades 7
Lost trades 0
Win Rate 100.00 %
Expected payoff 25315772.00
Gross Profit 177210397.50
Gross Loss 0.00
Total Net Profit 177210397.50
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
20.63
Total Trades 6
Won Trades 5
Lost trades 1
Win Rate 83.33 %
Expected payoff 31.73
Gross Profit 200.10
Gross Loss -9.70
Total Net Profit 190.40
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.57
Total Trades 176
Won Trades 122
Lost trades 54
Win Rate 69.32 %
Expected payoff 21.54
Gross Profit 10421.53
Gross Loss -6629.67
Total Net Profit 3791.86
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.49
Total Trades 50
Won Trades 37
Lost trades 13
Win Rate 74.00 %
Expected payoff 21.83
Gross Profit 3331.92
Gross Loss -2240.55
Total Net Profit 1091.37
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
1.69
Total Trades 55
Won Trades 39
Lost trades 16
Win Rate 70.91 %
Expected payoff 24.13
Gross Profit 3240.86
Gross Loss -1913.44
Total Net Profit 1327.42
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
1.81
Total Trades 24
Won Trades 18
Lost trades 6
Win Rate 75.00 %
Expected payoff 25.33
Gross Profit 1358.06
Gross Loss -750.02
Total Net Profit 608.04
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
1.61
Total Trades 78
Won Trades 56
Lost trades 22
Win Rate 71.79 %
Expected payoff 26.25
Gross Profit 5399.79
Gross Loss -3352.52
Total Net Profit 2047.27
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.15
Total Trades 32
Won Trades 16
Lost trades 16
Win Rate 50.00 %
Expected payoff -274.61
Gross Profit 1552.52
Gross Loss -10340.15
Total Net Profit -8787.63
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
1.40
Total Trades 191
Won Trades 127
Lost trades 64
Win Rate 66.49 %
Expected payoff 19.04
Gross Profit 12829.58
Gross Loss -9192.71
Total Net Profit 3636.87
-100%
-50%
0%
50%
100%

Comments