Profitable EA. I just need a bit of help..

 

Hello,

Here is a great EA based on price action that goes after highs and lows. It trades on USDJPY as this currency seems to be the most consistent. It makes money and can even outrun commission.

What I need:

The EA is simple. Right now it's taking the dailyhigh and dailylow variables from the broker's server time rather than taking these variable starting from from 0 GMT. I need someone to make it so that the EA takes these variables starting from from 0 GMT so that the EA can be used with brokers who don't have 0 GMT as their server time. The timing with this EA is extremely important so this needs to be done right.

Hopefully some rockstar out there can help me - you'll get a great EA too!

Thanks! Here is the code below:

//USDJPY Daily Breakout // dailyhigh and dailylow should be taken starting from 0 GMT.



#include

extern int myMagic = 12345;

extern double TakeProfit =180;
extern bool PartialClosing =true;
extern int TPDivide = 2;
extern double StopLoss =25;
extern int TrailingStop =0;
extern double BreakEvenStop =90;

extern int slippage=5;
extern int shift=0;

extern double Lots = 0.01;
extern double MaximumRisk = 0.002; //AccountFreeMargin x MaximumRisk / 1000 = Lots
extern bool FixedLot = false;

extern int TimeStart1=100; // Set this so that the EA starts 1 hour after 0 GMT.
extern int TimeStop1=1200;

extern int TimeStart2=0000;
extern int TimeStop2=0000;

extern int TimeStart3=0000;
extern int TimeStop3=0000;

extern int TimeStart4=0000;
extern int TimeStop4=0000;

extern int OrderTriesNumber=25;

bool buysig,sellsig,closebuy,closesell; int lastsig,tries;


double LotsRisk(int StopLoss) {
double lot=Lots;
//---- select lot size
if (!FixedLot && (StopLoss > 0))
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000,2);
else
lot=Lots;
//---- return lot size
if(lot<0.01) lot=0.01;
return(lot);
}

//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==myMagic)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForSignals(datetime) {

double dailyhigh=iHigh(NULL,PERIOD_D1,0);
double dailylow=iLow(NULL,PERIOD_D1,0);
double dailyopen=iOpen(NULL,PERIOD_D1,0);

double dailyhigh1=iHigh(NULL,PERIOD_D1,1);
double dailylow1=iLow(NULL,PERIOD_D1,1);

double high=iHighest(NULL,0,MODE_HIGH,100,0);
double low=iLowest(NULL,0,MODE_LOW,100,0);

int ct;
ct=Hour()*100+Minute();


sellsig=false;
buysig=false;

{
if


(Close[0]>dailyhigh-3*Point)


{
buysig=true;
}
if
(Close[0]<dailylow+3*Point)

{
sellsig=true;
}

}
closebuy=false;
closesell=false;

if (High[0]<Low[0]) {
closebuy=true;
}
if (High[0]<Low[0]) {
closesell=true;
}
}

datetime CheckForOpen(datetime orderopenbar) {
int res,ct;
datetime result = orderopenbar;
ct=Hour()*100+Minute();
if

( !((ct>=TimeStart1 && ct=TimeStart2 && ct<TimeStop2) ||

(ct>=TimeStart3 && ct=TimeStart4 && ct<TimeStop4)) ) return(result);

double takeProfit;
double SetLots=0;
string EAComment="USDJPY Daily Breakout";
//---- sell conditions
if(sellsig && lastsig!=-1) {
res=0;
tries=0;
while (res<=0 && tries<OrderTriesNumber) {
while(!IsTradeAllowed()) Sleep(5000);
RefreshRates();
if(TakeProfit > MarketInfo(Symbol(), MODE_STOPLEVEL))
takeProfit = Bid-TakeProfit*Point;
else
takeProfit = 0;
SetLots=LotsRisk(StopLoss);
EAComment="USDJPY Daily Breakout";
res=OrderSend(Symbol(),OP_SELL,SetLots,Bid,slippage,Bid+StopLoss*Point,
takeProfit,EAComment,myMagic,0,DeepPink);
if (res<0)
Print("Error opening SELL order : ",ErrorDescription(GetLastError()));
else
result = Time[0]; // return this bar open time.
tries++;
}
lastsig= 0;
return(result);
}
//---- buy conditions
if(buysig && lastsig!=1) {
res=0;
tries=0;
while (res<=0 && tries<OrderTriesNumber) {
while(!IsTradeAllowed()) Sleep(5000);
RefreshRates();
if(TakeProfit > MarketInfo(Symbol(), MODE_STOPLEVEL))
takeProfit = Ask+TakeProfit*Point;
else
takeProfit = 0;
SetLots=LotsRisk(StopLoss);
EAComment="USDJPY Daily Breakout";
res=OrderSend(Symbol(),OP_BUY,LotsRisk(StopLoss),Ask,slippage,Ask-StopLoss*Point,
takeProfit,EAComment,myMagic,0,Yellow);
if (res<0)
Print("Error opening BUY order : ",ErrorDescription(GetLastError()));
else
result = Time[0]; // return this bar open Time
tries++;
}
lastsig = 0;
return(result);
}
return(result);
}


