Help with Entry Criteria
  #1 (permalink)  
Old 07-23-2012, 02:31 PM
Currency Trader
 
Join Date: Jul 2012
Posts: 1
tkuan77 is on a distinguished road
Default Help with Entry Criteria

Hi all,
I am having some problems entering trades with stochastics crossovers. My aim is to open trade when stochastic crosses at the overbrought (level 80) or oversold (level 20) area. However, I am only able to open trade when it crosses. How do I restrict the trades to be carried out at the over brought and oversold regions?

Please help. Thanks.
Terrance


//--- input parameters
extern double TakeProfit=530.0;
extern double Lots=0.1;
extern double StopLoss=520.0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+

int start()
{

//----
int ticket, total;
double shortStoc, longStoc;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}

//+------------------------------------------------------------------+
//| expert start function | Stochastic Trigger
//+------------------------------------------------------------------+
shortStoc = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0); //orignial Stoc movement
longStoc = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0) ; //orignial Stoc movement

//+--------------------------------------------------------------------------------------+
//| expert start function | Set trigger trade only when line crossed and candle closed |//
//+--------------------------------------------------------------------------------------+
int isCrossed = 0;
double shortStoc1 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1);
double longStoc1 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,1) ;
double shortStoc2 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,2);
double longStoc2 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,2) ;
double diff1 = shortStoc1-longStoc1;
double diff2 = shortStoc2-longStoc2;

if ((diff1*diff2)<0)
{
if (shortStoc1>longStoc1)
isCrossed = 1;
else isCrossed = 2;
}
//+------------------------------------------------------------------------------------+
//| expert end function | Set trigger trade only when line crossed and candle closed |//
//+------------------------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert end function | Stochastic Trigger
//+------------------------------------------------------------------+


//| expert start function | Trigger order
//+------------------------------------------------------------------------------------------------------------+
total = OrdersTotal();
if(total < 1)
{
if(isCrossed == 1)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,1,Ask-StopLoss*Point,Ask+TakeProfit*Point,
"My EA",12345,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))
Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(isCrossed == 2)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,1,Bid+S topLoss*Point,Bid-TakeProfit*Point,
"My EA",12345,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))
Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
return(0);
}
Reply With Quote
  #2 (permalink)  
Old 08-04-2012, 02:51 PM
Forex Senior
 
Join Date: May 2010
Posts: 193
master4x is on a distinguished road
Default

All you need to do is just add 2 more checks. Since you already have the stoch. values then all you need to do is add something like "if(isCrossed == 1 && shortStoc<20 && longStoc<20)". There are several ways this could be done though.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
forex entry Paulot Indicators 4 07-20-2011 09:40 AM
pallada entry kevinator Indicators 1 06-19-2011 06:51 AM
entry at open trini shinobi System Coding 1 08-13-2009 07:05 AM
need some indicator to entry aloy Indicators 1 07-06-2009 10:49 PM
Simple Entry EA Tribulus Trading Systems 0 05-25-2008 01:57 AM


All times are GMT. The time now is 04:59 PM.

Registered members gain free access to online FOREX currency trading tools, foreign exchange software, Metatrader MT4/MT5 expert advisors, MT4 indicators and EAs. Register now