TSD-v11-MT4-JB-OsMA Daily

Download script
Profit factor:
0.73

Strategy Overview

This script is an automated trading tool designed to execute trades based on the "Triple Screen" system, a well-known multi-timeframe analysis method. The logic follows a systematic approach by analyzing market trends across different timeframes (Weekly, Daily, and current price action) to determine when to enter and manage positions.

Core Market Analysis Logic

The script gathers three specific types of data to make its decisions:

  • Trend Direction: It monitors weekly indicators (MACD and OsMA). By comparing the values of these indicators from previous periods, the script determines the overarching "Direction" of the market (Bullish, Bearish, or Neutral).
  • Market Force: It calculates a "Force" metric based on daily price movements. This helps the script identify the immediate momentum—specifically whether the current daily pressure is Bullish or Bearish.
  • Dynamic Filtering: The tool includes specific time-based windows for different currency pairs (such as EURUSD, GBPUSD, USDJPY, and USDCHF). It only allows the script to place new orders during specific minutes of the day to prevent "collisions" or over-trading during low-liquidity periods.

Entry Mechanism

The script does not enter the market instantly; instead, it places Pending Orders (Buy Stops and Sell Stops). The logic for these entries is as follows:

  1. Buy Condition: If the weekly indicators show a specific alignment and the daily "Force" is Bearish, the script looks to place a Buy Stop order slightly above the previous day's high.
  2. Sell Condition: Conversely, if the weekly indicators align with a Bullish daily "Force," it looks to place a Sell Stop order slightly below the previous day's low.
  3. Price Protection: The script ensures that these pending orders are placed at a minimum distance from the current market price (16 pips) to avoid accidental execution due to minor price fluctuations.

Trade Management and Automation