//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose() {
bool bres; int tr;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=myMagic || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
if (closebuy) {
bres=false;
tries=0;
while (!bres && tries<OrderTriesNumber) {
while(tr<7 && !IsTradeAllowed()) { tr++; Sleep(5000); }
RefreshRates();
bres=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,White);
Sleep(3000);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
tries++;
}
}
else
if(PartialClosing) PartialClosingExe();
break;
}
if(OrderType()==OP_SELL)
{
if (closesell) {
bres=false;
tries=0;
while (!bres && tries<OrderTriesNumber) {
while(tr<7 && !IsTradeAllowed()) { tr++; Sleep(5000); }
RefreshRates();
bres=OrderClose(OrderTicket(),OrderLots(),Ask,slippage,White);
Sleep(3000);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
tries++;
}
}
else
if(PartialClosing) PartialClosingExe();
break;
}
}
}


void BreakEvenStop() {
bool bres;
double StopLoss;
if ( BreakEvenStop > 2 ) {
for (int i = 0; i < OrdersTotal(); i++) {
if ( OrderSelect (i, SELECT_BY_POS) == false ) continue;
if ( OrderSymbol() != Symbol() || OrderMagicNumber() != myMagic ) continue;
if ( OrderType() == OP_BUY ) {
if ( (Bid < OrderOpenPrice()+BreakEvenStop*Point) ) return;
StopLoss = OrderOpenPrice();
if ( StopLoss > OrderStopLoss() ) {
bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss+10*Point, OrderTakeProfit(), 0, White);
Sleep(3000);
if (!bres) Print("Error Modifying BUY order : ",ErrorDescription(GetLastError()));
}
}

if ( OrderType() == OP_SELL ) {
if ( (Ask > OrderOpenPrice()-BreakEvenStop*Point) ) return;
StopLoss = OrderOpenPrice();
if ( StopLoss < OrderStopLoss() ) {
bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss-10*Point, OrderTakeProfit(), 0, White);
Sleep(3000);
if (!bres) Print("Error Modifying SELL order : ",ErrorDescription(GetLastError()));
}
}
}
}
return;
}

void TrailingStop() {
bool bres;
double StopLoss;
if ( TrailingStop > MarketInfo(Symbol(), MODE_STOPLEVEL)) {
for (int i = 0; i < OrdersTotal(); i++) {
if ( OrderSelect (i, SELECT_BY_POS) == false ) continue;
if ( OrderSymbol() != Symbol() || OrderMagicNumber() != myMagic ) continue;
if ( OrderType() == OP_BUY ) {
if ( (Bid < OrderStopLoss()+TrailingStop*Point) ) return;
StopLoss = Bid-TrailingStop*Point;
if ( StopLoss > OrderStopLoss() ) {
bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss, OrderTakeProfit(), 0, White);
Sleep(3000);
if (!bres) Print("Error Modifying BUY order : ",ErrorDescription(GetLastError()));
}
}

if ( OrderType() == OP_SELL ) {
if ( (Ask > OrderStopLoss()-TrailingStop*Point) ) return;
StopLoss = Ask+TrailingStop*Point;
if ( StopLoss < OrderStopLoss() ) {
bres=OrderModify (OrderTicket(), OrderOpenPrice(), StopLoss, OrderTakeProfit(), 0, White);
Sleep(3000);
if (!bres) Print("Error Modifying SELL order : ",ErrorDescription(GetLastError()));
}
}
}
}
return;
}

