Siscop2DayBreakOut





#property copyright "siscop"

// ---- input externe variabeln
extern double Lots=0.1;
extern double pipsize=0.0001;
extern int puffer=3;
extern int TP=20;
extern int SL=10;
extern int TS=10;
extern int magic=12345;

// ---- init
int init()
{
	return(0);
}

// ---- deinit()
int deinit()
{
	return(0);
}

// ---- start
int start()
{

// ---- Variabeln
	static bool long;
	static bool short;
	static double TPPreis;
	static double SLPreis;

	double DHighVortag;
	double DLowVortag;
	double DHighHeute;
	double DLowHeute;
	int WochenTagHeute;
	int WochenTagVortag;
	int AnzahlBalkenHeute;
	int AnzahlBalkenVortag;
	static int ticket;
	int tmp;

// ---- WochenTagBestimmung
	
	WochenTagHeute=TimeDayOfWeek(TimeCurrent());
	
	switch(WochenTagHeute)
  	{
   	case 0:
		case 1:
      			WochenTagVortag=5;
      			break;
   	case 2:
   	case 3:
		case 4:
		case 5:
		case 6:
      			WochenTagVortag=WochenTagHeute-1;
             	break;
   	default:
      			Print("WochenTagFehler");
      			break;
  	}	

	AnzahlBalkenVortag=0;
	AnzahlBalkenHeute=0;
	tmp=0;
	while(true)
	{
		int WochenTagTmp=TimeDayOfWeek(Time[AnzahlBalkenVortag]);
		if (WochenTagTmp == WochenTagHeute)
		{
   		AnzahlBalkenHeute++;
			AnzahlBalkenVortag++;
			continue;
		}
	
 		if (WochenTagTmp == WochenTagVortag)
		{
		   tmp=1;
			AnzahlBalkenVortag++;
			continue;
		}
		if (tmp==0)
		{
			AnzahlBalkenVortag++;
			continue;
		}	
		break;
	}

// ---- HighLow von Heute und Vortagbestimmung

	DHighHeute=High[0];
	DLowHeute=Low[0];
	for (int i=2;i<=AnzahlBalkenHeute;i++)
	{
		if (DHighHeute<High[i])
			DHighHeute=High[i];
		if (DLowHeute>Low[i])
			DLowHeute=Low[i];
	}

	DHighVortag=High[AnzahlBalkenVortag-AnzahlBalkenHeute+1];
	DLowVortag=Low[AnzahlBalkenVortag-AnzahlBalkenHeute+1];
	for (i=AnzahlBalkenHeute+1;i<=AnzahlBalkenVortag;i++)
	{
		if (DHighVortag<High[i])
			DHighVortag=High[i];
		if (DLowVortag>Low[i])
			DLowVortag=Low[i];
	}

// ---- Kauf / Verkauf

	if (!long && !short)
	{
// ---- Kauf
		if (High[1]>DHighHeute && High[1]>DHighVortag)
		{
			if ((Close[0]+(puffer*pipsize))>High[1])
			{
				ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"2DayBreakOut",magic,0,Green);
				if(ticket>0)
				{
					if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
						Print("BUY order opened : ",OrderOpenPrice());
					long=true;
					// TPPreis=OrderOpenPrice()+(TP*pipsize);
				}
				else Print("Error opening BUY order : ",GetLastError());
				return(0);
			}
		}
// ---- Verkauf
		if (Low[1]<DLowHeute && Low[1]<DLowVortag)
		{
			if ((Close[0]-(puffer*pipsize))<Low[1])
			{
				ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"2DayBreakOut",magic,0,Red);
				if(ticket>0)
				{
					if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
						Print("SELL order opened : ",OrderOpenPrice());
					short=true;
					// TPPreis=OrderOpenPrice()-(TP*pipsize);
				}
				else Print("Error opening SELL order : ",GetLastError());
				return(0);
			}
		}
	}

	if (long || short)
		OrderSelect(0, SELECT_BY_POS, MODE_TRADES);

// ---- TrailingStop StopLoss Berechnung

	if(TS>0)
	{
		if (long)
		{
			if((High[0]-(TS*pipsize))>SLPreis)
			{
				SLPreis=High[0]-(TS*pipsize);
			}
		}
		if (short)
		{
			if((Low[0]+(TS*pipsize))<SLPreis)
			{
				SLPreis=Low[0]+(TS*pipsize);
			}
		}
	}
	else
		SLPreis=OrderOpenPrice()-(SL*pipsize);

// ---- TakeProfit Berechnung
	
	if (TP!=0)
	{
		if (long)
		{
			TPPreis=OrderOpenPrice()+(TP*pipsize);
		}
		if (short)
		{
			TPPreis=OrderOpenPrice()-(TP*pipsize);
		}
	}
	else
		TPPreis=9999999;

// ---- EXITKauf / Verkauf StopLoss

	if (long)
	{
		if (Close[0]<SLPreis)
		{
			OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
			long=false;
		}
	}
	if (short)
	{
		if (Close[0]>SLPreis)
		{
			OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
			short=false;
		}
	}

// ---- EXITKauf / Verkauf TakeProfit

	if (long)
	{
		if (Close[0]>TPPreis)
		{
			OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
			long=false;
		}
	}
	if (short)
	{
		if (Close[0]<TPPreis)
		{
			OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
			short=false;
		}
	}
	Print ("long",long);
	Print ("short",short);
	Print ("ticket",ticket);
}





Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains close prices for each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:
It automatically opens orders when conditions are reached

It Closes Orders by itself

Other Features:

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.52 Total Net Profit:-1095.18

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.06 Total Net Profit:-3539.35

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.42 Total Net Profit:-2864.92

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:2.03 Total Net Profit:10070.65

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.31 Total Net Profit:-10818.48

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:1.72 Total Net Profit:604.60

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.80 Total Net Profit:-2353.94

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-05-01 to 2010-05-31 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-06-01 to 2010-06-30 Profit Factor:0.00 Total Net Profit:0.00

Request Backtest for Siscop2DayBreakOut


From : (yyyy/mm/dd) To: (yyyy/mm/dd)

Pair: Period: