Nice one. Thanks.pah wrote:The freeze on opening a trade appears to be fixed by adding a return value to the following two lines in LookForTradeClosure()
Code: Select all
if (HtfSlopeTrend == buyhold) return(false);Regards, Paul.Code: Select all
if (HtfSlopeTrend == sellhold) return(false);
Flying Slope auto-trading EA
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Flying Slope auto-trading EA
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Flying Slope auto-trading EA
Another great spot, Paul. Thanks again.pah wrote:And now it only trades once which is caused by the check in TooClose()
This is checking the hour but could be checking a trade from yesterday for example, which happened to have occurred at an earlier hour.Code: Select all
if (TimeHour(TimeCurrent()) - TimeHour(OrderCloseTime()) < (MinMinutesBetweenTrades * 60) )
The conditional was completely wrong. I want to check that enough time has elapsed between the closing of one trade and the open of another, so the conditional should be:
Code: Select all
if (OrderCloseTime() - TimeCurrent() < (MinMinutesBetweenTrades * 60))Rogue trade behaviour will only become apparent when a trade closes, so we are only concerned with the history of closed trades. The stacking function does not work, so there can only be one open trade at a time. We need to prevent it being sent at all if the previous one was a rogue.Also, I'm a bit puzzled by it only checking history here, should it not also be looking at open trades that were taken recently and ensuring it doesn't open another too soon after?
Since it only opens market orders direct (no stop or limit orders) might it not be easier to set a datetime variable called e.g. NextTradeAllowed which you can set when you open a trade ( TimeCurrent() + (MinMinutesBetweenTrades * 60) ) and then disallow any subsequent trades that fire before this time has passed?
Thanks for your help, Paul. Much appreciated by us all, but especially me.
Version 1k is in post 1 folks, with the appropriate fixes so far. Unless you want to play with strategy tester, you may as well hold on until later, in case anything else crops up.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
pah
- Posts: 6
- Joined: Sat Jan 07, 2012 7:25 am
Re: Flying Slope auto-trading EA
I'm still pretty sure you want to check OrderCloseTime() - OrderOpenTime(). The close will always occur later than the open and so, open - close will always return a negative value. Do you need a bath?SteveHopwood wrote: Nope. The order opened before it closed, so I need to know how soon after its open that it closed.
I can't find the original but I think this should do what you want - note: I've not tested it in anger...SteveHopwood wrote:Can you do me a favour, please, and resend me this, or post it here? I don't remember this and it would be most helpful.
Code: Select all
bool IsLastTradeClosedRogue()
{
// look for trades that closed within the last 5 minutes
// otherwise we will always find the last rogue trade
// even when that happened some time ago and can be ignored
datetime latest.time = TimeCurrent() - ( 5 * 60 );
datetime duration = -1; //impossible value
for ( int i = OrdersHistoryTotal()-1; i >= 0; i-- )
{
if ( ! OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) ) continue;
if ( OrderMagicNumber() != MagicNumber || OrderSymbol() != Symbol() ) continue;
if ( OrderCloseTime() >= latest.time )
{
latest.time = OrderCloseTime();
duration = OrderCloseTime() - OrderOpenTime();
}
}
bool rogue = ( duration >= 0 ) && ( duration < ( MinMinutesBetweenTradeOpenClose * 60) );
if ( rogue )
{
//do your rouge stuff here
}
return(rogue);
}-
pah
- Posts: 6
- Joined: Sat Jan 07, 2012 7:25 am
Re: Flying Slope auto-trading EA
I realize that but isn't that dealt with by the rogue trade routine?SteveHopwood wrote: Rogue trade behaviour will only become apparent when a trade closes, so we are only concerned with the history of closed trades. The stacking function does not work, so there can only be one open trade at a time. We need to prevent it being sent at all if the previous one was a rogue.
I was referring to the TooClose() function which I thought was trying to prevent opening another trade too soon after the last one (whether rogue or not), in which case, the last trade could still be open.
However, if you can only have one open then this point is purely academic...
Regards, Paul.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Flying Slope auto-trading EA
Nope. I need a firing brain-cell. Obviously you are correct - I was just being dim. In case any of you are wondering why Paul is right, the reason is that Crapql4 counts time forward from Jan 1st 1970, not backwards from now. If any of you have trades in your History tab, the latest version should have shut up shop immediately. Fix coming soon.pah wrote:I'm still pretty sure you want to check OrderCloseTime() - OrderOpenTime(). The close will always occur later than the open and so, open - close will always return a negative value. Do you need a bath?SteveHopwood wrote: Nope. The order opened before it closed, so I need to know how soon after its open that it closed.![]()
![]()
Thanks Paul.I can't find the original but I think this should do what you want - note: I've not tested it in anger...SteveHopwood wrote:Can you do me a favour, please, and resend me this, or post it here? I don't remember this and it would be most helpful.
Code: Select all
bool IsLastTradeClosedRogue() { // look for trades that closed within the last 5 minutes // otherwise we will always find the last rogue trade // even when that happened some time ago and can be ignored datetime latest.time = TimeCurrent() - ( 5 * 60 ); datetime duration = -1; //impossible value for ( int i = OrdersHistoryTotal()-1; i >= 0; i-- ) { if ( ! OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) ) continue; if ( OrderMagicNumber() != MagicNumber || OrderSymbol() != Symbol() ) continue; if ( OrderCloseTime() >= latest.time ) { latest.time = OrderCloseTime(); duration = OrderCloseTime() - OrderOpenTime(); } } bool rogue = ( duration >= 0 ) && ( duration < ( MinMinutesBetweenTradeOpenClose * 60) ); if ( rogue ) { //do your rouge stuff here } return(rogue); }
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Flying Slope auto-trading EA
Version 1l is in post 1, incorporating Paul's improvements. Also, if suspended because of possible rogue trading, FS will continue to manage open trades.

Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
jiaxingx
- Trader
- Posts: 43
- Joined: Fri Jun 22, 2012 10:45 am
Re: Flying Slope auto-trading EA
I run version 1l on demo for one week,
but no trade happen,anyone have trade?
but no trade happen,anyone have trade?
-
fxshadow
- Trader
- Posts: 61
- Joined: Tue Nov 15, 2011 11:46 pm
Re: Flying Slope auto-trading EA
Check your screen info and you will probably see that trade conditions were not met.jiaxingx wrote:I run version 1l on demo for one week,
but no trade happen,anyone have trade?
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: Flying Slope auto-trading EA
I haven't been involved in the conversation about Rogue trades, but that's apparently not going to stop me from chiming in...SteveHopwood wrote:Version 1l is in post 1, incorporating Paul's improvements. Also, if suspended because of possible rogue trading, FS will continue to manage open trades.
It seems to me an important distinction for a trade to be rogue is that our code closed the trade. If we enter a trade and it is stopped out in a fast moving market it may look like a rogue trade when it was simply an unfortunate one. I think to really catch the rogue behavior we need to have our code check at the time of closure to see if we just opened the trade we are closing. Or, we could do something to track the number of high-frequency trading decisions we have made. For example, if we add two global variables...
Code: Select all
// holds the result of GetTickCount(), set after every call to a OrderClose(), OrderOpen() or
// OrderModify()
int LastTradingDecision = 0;
// number of times we called OrderClose(), OrderOpen(), or OrderModify() when
// GetTickCount() - LastTradingDecision < HighFrequencyTradeThresholdMilliseconds
int HighFreqCount = 0;
George
-
SWG123
- Trader
- Posts: 565
- Joined: Wed Nov 16, 2011 3:02 pm
- Location: Cape Town
Re: Flying Slope auto-trading EA
Welcome back George 