double RoundLots(string S, double P)
{
double value=P;
double MinimalLot=0;
MinimalLot=MarketInfo(S,MODE_MINLOT);
if(MinimalLot<=0)
{
RefreshRates();
return(-1);
}
value=MathFloor(P/MinimalLot)*MinimalLot;
return(value);
}

//+------------------------------------------------------------------+
//| Linear closing of position |
//+------------------------------------------------------------------+
void PartialClosingExe()
{
int Profit=0;
if(OrderType()==OP_BUY) Profit=MathRound((Bid-OrderOpenPrice())/Point);
if(OrderType()==OP_SELL) Profit=MathRound((OrderOpenPrice()-Ask)/Point);
if(Profit<=0) return;
int PipStep=MathFloor(TakeProfit/TPDivide);
if(PipStep<1) PipStep=1;
if(PipStep>TakeProfit) PipStep=TakeProfit;
double LotPercent=1.00/TPDivide;
if(LotPercent>1.00) LotPercent=1.00;
if(TPDivide>TakeProfit && TakeProfit>0) LotPercent=1.00/TakeProfit;
double FirstPosition=LotsRisk(StopLoss);
double CutLots=FirstPosition*LotPercent*MathFloor(Profit/PipStep);
CutLots=RoundLots(Symbol(),CutLots);
if(CutLots<=0) return;
CutLots=CutLots-(FirstPosition-OrderLots());
if(CutLots<=0) return;
if(OrderLots()<CutLots) CutLots=OrderLots();
if(OrderType()==OP_BUY)
OrderClose(OrderTicket(),CutLots,Bid,slippage,White);
if(OrderType()==OP_SELL)
OrderClose(OrderTicket(),CutLots,Ask,slippage,White);

return;
}

void start() {
static datetime TradeOpenBar;

//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;

//---- check for signals
CheckForSignals(TradeOpenBar);

//---- calculate open orders by current symbol
if (CalculateCurrentOrders(Symbol())==0)
TradeOpenBar = CheckForOpen(TradeOpenBar);
else
CheckForClose();

BreakEvenStop();
TrailingStop();
}
//+------------------------------------------------------------------+

 

Here is another version of the system that martingales at 1.2 times. If the same mod could be done to this code as well that would be awesome. Thanks so much.

Here is the code:



//USDJPY Daily Breakout 2// dailyhigh and dailylow should be taken starting from 0 GMT.


#include
#include
#define name "USDJPY Daily Breakout 2"
bool DEBUG=true;

extern string comment=name;
extern int MagicNumber=54321;
extern bool useFixedLots=false;
extern double FixedLots=0.02;
extern double RiskPerTrade=0.01;

extern int slippage=1;
extern bool EveryTick=true;
extern string HeaderMartingale="=== Martingale";
extern bool StartOverAfterEAReload=true;
extern double MartingaleMultiplier=1.2;
extern int PointsToEnter=5;
extern int PointsToExit=5;

extern int stoploss_points=25;
extern int takeprofit_points=180;
//breakeven
extern bool use_breakeven=true;
extern int breakeven_threshold_points=90;
extern int breakeven_addition_points=5;
//trailing stop
extern bool useTrailingStop=false;
extern int trailingStop_threshold=01;
extern int trailingStop_trail=01;

//order repetition
int repeat=30;//new
int sleep_interval=1000;//new

datetime start_time=0;

int init()

{
if(StartOverAfterEAReload)
{
start_time=TimeCurrent();
}
else start_time=0;
return(0);
}

int deinit()
{
return(0);
}

