VBS - Very Blondie System

Author: David
Profit factor:
0.76

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
1 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 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%
AUD/USD Jan 2025 - Jul 2025
0.00
Total Trades 26
Won Trades 19
Lost trades 7
Win Rate 73.08 %
Expected payoff -16035.79
Gross Profit 1274.07
Gross Loss -418204.61
Total Net Profit -416930.54
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.07
Total Trades 13
Won Trades 4
Lost trades 9
Win Rate 30.77 %
Expected payoff 9.22
Gross Profit 1841.32
Gross Loss -1721.52
Total Net Profit 119.80
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.92
Total Trades 7
Won Trades 2
Lost trades 5
Win Rate 28.57 %
Expected payoff -12.24
Gross Profit 941.60
Gross Loss -1027.30
Total Net Profit -85.70
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00
Total Trades 5
Won Trades 0
Lost trades 5
Win Rate 0.00 %
Expected payoff -1767.66
Gross Profit 0.00
Gross Loss -8838.30
Total Net Profit -8838.30
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
1.14
Total Trades 27
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 10.21
Gross Profit 2180.45
Gross Loss -1904.74
Total Net Profit 275.71
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.42
Total Trades 10
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 19.19
Gross Profit 652.80
Gross Loss -460.90
Total Net Profit 191.90
-100%
-50%
0%
50%
100%

Comments