The MQ4 file is there too. Just change the .ex4 in the previous link to .mq4
Here it is in full as well. I just added a 50 pip trailing stop as well in this code (not there in the linked file). It doesn’t change the profit much, just a little less draw down.
//+------------------------------------------------------------------+
//| Slingshot System.mq4 |
//| Copyright � 2008, Brian Redmond |
//| http://www.brianredmond.net/forex/slingshot |
//+------------------------------------------------------------------+
#property copyright "Copyright � 2009, Brian Redmond"
#property link "[email protected]"
//---- input parameters
extern double Lots=0.1;
bool tradeOpen=false;
int ticket,diff,tickNum[5];
double sl,spread,profTest=50.0;
bool NewBar()
{
static datetime lastbar = 0;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return (true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void shortTrade()
{
sl=High[0]+Point;
if(sl<(Bid+(10*Point))) sl=Bid+(10*Point);
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,sl,0);
if(ticket<0)
{
Print("Error # ",GetLastError());
return(0);
}
}
void longTrade()
{
sl=Low[0]-Point;
if(sl>(Ask-(10*Point))) sl=Ask-(10*Point);
if(tradeOpen==true) sl=Ask-(30*Point);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,sl,0);
if(ticket<0)
{
Print("Error # ",GetLastError());
return(0);
}
}
bool checkPrior()
{
diff=(MathAbs(High[1]-Low[1]))/Point;
if(diff>=20) return(true);
else return(false);
}
int tradeDir()
{
if(Close[1]>Open[1]) return(-1);
else
{
if(Close[1]<Open[1]) return(1);
else return(0);
}
}
int start()
{
if((NewBar() == true)||((DayOfWeek()==6)&&(Hour()==20)))
{ // Close orders with new candlde or on Friday to avoid gaps
if(tradeOpen==true)
{
int total = OrdersTotal();
int cnt = 0;
int t = 0, x = 0;
for (cnt = total ; cnt >0 ; cnt--)
{
OrderSelect((cnt - 1),SELECT_BY_POS,MODE_TRADES);
tickNum[t]=OrderTicket();
t++;
}
for (x=(total-1);x>=0;x--)
{
OrderSelect(tickNum[x],SELECT_BY_TICKET);
if(OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),Bid,0);
if(OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots(),Ask,0);
}
tradeOpen=false;
}
} //End New Bar
if((Hour()>=7)&&(Hour()<20))
{
if((checkPrior()==true)&&(tradeOpen==false))
{
spread = (MarketInfo(Symbol(),MODE_SPREAD)*Point);
if(tradeDir()==1)
{
if((Low[0]<Low[1])&&((Ask-spread)>(Close[1]-spread)))
{
longTrade();
tradeOpen=true;
}
}
if(tradeDir()==-1)
{
if((High[0]>High[1])&&((Bid+spread)<(Close[1]+spread)))
{
shortTrade();
tradeOpen=true;
}
}
}
if(tradeOpen==true)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==true)
{
if(OrderProfit()>=profTest)
{
if(tradeDir()==1) sl=OrderStopLoss()+(50*Point);
else sl=OrderStopLoss()-(50*Point);
OrderModify(OrderTicket(),OrderOpenPrice(),sl,0,0);
profTest=profTest+50.0;
}
}
else Alert("Error # ",GetLastError());
}
}
return(0);
}
//+------------------------------------------------------------------+