TSD-v11-MT4-JB-OsMA Jan 4 hour

Profit factor:
312.07
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
10 Views
0 Downloads
0 Favorites
TSD-v11-MT4-JB-OsMA Jan 4 hour
/*-----------------------------+
|			       |
| 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 a Weekly 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] = ",High[1],
        "\n","Daily High[2] = ",High[2],
        "\n","Daily Low[1] = ",Low[1],
        "\n","Daily Low[2] = ",Low[2],
        "\n",
        "\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 = High[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,Low[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,Low[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 = Low[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,High[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,High[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(High[1] < High[2])
	  			{ 
					if(High[1] > (Ask + 16 * Point))
	  				{ 
	  	   		  OrderModify(OrderTicket(),High[1] + 1 * Point,Low[1] - 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
	  				} //close for if(High[1] > (Ask + 16 * Point))
	  				else
	  				{
	  				  OrderModify(OrderTicket(),Ask + 16 * Point,Low[1] - 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
	  				
	  				} //close for else statement
	  			} //close for if(High[1] < High[2])
	  		} //close for if(OrderSymbol()==Symbol() && OrderType()==OP_BUYSTOP)
	  
	      if(OrderSymbol()==Symbol() && OrderType()==OP_SELLSTOP)
   		{
				if(Low[1] > Low[2])
				{ 
					if(Low[1] < (Bid - 16 * Point))
					{
		   		  OrderModify(OrderTicket(),Low[1] - 1 * Point,High[1] + 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
					} // close for if(Low[1] < (Bid - 16 * Point))
					else
					{
					  OrderModify(OrderTicket(),Bid - 16 * Point,High[1] + 1 * Point,OrderTakeProfit(),0,Cyan);
                 return(0);					
      
					} //close for else statement
				} //close for if(Low[1] > Low[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

EUR/USD Jul 2025 - Sep 2025
5831.04
Total Trades 363
Won Trades 222
Lost trades 141
Win Rate 61.16 %
Expected payoff 183028.02
Gross Profit 66450565.00
Gross Loss -11396.00
Total Net Profit 66439169.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
3514.53
Total Trades 225
Won Trades 153
Lost trades 72
Win Rate 68.00 %
Expected payoff 149973.28
Gross Profit 33753591.00
Gross Loss -9604.00
Total Net Profit 33743987.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.07
Total Trades 156
Won Trades 88
Lost trades 68
Win Rate 56.41 %
Expected payoff 2.86
Gross Profit 6415.30
Gross Loss -5968.68
Total Net Profit 446.62
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.90
Total Trades 385
Won Trades 213
Lost trades 172
Win Rate 55.32 %
Expected payoff -4.73
Gross Profit 16168.06
Gross Loss -17989.62
Total Net Profit -1821.56
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.85
Total Trades 355
Won Trades 192
Lost trades 163
Win Rate 54.08 %
Expected payoff -8.44
Gross Profit 16599.00
Gross Loss -19596.00
Total Net Profit -2997.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.83
Total Trades 176
Won Trades 118
Lost trades 58
Win Rate 67.05 %
Expected payoff -6.88
Gross Profit 5924.33
Gross Loss -7135.08
Total Net Profit -1210.75
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.80
Total Trades 207
Won Trades 132
Lost trades 75
Win Rate 63.77 %
Expected payoff -9.07
Gross Profit 7739.00
Gross Loss -9617.00
Total Net Profit -1878.00
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.73
Total Trades 466
Won Trades 296
Lost trades 170
Win Rate 63.52 %
Expected payoff -14.88
Gross Profit 19217.00
Gross Loss -26149.00
Total Net Profit -6932.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.71
Total Trades 261
Won Trades 157
Lost trades 104
Win Rate 60.15 %
Expected payoff -13.24
Gross Profit 8443.00
Gross Loss -11898.00
Total Net Profit -3455.00
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.68
Total Trades 455
Won Trades 270
Lost trades 185
Win Rate 59.34 %
Expected payoff -17.68
Gross Profit 17105.96
Gross Loss -25152.49
Total Net Profit -8046.53
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.68
Total Trades 467
Won Trades 334
Lost trades 133
Win Rate 71.52 %
Expected payoff -17.00
Gross Profit 16612.85
Gross Loss -24551.53
Total Net Profit -7938.68
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.68
Total Trades 314
Won Trades 196
Lost trades 118
Win Rate 62.42 %
Expected payoff -13.22
Gross Profit 8706.70
Gross Loss -12856.43
Total Net Profit -4149.73
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.65
Total Trades 161
Won Trades 94
Lost trades 67
Win Rate 58.39 %
Expected payoff -21.58
Gross Profit 6365.00
Gross Loss -9839.00
Total Net Profit -3474.00
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.64
Total Trades 349
Won Trades 198
Lost trades 151
Win Rate 56.73 %
Expected payoff -27.58
Gross Profit 16994.47
Gross Loss -26619.75
Total Net Profit -9625.28
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.63
Total Trades 171
Won Trades 91
Lost trades 80
Win Rate 53.22 %
Expected payoff -20.35
Gross Profit 5822.58
Gross Loss -9302.83
Total Net Profit -3480.25
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.63
Total Trades 157
Won Trades 91
Lost trades 66
Win Rate 57.96 %
Expected payoff -20.65
Gross Profit 5521.22
Gross Loss -8762.64
Total Net Profit -3241.42
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.63
Total Trades 235
Won Trades 125
Lost trades 110
Win Rate 53.19 %
Expected payoff -15.92
Gross Profit 6448.78
Gross Loss -10190.92
Total Net Profit -3742.14
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.56
Total Trades 167
Won Trades 79
Lost trades 88
Win Rate 47.31 %
Expected payoff -19.01
Gross Profit 4052.05
Gross Loss -7226.60
Total Net Profit -3174.55
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.54
Total Trades 408
Won Trades 267
Lost trades 141
Win Rate 65.44 %
Expected payoff -23.59
Gross Profit 11520.00
Gross Loss -21146.00
Total Net Profit -9626.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.54
Total Trades 231
Won Trades 91
Lost trades 140
Win Rate 39.39 %
Expected payoff -17.19
Gross Profit 4703.11
Gross Loss -8673.63
Total Net Profit -3970.52
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.53
Total Trades 222
Won Trades 69
Lost trades 153
Win Rate 31.08 %
Expected payoff -20.81
Gross Profit 5202.00
Gross Loss -9822.00
Total Net Profit -4620.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.52
Total Trades 157
Won Trades 59
Lost trades 98
Win Rate 37.58 %
Expected payoff -26.75
Gross Profit 4543.00
Gross Loss -8742.00
Total Net Profit -4199.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.51
Total Trades 156
Won Trades 57
Lost trades 99
Win Rate 36.54 %
Expected payoff -19.54
Gross Profit 3128.00
Gross Loss -6177.00
Total Net Profit -3049.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.50
Total Trades 154
Won Trades 56
Lost trades 98
Win Rate 36.36 %
Expected payoff -30.85
Gross Profit 4682.00
Gross Loss -9433.00
Total Net Profit -4751.00
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.48
Total Trades 236
Won Trades 126
Lost trades 110
Win Rate 53.39 %
Expected payoff -38.98
Gross Profit 8481.61
Gross Loss -17681.62
Total Net Profit -9200.01
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.48
Total Trades 306
Won Trades 137
Lost trades 169
Win Rate 44.77 %
Expected payoff -32.11
Gross Profit 9214.00
Gross Loss -19040.00
Total Net Profit -9826.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.41
Total Trades 216
Won Trades 113
Lost trades 103
Win Rate 52.31 %
Expected payoff -39.68
Gross Profit 6060.20
Gross Loss -14631.12
Total Net Profit -8570.92
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.21
Total Trades 166
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -57.81
Gross Profit 2492.00
Gross Loss -12088.00
Total Net Profit -9596.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.10
Total Trades 125
Won Trades 14
Lost trades 111
Win Rate 11.20 %
Expected payoff -73.63
Gross Profit 999.81
Gross Loss -10203.26
Total Net Profit -9203.45
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 105
Won Trades 0
Lost trades 105
Win Rate 0.00 %
Expected payoff -94.30
Gross Profit 0.00
Gross Loss -9901.00
Total Net Profit -9901.00
-100%
-50%
0%
50%
100%

Comments