int start()
{
if(IsNewBar() || EveryTick)
{
if(ExitLong()) CloseLong();
if(ExitShort()) CloseShort();
if(LongSignal() && NoTrades() && (!ExitLong()))
{
EnterLong();
}
else if(ShortSignal() && NoTrades() && (!ExitShort()))
{
EnterShort();
}
}
AssignSL();
Breakeven();
Trail();
return(0);
}


bool IsNewBar()
{
static datetime last_time = 0;
datetime lastbar_time = Time[0];

if(0 == last_time)
{ // only just after initialization
last_time=lastbar_time;
return( false);
}

if(last_time!=lastbar_time)
{
last_time = lastbar_time;
return( true);
}

return (false);
}


bool NoTrades()
{
int total=OrdersTotal();
for(int n=0;n<total;n++)
{
if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderCloseTime()!=0) continue;
if((OrderType()==OP_SELL) || (OrderType()==OP_BUY))
{
return (false);
}
}
return (true);
}

void EnterLong()
{

int res=-1;
for(int i=0;(i<repeat) && (res<0);i++)
{
RefreshRates();
res=OrderSend(Symbol(),OP_BUY,Lots(),Ask,slippage,0,0,comment,MagicNumber,0,Yellow);
if(res<0)
{
PrintError(Symbol());
Sleep(sleep_interval);
}
else break;
}
}

void EnterShort()
{

int res=-1;
for(int i=0;(i<repeat) && (res<0);i++)
{
RefreshRates();
res=OrderSend(Symbol(),OP_SELL,Lots(),Bid,slippage,0,0,comment,MagicNumber,0,DeepPink);
if(res<0)
{
PrintError(Symbol());
Sleep(sleep_interval);
}
else break;
}
}

void Breakeven()
{
if(!use_breakeven) return;
double sl=-1;
int total=OrdersTotal();
for(int n=0;n<total;n++)
{
if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderCloseTime()!=0) continue;
if(OrderMagicNumber()!=MagicNumber) continue;
RefreshRates();
if(OrderType()==OP_SELL)
{
if((OrderOpenPrice()-Ask)>=(breakeven_threshold_points*Point))
{
sl=OrderOpenPrice()-breakeven_addition_points*Point;
sl=NormalizeDouble(sl,Digits);
}
if((sl=0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0);
continue;
}
}
if(OrderType()==OP_BUY)
{
if((Bid-OrderOpenPrice())>=(breakeven_threshold_points*Point))
{
sl=OrderOpenPrice()+breakeven_addition_points*Point;
sl=NormalizeDouble(sl,Digits);
}
if(sl>OrderStopLoss())
{
OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0);
continue;
}
}
}
}


void AssignSL()
{
double sl=0;
double tp=0;
int total=OrdersTotal();
for(int n=0;n<total;n++)
{
if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderCloseTime()!=0) continue;
if(OrderMagicNumber()!=MagicNumber) continue;
if((IsEqual(OrderStopLoss(),0) && IsEqual(OrderTakeProfit(),0)) && ((!IsEqual(stoploss_points,0)) || (!IsEqual(takeprofit_points,0))))
{
if(OrderType()==OP_SELL)
{
sl=OrderOpenPrice()+stoploss_points*Point;
if(IsEqual(stoploss_points,0)) sl=0;
tp=OrderOpenPrice()-takeprofit_points*Point;
if(IsEqual(takeprofit_points,0)) tp=0;
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0);
continue;
}
if(OrderType()==OP_BUY)
{
sl=OrderOpenPrice()-stoploss_points*Point;
if(IsEqual(stoploss_points,0)) sl=0;
tp=OrderOpenPrice()+takeprofit_points*Point;
if(IsEqual(takeprofit_points,0)) tp=0;
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0);
continue;
}
}
}
}