Once a trade is active or a pending order exists, the script performs continuous management:

  • Order Updates: If market conditions shift significantly (e.g., the previous day's high/low changes), the script automatically moves the pending orders to the new relevant price levels.
  • Conflict Cancellation: If the weekly trend indicators flip against an existing pending order, the script will automatically delete that pending order to prevent entering a trade against the primary trend.
  • Trailing Stop Loss: For active trades, the script features a dynamic "Trailing Stop." As the market moves in favor of the trade by a certain amount, the stop loss is automatically moved forward. This helps lock in profits while allowing the trade room to continue growing.
  • Profit Taking: Every trade is governed by a fixed Take Profit target set by the user at the time of configuration.

Visual Monitoring

For the user, the script provides a real-time dashboard on the chart. This display shows critical data points including:

  • The current trend directions for both Weekly MACD and OsMA.
  • Whether the Daily Force is currently Bullish or Bearish.
  • Current account balance and equity information.
  • Live tracking of the number of open orders and active trades.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest 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
MACD HistogramMoving Average of OscillatorForce index
13 Views
0 Downloads
0 Favorites
TSD-v11-MT4-JB-OsMA Daily
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

/*[[
	Name := TDSGlobal
	Author := Copyright © 2005 Bob O'Brien / Barcode
	Link := 
	Notes := Based on Alexander Elder's Triple Screen system. To be run only on any chart.
	Lots := 1
	Stop Loss := 0
	Take Profit := 100
	Trailing Stop := 60
]]*/
//+------------------------------------------------------------------+
//|  External Variables                                              |
//+------------------------------------------------------------------+

extern int Lots = 1;
extern int TakeProfit = 100;
extern int Stoploss = 0;
extern int TrailingStop = 60;	
extern int Slippage=5;			// Slippage
extern int StopYear=2005;
extern int MM=0,Leverage=1,AcctSize=10000;

int BuyEntryOrderTicket=0,SellEntryOrderTicket=0,cnt=0,total=0;

double MacdCurrent=0, MacdPrevious=0, MacdPrevious2=0, Direction=0, OsMAPrevious=0, OsMAPrevious2=0, OsMADirection=0;

double newbar=0,PrevDay=0,PrevMonth=0,PrevYear=0,PrevCurtime=0;

double PriceOpen=0;								// Price Open


bool First=True;

double TradesThisSymbol=0;
double ForcePos=0, ForceNeg=0, Force=0,NewPrice=0;
double StartMinute1=0,EndMinute1=0,StartMinute2=0,EndMinute2=0,StartMinute3=0,EndMinute3=0;
double StartMinute4=0,EndMinute4=0,StartMinute5=0,EndMinute5=0,StartMinute6=0,EndMinute6=0;
double StartMinute7=0,EndMinute7=0,DummyField=0;

int start()
{

Comment("TSD for MT4 ver beta 0.2 - DO NOT USE WITH REAL MONEY YET",
        "\n",
        "\n","Weekly MacdPrevious = ",MacdPrevious,"    Weekly OsMAPrevious = ",OsMAPrevious,
        "\n","Weekly MacdPrevious2 = ",MacdPrevious2,"    Weekly OsMAPrevious2 = ",OsMAPrevious2,
        "\n","Weekly Direction = ",Direction,"    Weekly OsMADirection = ",OsMADirection,
        "\n",
        "\n","Daily Force = ",Force,
        "\n","Is Daily Force Bullish = ",ForcePos,
        "\n","Is Daily Force Bearish = ",ForceNeg,
        "\n",
        "\n","Total Orders = ",total,
        "\n","Trades this Symbol(",Symbol(),") = ",TradesThisSymbol,
        "\n",
        "\n","New Bar Time is ",TimeToStr(newbar),
        "\n",
        "\n","Daily High[1] = ",iHigh(NULL,PERIOD_D1,1),
        "\n","Daily High[2] = ",iHigh(NULL,PERIOD_D1,2),
        "\n","Daily Low[1] = ",iLow(NULL,PERIOD_D1,1),
        "\n","Daily Low[2] = ",iLow(NULL,PERIOD_D1,2),
        "\n",AccountBalance(),
        "\n",(AccountEquity()-AccountBalance()),
        "\n","Current Ask Price + 16 pips = ",Ask+(16*Point),
        "\n","Current Bid Price - 16 pips = ",Bid-(16*Point));
        
        
        
  total=OrdersTotal();
     TradesThisSymbol=0;
	  for(cnt=0;cnt<total;cnt++)
     { 
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	      
	      if(OrderSymbol()==Symbol())
	      {
	        TradesThisSymbol ++;
	      } // close for if(OrderSymbol()==Symbol())
	  } // close for for(cnt=0;cnt<total;cnt++)        
        
        
        
        

     
	  MacdPrevious  = iMACD(NULL,10080,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
	  MacdPrevious2 = iMACD(NULL,10080,12,26,9,PRICE_CLOSE,MODE_MAIN,2);
	  
	  OsMAPrevious  = iOsMA(NULL,10080,12,26,9,PRICE_CLOSE,1);
	  OsMAPrevious2 = iOsMA(NULL,10080,12,26,9,PRICE_CLOSE,2);

     Force = iForce(NULL,1440,2,MODE_EMA,PRICE_CLOSE,1); 
     ForcePos = iForce(NULL,1440,2,MODE_EMA,PRICE_CLOSE,1) > 0;
	  ForceNeg = iForce(NULL,1440,2,MODE_EMA,PRICE_CLOSE,1) < 0;

	  
	  if (MacdPrevious > MacdPrevious2) Direction = 1;
	  if (MacdPrevious < MacdPrevious2) Direction = -1;
	  if (MacdPrevious == MacdPrevious2) Direction = 0;
	  
	  if (OsMAPrevious > OsMAPrevious2) OsMADirection = 1;
	  if (OsMAPrevious < OsMAPrevious2) OsMADirection = -1;
	  if (OsMAPrevious == OsMAPrevious2) OsMADirection = 0;
	  
	            
     
	  
// Select a range of minutes in the day to start trading based on the currency pair.
// This is to stop collisions occurring when 2 or more currencies set orders at the same time.

if(Symbol() == "USDCHF")
{
    StartMinute1 = 0;
	EndMinute1   = 1;
    StartMinute2 = 8;
	EndMinute2   = 9;
    StartMinute3 = 16;
	EndMinute3   = 17;
    StartMinute4 = 24;
	EndMinute4   = 25;
    StartMinute5 = 32;
	EndMinute5   = 33;
    StartMinute6 = 40;
	EndMinute6   = 41;
    StartMinute7 = 48;
	EndMinute7   = 49;
} // close for if(Symbol() == "USDCHF")
if(Symbol() == "GBPUSD")
{  
    StartMinute1 = 2;
	EndMinute1   = 3;
    StartMinute2 = 10;
	EndMinute2   = 11;
    StartMinute3 = 18;
	EndMinute3   = 19;
    StartMinute4 = 26;
	EndMinute4   = 27;
    StartMinute5 = 34;
	EndMinute5   = 35;
    StartMinute6 = 42;
	EndMinute6   = 43;
    StartMinute7 = 50;
	EndMinute7   = 51;
} // close for if(Symbol() == "GBPUSD")
if(Symbol() == "USDJPY")
{
    StartMinute1 = 4;
	EndMinute1   = 5;
    StartMinute2 = 12;
	EndMinute2   = 13;
    StartMinute3 = 20;
	EndMinute3   = 21;
    StartMinute4 = 28;
	EndMinute4   = 29;
    StartMinute5 = 36;
	EndMinute5   = 37;
    StartMinute6 = 44;
	EndMinute6   = 45;
    StartMinute7 = 52;
	EndMinute7   = 53;
} //close for if(Symbol() == "USDJPY")
if(Symbol() == "EURUSD")
{
    StartMinute1 = 6;
	EndMinute1   = 7;
    StartMinute2 = 14;
	EndMinute2   = 15;
    StartMinute3 = 22;
	EndMinute3   = 23;
    StartMinute4 = 30;
	EndMinute4   = 31;
    StartMinute5 = 38;
	EndMinute5   = 39;
    StartMinute6 = 46;
	EndMinute6   = 47;
    StartMinute7 = 54;
	EndMinute7   = 59;
} // close for if(Symbol() == "EURUSD")



if( (Minute() >= StartMinute1 && Minute() <= EndMinute1) ||
   (Minute() >= StartMinute2 && Minute() <= EndMinute2) ||
   (Minute() >= StartMinute3 && Minute() <= EndMinute3) ||
   (Minute() >= StartMinute4 && Minute() <= EndMinute4) ||
   (Minute() >= StartMinute5 && Minute() <= EndMinute5) ||
   (Minute() >= StartMinute6 && Minute() <= EndMinute6) ||
   (Minute() >= StartMinute7 && Minute() <= EndMinute7) )
{
	DummyField = 0; // dummy statement because MT will not allow me to use a continue statement
} // close for LARGE if statement
else return(0);

/////////////////////////////////////////////////
//  Process the next bar details
/////////////////////////////////////////////////

if (newbar != Time[0]) 
{
	 newbar        = Time[0];
	 
	 if(TradesThisSymbol < 1) 
	 {
	   
	   if(OsMADirection == 1 && ForceNeg)
		{
			PriceOpen = iHigh(NULL,PERIOD_D1,1) + 1 * Point;		// Buy 1 point above high of previous candle
			if(PriceOpen > (Ask + 16 * Point))  // Check if buy price is a least 16 points > Ask
			{
				BuyEntryOrderTicket=OrderSend(Symbol(),OP_BUYSTOP,Lots,PriceOpen,Slippage,iLow(NULL,PERIOD_D1,1) - 1 * Point,PriceOpen + TakeProfit * Point,"Buy Entry Order placed at "+CurTime(),0,0,Green);
				return(0);

			} // close for if(PriceOpen > (Ask + 16 * Point))
			else
			{
			   NewPrice = Ask + 16 * Point;
				BuyEntryOrderTicket=OrderSend(Symbol(),OP_BUYSTOP,Lots,NewPrice,Slippage,iLow(NULL,PERIOD_D1,1) - 1 * Point,NewPrice + TakeProfit * Point,"Buy Entry Order placed at "+CurTime(),0,0,Green);
				return(0);
			} // close for else statement
	   } // close for if(Direction == 1 && ForceNeg)
     
     
     if(OsMADirection == -1 && ForcePos)
     {
         PriceOpen = iLow(NULL,PERIOD_D1,1) - 1 * Point;
			if(PriceOpen < (Bid - 16 * Point)) // Check if buy price is a least 16 points < Bid
			{
				SellEntryOrderTicket=OrderSend(Symbol(),OP_SELLSTOP,Lots,PriceOpen,Slippage,iHigh(NULL,PERIOD_D1,1) + 1 * Point,PriceOpen - TakeProfit * Point,"Sell Entry Order placed at "+CurTime(),0,0,Green);
				return(0);
			} // close for if(PriceOpen < (Bid - 16 * Point))
			else
			{
				NewPrice = Bid - 16 * Point;
				SellEntryOrderTicket=OrderSend(Symbol(),OP_SELLSTOP,Lots,NewPrice,Slippage,iHigh(NULL,PERIOD_D1,1) + 1 * Point,NewPrice - TakeProfit * Point,"Sell Entry Order placed at "+CurTime(),0,0,Green);
            return(0);			
			} // close for else statement

      } // close for if(Direction == -1 && ForcePos)
    } //Close of if(TradesThisSymbol < 1)


/////////////////////////////////////////////////
//  Pending Order Management
/////////////////////////////////////////////////

if(TradesThisSymbol > 0)
	{
      total=OrdersTotal();
      for(cnt=0;cnt<total;cnt++)
  	   { 
  	      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

         if(OrderSymbol()==Symbol() && OrderType()==OP_BUYSTOP)
         {

				if(OsMADirection == -1)
  				{ 
  				   OrderDelete(OrderTicket());
	        		return(0); 
				} // close for if(Direction == -1)
			} // close for if(OrderSymbol()==Symbol() && OrderType()==OP_BUYSTOP)

         if(OrderSymbol()==Symbol() && OrderType()==OP_SELLSTOP)
         {

				if(OsMADirection == 1)
  				{ 
  				   OrderDelete(OrderTicket());
	        		return(0); 
				} //close for if(Direction == 1)
			} //close for if(OrderSymbol()==Symbol() && OrderType()==OP_SELLSTOP)


         if(OrderSymbol()==Symbol() && OrderType()==OP_BUYSTOP)
   	   {
				if(iHigh(NULL,PERIOD_D1,1) < iHigh(NULL,PERIOD_D1,2))
	  			{ 
					if(iHigh(NULL,PERIOD_D1,1) > (Ask + 16 * Point))
	  				{ 
	  	   		  OrderModify(OrderTicket(),iHigh(NULL,PERIOD_D1,1) + 1 * Point,iLow(NULL,PERIOD_D1,1) - 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
	  				} //close for if(iHigh(NULL,PERIOD_D1,1) > (Ask + 16 * Point))
	  				else
	  				{
	  				  OrderModify(OrderTicket(),Ask + 16 * Point,iLow(NULL,PERIOD_D1,1) - 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
	  				
	  				} //close for else statement
	  			} //close for if(iHigh(NULL,PERIOD_D1,1) < iHigh(NULL,PERIOD_D1,2))
	  		} //close for if(OrderSymbol()==Symbol() && OrderType()==OP_BUYSTOP)
	  
	      if(OrderSymbol()==Symbol() && OrderType()==OP_SELLSTOP)
   		{
				if(iLow(NULL,PERIOD_D1,1) > iLow(NULL,PERIOD_D1,2))
				{ 
					if(iLow(NULL,PERIOD_D1,1) < (Bid - 16 * Point))
					{
		   		  OrderModify(OrderTicket(),iLow(NULL,PERIOD_D1,1) - 1 * Point,iHigh(NULL,PERIOD_D1,1) + 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
					} // close for if(iLow(NULL,PERIOD_D1,1) < (Bid - 16 * Point))
					else
					{
					  OrderModify(OrderTicket(),Bid - 16 * Point,iHigh(NULL,PERIOD_D1,1) + 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
      
					} //close for else statement
				} //close for if(iLow(NULL,PERIOD_D1,1) > iLow(NULL,PERIOD_D1,2))
			} //close for if(OrderSymbol()==Symbol() && OrderType()==OP_SELLSTOP)
		} // close for for(cnt=0;cnt<total;cnt++)
	} // close for if(TradesThisSymbol > 0)
} // close for if (newbar != Time[0]) 


/////////////////////////////////////////////////
//  Stop Loss Management
/////////////////////////////////////////////////
if(TradesThisSymbol > 0)
{
  total=OrdersTotal();
  for(cnt=0;cnt<total;cnt++)
  { 
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

     if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
    	{
			if(Ask-OrderOpenPrice() > (TrailingStop * Point))
  			{ 
				if(OrderStopLoss() < (Ask - TrailingStop * Point))
				{ 
	   		   OrderModify(OrderTicket(),OrderOpenPrice(),Ask - TrailingStop * Point,Ask + TakeProfit * Point,0,Cyan);
               return(0);					

				} // close for if(OrderStopLoss() < (Ask - TrailingStop * Point))
			} // close for if(Ask-OrderOpenPrice() > (TrailingStop * Point))
		} // close for if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
	
     if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
		{
			if(OrderOpenPrice() - Bid > (TrailingStop * Point))
			{ 
				if(OrderStopLoss() > (Bid + TrailingStop * Point))
				{ 
	   		   OrderModify(OrderTicket(),OrderOpenPrice(),Bid + TrailingStop * Point,Bid - TakeProfit * Point,0,Cyan);
               return(0);					

				} // close for if(OrderStopLoss() > (Bid + TrailingStop * Point))
			} // close for if(OrderOpenPrice() - Bid > (TrailingStop * Point))
		 } // close for if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
  	  } // close for for(cnt=0;cnt<total;cnt++)
   } // close for if(TradesThisSymbol > 0)
  
	

//return(0);

} // close for start

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
16 reports
NZD/USD Jul 2025 - Sep 2025
1.97
Total Trades 17
Won Trades 16
Lost trades 1
Win Rate 94.12 %
Expected payoff 43.06
Gross Profit 1487.00
Gross Loss -755.00
Total Net Profit 732.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.33
Total Trades 19
Won Trades 18
Lost trades 1
Win Rate 94.74 %
Expected payoff 16.87
Gross Profit 1292.56
Gross Loss -972.11
Total Net Profit 320.45
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.04
Total Trades 35
Won Trades 33
Lost trades 2
Win Rate 94.29 %
Expected payoff 1.81
Gross Profit 1711.61
Gross Loss -1648.43
Total Net Profit 63.18
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.95
Total Trades 24
Won Trades 21
Lost trades 3
Win Rate 87.50 %
Expected payoff -2.69
Gross Profit 1364.29
Gross Loss -1428.95
Total Net Profit -64.66
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.91
Total Trades 18
Won Trades 14
Lost trades 4
Win Rate 77.78 %
Expected payoff -8.17
Gross Profit 1579.00
Gross Loss -1726.00
Total Net Profit -147.00
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.74
Total Trades 54
Won Trades 48
Lost trades 6
Win Rate 88.89 %
Expected payoff -19.75
Gross Profit 3104.13
Gross Loss -4170.77
Total Net Profit -1066.64
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.71
Total Trades 24
Won Trades 20
Lost trades 4
Win Rate 83.33 %
Expected payoff -21.48
Gross Profit 1256.40
Gross Loss -1771.85
Total Net Profit -515.45
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.67
Total Trades 24
Won Trades 21
Lost trades 3
Win Rate 87.50 %
Expected payoff -30.58
Gross Profit 1480.00
Gross Loss -2214.00
Total Net Profit -734.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.63
Total Trades 33
Won Trades 29
Lost trades 4
Win Rate 87.88 %
Expected payoff -33.61
Gross Profit 1876.00
Gross Loss -2985.00
Total Net Profit -1109.00
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.57
Total Trades 55
Won Trades 47
Lost trades 8
Win Rate 85.45 %
Expected payoff -47.12
Gross Profit 3487.88
Gross Loss -6079.57
Total Net Profit -2591.69
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.51
Total Trades 41
Won Trades 34
Lost trades 7
Win Rate 82.93 %
Expected payoff -47.98
Gross Profit 2014.00
Gross Loss -3981.00
Total Net Profit -1967.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.48
Total Trades 16
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -108.06
Gross Profit 1585.00
Gross Loss -3314.00
Total Net Profit -1729.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.37
Total Trades 11
Won Trades 5
Lost trades 6
Win Rate 45.45 %
Expected payoff -205.69
Gross Profit 1349.08
Gross Loss -3611.67
Total Net Profit -2262.59
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.34
Total Trades 37
Won Trades 29
Lost trades 8
Win Rate 78.38 %
Expected payoff -82.68
Gross Profit 1565.00
Gross Loss -4624.00
Total Net Profit -3059.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.28
Total Trades 22
Won Trades 16
Lost trades 6
Win Rate 72.73 %
Expected payoff -123.41
Gross Profit 1038.00
Gross Loss -3753.00
Total Net Profit -2715.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.14
Total Trades 10
Won Trades 4
Lost trades 6
Win Rate 40.00 %
Expected payoff -306.81
Gross Profit 500.10
Gross Loss -3568.25
Total Net Profit -3068.15
-100%
-50%
0%
50%
100%

Comments