How to code? - page 29 1...222324252627282930313233343536...346 New comment ejoi 2007.07.15 16:58 #281 Here... string price = (DoubleToStr(iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0),Digits)); if (price=>1.0000 && price< 1.0050) { sell order here } islandrock 2007.07.15 17:13 #282 thanks thank you for the quick response. islandrock 2007.07.15 20:21 #283 ejoi:Here... string price = (DoubleToStr(iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0),Digits)); if (price=>1.0000 && price< 1.0050) { sell order here } when i try to compile this it get diff types in comparison ralphronnquist 2007.07.15 22:16 #284 I think ejoi made a slight mistake with the stringifying part; the code should have been like: double price = iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0); if (price=>1.0000 && price< 1.0050) { sell order here } Basic EA template Need help on codes Help For Array elements islandrock 2007.07.16 03:46 #285 thanks thanks that worked great!!! islandrock 2007.07.16 03:59 #286 it seems that i also have this problem if anyone can help. i'm trying to limit the time that trades can be opened. total=OrdersTotal(); if (total<1) { if (TimeHour(CurTime())<StartHour) {return(0);} if (TimeMinute(CurTime())<StartMinute) {return(0);} if (TimeHour(CurTime())>EndHour) {return(0);} if (TimeMinute(CurTime())>EndMinute) {return(0);} }[/PHP] it seems right that no trades are executed whenever i use it my extern is as follows [PHP]extern int StartHour=0; extern int StartMinute=30; extern int EndHour=22; extern int EndMinute=30; Expiration EA BAsed on Heiken itime problem ralphronnquist 2007.07.16 04:14 #287 You might add the following function bool isTradableTime() { datetime time = TimeCurrent(); int now = TimeHour( time ) * 60 + TimeMinute( time ); int begin = StartHour * 60 + StartMinute; int end = EndHour * 60 + EndMinute; return ( begin <= now && now < end ); } [/PHP] and then use it like the following in your start() function [PHP]if ( ! isTradableTime() ) return( 0 ); Function of "trading at PipMaker v1 - Price EA BAsed on Heiken Michel 2007.07.16 04:17 #288 If the trading period does not include midnight: total=OrdersTotal(); if (total<1) { if(Hour()<StartHour) return(0); if(Hour()==StartHour && Minute()<StartMinute) return(0); if(Hour()>EndHour) return(0); if(Hour==EndHour && Minute()>EndMinute) return(0); } islandrock 2007.07.16 04:57 #289 Michel:If the trading period does not include midnight: total=OrdersTotal(); if (total<1) { if(Hour()<StartHour) return(0); if(Hour()==StartHour && Minute()<StartMinute) return(0); if(Hour()>EndHour) return(0); if(Hour==EndHour && Minute()>EndMinute) return(0); } thank you both...i went with this one becuase i liked the simplicity of it and it works great.... thank you again islandrock 2007.07.17 00:10 #290 new question does any one know how to code into an EA if a trade exsist already do not open a second one unless it's 10 pips apart? 1...222324252627282930313233343536...346 New comment
Here...
string price = (DoubleToStr(iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0),Digits));
if (price=>1.0000 && price< 1.0050)
{
sell order here
}
thanks
thank you for the quick response.
Here...
string price = (DoubleToStr(iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0),Digits));
if (price=>1.0000 && price< 1.0050)
{
sell order here
}
when i try to compile this it get diff types in comparison
I think ejoi made a slight mistake with the stringifying part; the code should have been like:
if (price=>1.0000 && price< 1.0050)
{
sell order here
}thanks
thanks that worked great!!!
it seems that i also have this problem if anyone can help. i'm trying to limit the time that trades can be opened.
if (total<1)
{
if (TimeHour(CurTime())<StartHour) {return(0);}
if (TimeMinute(CurTime())<StartMinute) {return(0);}
if (TimeHour(CurTime())>EndHour) {return(0);}
if (TimeMinute(CurTime())>EndMinute) {return(0);}
}[/PHP]
it seems right that no trades are executed whenever i use it
my extern is as follows
[PHP]extern int StartHour=0;
extern int StartMinute=30;
extern int EndHour=22;
extern int EndMinute=30;You might add the following function
{
datetime time = TimeCurrent();
int now = TimeHour( time ) * 60 + TimeMinute( time );
int begin = StartHour * 60 + StartMinute;
int end = EndHour * 60 + EndMinute;
return ( begin <= now && now < end );
}
[/PHP]
and then use it like the following in your start() function
[PHP]if ( ! isTradableTime() )
return( 0 );If the trading period does not include midnight:
if (total<1)
{
if(Hour()<StartHour) return(0);
if(Hour()==StartHour && Minute()<StartMinute) return(0);
if(Hour()>EndHour) return(0);
if(Hour==EndHour && Minute()>EndMinute) return(0);
}If the trading period does not include midnight:
if (total<1)
{
if(Hour()<StartHour) return(0);
if(Hour()==StartHour && Minute()<StartMinute) return(0);
if(Hour()>EndHour) return(0);
if(Hour==EndHour && Minute()>EndMinute) return(0);
}thank you both...i went with this one becuase i liked the simplicity of it and it works great....
thank you again
new question
does any one know how to code into an EA if a trade exsist already do not open a second one unless it's 10 pips apart?