void Trail()
{
if(!useTrailingStop) return;
if(trailingStop_threshold<=0) return;
if(trailingStop_trail<=0) return;

double sl=0;
int total=OrdersTotal();
for(int n=0;n<total;n++)
{
if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderCloseTime()!=0) continue;
if(OrderMagicNumber()!=MagicNumber) continue;
if(OrderType()==OP_SELL)
{
if(Ask<=(OrderOpenPrice()-trailingStop_threshold*Point) || (!IsEqual(OrderStopLoss(),0) && (OrderStopLoss()<(OrderOpenPrice()-(breakeven_addition_points+1)*Point)) ) )
{
sl=Ask+trailingStop_trail*Point;
if(sl<OrderStopLoss() || IsEqual(OrderStopLoss(),0))
OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0);
}
continue;
}
if(OrderType()==OP_BUY)
{
if(Bid>=(OrderOpenPrice()+trailingStop_threshold*Point) || (!IsEqual(OrderStopLoss(),0) && (OrderStopLoss()>(OrderOpenPrice()+(breakeven_addition_points+1)*Point)) ) )
{
sl=Bid-trailingStop_trail*Point;
if(sl>OrderStopLoss())
OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0);
}
continue;
}
}
}

void PrintError(string pair)
{
int err=GetLastError();
Print("Error# ",err," ",ErrorDescription(err)," for ",pair);
}

bool IsEqual(double val1, double val2,int acc=1)
{
return (MathAbs(val1-val2)<=(acc*Point));
}

double RoundLots(double lots)
{
double l=lots;
double maxl=MarketInfo(Symbol(),MODE_MAXLOT);
double minl=MarketInfo(Symbol(),MODE_MINLOT);
double stepl=MarketInfo(Symbol(),MODE_LOTSTEP);
if(l<minl) l=minl;
if(l>maxl) l=maxl;
l=MathFloor(l/stepl)*stepl;
return (l);
}

double LotsForSL(double sl_points,double RiskPerTrade)
{
double sl_ticks=sl_points*Point/MarketInfo(Symbol(),MODE_TICKSIZE);
double free=MathMin(AccountBalance(),AccountFreeMargin());
double lots=AccountFreeMargin()*RiskPerTrade/1000;
//Margin can be insufficient
double lot_lim=AccountFreeMargin()/MarketInfo(Symbol(),MODE_MARGINREQUIRED);
return (MathMin(lots,lot_lim));
}

double RiskLots()
{
double sl=stoploss_points;
if(IsEqual(sl,0))
{
sl=Ask/Point;
}
double l=LotsForSL(sl,RiskPerTrade);
l=RoundLots(l);
return (l);
}

double Lots()
{
datetime lasttime=0;
int ticket=-1;
double lastlots=0;
bool isLoser=false;
bool isNeutral=false;//breakeven
int total=OrdersHistoryTotal();
for(int n=0;n<total;n++)
{
if(!OrderSelect(n,SELECT_BY_POS,MODE_HISTORY)) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderMagicNumber()!=MagicNumber) continue;
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
{
if(OrderOpenTime()>lasttime && OrderOpenTime()>=start_time)
{
lasttime=OrderOpenTime();
ticket=OrderTicket();
lastlots=OrderLots();
isLoser=OrderProfit()<0;
isNeutral=OrderProfit()>=0 && MathAbs(OrderClosePrice()-OrderOpenPrice())<=((breakeven_addition_points+1)*Point);
}
}
}
if(ticket<0)
{
//trade from scratch
return (BaseLots());
}
else
{
//martingale
if(isLoser) return (RoundLots(MartingaleMultiplier*lastlots));
else if(isNeutral) return (lastlots);
else return (BaseLots());//winner


}
return (BaseLots());//will never happen
}

double BaseLots()
{
if(useFixedLots)
{
return (FixedLots);
}
//Money management
return (RiskLots());
}

void CloseShort()
{
int i;
//close own short market, if any
bool something_closed=true;
while(something_closed)
{
something_closed=false;
int total=OrdersTotal();
for(int n=0;n<total;n++)
{
if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderCloseTime()!=0) continue;
if(OrderMagicNumber()!=MagicNumber) continue;
if(OrderType()==OP_SELL)
{
for(i=0;i<repeat;i++)
{
RefreshRates();
if(!OrderClose(OrderTicket(),OrderLots(),Ask,slippage))
{
PrintError(Symbol());
Sleep(sleep_interval);
}
else
{
something_closed=true;
break;
}
}
if(something_closed) break;
}
}
}
}

