
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You can always write int crossTime = Time[0] when you had a cross, and then use iBarShift function using crossTime variable to check how many bars passed.
Hi Kalenzo,
You can always write int crossTime = Time[0] when you had a cross, and then use iBarShift function using crossTime variable to check how many bars passed.
How would you write this code to only include "Bear Bars" in the count?
I understand the ibarshift but this would include all bars since cross. You would still need to use a count system like I have it to count "Bear Bars" and I believe this is where my issue lies.
I originally tested my code with this code .... Which worked fine.... but didn't translate into the code above that would actually be listed in my EA
{
//----
double f=iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,0);
double s=iMA(NULL,0,7,0,MODE_SMA,PRICE_CLOSE,0);
double fp=iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,1);
double sp=iMA(NULL,0,7,0,MODE_SMA,PRICE_CLOSE,1);
static bool CrossedUP,CrossedDn;
static int Count=0;
if(f>s && fp<=sp)
{
CrossedUP=true;
CrossedDn=false;
Alert(Symbol()," Crossed UP");
Count=0;
}
else
if(f=sp){
CrossedUP=false;
CrossedDn=true;
Alert(Symbol()," Crossed Down");
Count=0;
}
if(NewBar()==true && f>s || f<s) Count++;
Comment("Crossed UP: ",CrossedUP," Crossed Down: ",CrossedDn," Bars since Cross: ",Count);
//----
return(0);
}Any other thoughts would be appreciated.
Thanks,
SaxMan
Sorry Omelette,
This doesn't work either
Thanks,
SaxMan
Hi. Try this.
{
if(MAFastC=MASlowP){
CrossedUp=false;
CrossedDn=true;
BarCount=0;
}
else
if(MAFastC>MASlowC && MAFastP<=MASlowP)
{
CrossedUp=true;
CrossedDn=false;
BarCount=0;
Alert("Crossed Down");
}
if(CrossedDn==true && NewBar()==true && Candle3mP=="Bear")
BarCount++;
if(BarCount>=2 && Candle3mC=="Bear")
{
Alert("Close Long Position");
return(true);
}
else return(false);time limit with EA code
I cant seame to place a time limit on my EA
code line is as follows:
OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,Ask+TakeProfit*Point,"timetest",16384,0,Green)
I've tried changing that ZERO to a 1 or to a 12 and i can't get it to stop the trade ... i would like to have the trade expire in 12 hours how can i do this?
i'm useing a backtesting. to nake sure it works.. the expire function does work with that right?
Try this....
{
string expire_date = "2007.10.22";
datetime expirevar = StrToTime(expire_date);
if ( CurTime() >= expirevar )
{
Alert ("Version Expired");
return(0);
}
// code
return(0);
}
Dave
I cant seame to place a time limit on my EA
code line is as follows:
OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,Ask+TakeProfit*Point,"timetest",16384,0,Green)
I've tried changing that ZERO to a 1 or to a 12 and i can't get it to stop the trade ... i would like to have the trade expire in 12 hours how can i do this?
i'm useing a backtesting. to nake sure it works.. the expire function does work with that right?check ther error channel;
Applying of pending order expiration time can be disabled in some trade servers. In this case, when a non-zero value is specified in the expiration parameter, the error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated.
the parameter is a 'datetime' variable I dont beleive that 12 will fall within that variable declaration.
I cant seame to place a time limit on my EA
code line is as follows:
OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,Ask+TakeProfit*Point,"timetest",16384,0,Green)
I've tried changing that ZERO to a 1 or to a 12 and i can't get it to stop the trade ... i would like to have the trade expire in 12 hours how can i do this?
i'm useing a backtesting. to nake sure it works.. the expire function does work with that right?Hi. Expiration timeouts work fine with MT, the only caveat being that some brokers don't allow them - FXDD is one. The expiration time needs to be in datetime format for it to work - ie.
i've been trying this.
extern int TradeLifeHour=12;
extern int TradeLifeMin=00;
datetime expirationtime; (did'nt know what goes here)
then within start()
expirationtime = CurTime()+TradeLifeHour*60*60+TradeLifeMin*60;
and use expirationtime in the 0 area.
i the last code but i dont know how to config it to expire the trade in 12 hours
Try this....
{
string expire_date = "2007.10.22";
datetime expirevar = StrToTime(expire_date);
if ( CurTime() >= expirevar )
{
Alert ("Version Expired");
return(0);
}
// code
return(0);
}
DaveI just used the code I gave you. I changed the date to 2006 and slapped it in a random place inside Bipoler on a real money FXDD account, and it worked like a charm.
Or mabe mines too simple? I dunno
Dave
??
that code does not make each trade my EA opens expire 12 hours from the time it opens...