void CloseLong()
{
int i;
//close own long market, if any
bool something_closed=true;
while(something_closed)
{
something_closed=false;
int total=OrdersTotal();
for(int n=0;n<total;n++)
{
if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderCloseTime()!=0) continue;
if(OrderMagicNumber()!=MagicNumber) continue;
if(OrderType()==OP_BUY)
{
for(i=0;i<repeat;i++)
{
RefreshRates();
if(!OrderClose(OrderTicket(),OrderLots(),Bid,slippage))
{
PrintError(Symbol());
Sleep(sleep_interval);
}
else
{
something_closed=true;
break;
}
}
if(something_closed) break;
}
}
}
}

double GetStochastics(int kperiod,int shift)
{
return (iStochastic(NULL,0,kperiod,2,2,MODE_SMA,0,MODE_MAIN,shift));
}

bool LongSignal()
{
int shift=1;
if(EveryTick) shift=0;

int ct;
ct=Hour()*100+Minute();

double CycleCurrent=GetStochastics(377,shift+1);
double CyclePrevious=GetStochastics(377,shift+2);

double DailyOpen=iOpen(NULL,PERIOD_D1,0);
double DailyLow=iLow(NULL,PERIOD_D1,0);
double DailyHigh=iHigh(NULL,PERIOD_D1,0);

double DailyLow1=iLow(NULL,PERIOD_D1,1);
double DailyHigh1=iHigh(NULL,PERIOD_D1,1);

double DailyLow2=iLow(NULL,PERIOD_D1,2);
double DailyHigh2=iHigh(NULL,PERIOD_D1,2);

double MAImperial=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,0);
double MAImperial21=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,21);

double open=iOpen(NULL,PERIOD_M5,0);
double close=iClose(NULL,PERIOD_M5,0);


return (Close[0]>DailyHigh-3*Point && ct>100 && ct<1200);


}

bool ShortSignal()
{
int shift=1;
if(EveryTick) shift=0;

int ct;
ct=Hour()*100+Minute();

double CycleCurrent=GetStochastics(377,shift+1);
double CyclePrevious=GetStochastics(377,shift+2);

double DailyOpen=iOpen(NULL,PERIOD_D1,0);
double DailyLow=iLow(NULL,PERIOD_D1,0);
double DailyHigh=iHigh(NULL,PERIOD_D1,0);

double DailyLow1=iLow(NULL,PERIOD_D1,1);
double DailyHigh1=iHigh(NULL,PERIOD_D1,1);

double DailyLow2=iLow(NULL,PERIOD_D1,2);
double DailyHigh2=iHigh(NULL,PERIOD_D1,2);

double MAImperial=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,0);
double MAImperial21=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,21);

double open=iOpen(NULL,PERIOD_M5,0);
double close=iClose(NULL,PERIOD_M5,0);


return (Close[0]100 && ct<1200);

//
}

bool ExitLong()
{
int shift=1;
if(EveryTick) shift=0;
double CycleCurrent=GetStochastics(377,shift);
double CyclePrevious=GetStochastics(377,shift+1);

double DailyOpen=iOpen(NULL,PERIOD_D1,0);
double DailyLow=iLow(NULL,PERIOD_H1,1);
double DailyHigh=iHigh(NULL,PERIOD_H1,1);


return (High[0]<Low[0]); //High[0]<Low[0]
}

bool ExitShort()
{
int shift=1;
if(EveryTick) shift=0;
double CycleCurrent=GetStochastics(377,shift);
double CyclePrevious=GetStochastics(377,shift+1);

double DailyOpen=iOpen(NULL,PERIOD_D1,0);
double DailyLow=iLow(NULL,PERIOD_H1,1);
double DailyHigh=iHigh(NULL,PERIOD_H1,1);


return (High[0]<Low[0]); //High[0]<Low[0]
}

Reason: