stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Gday: a D1 Stochastic OB/OS trading robot
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=168
Page 30 of 71
Author:  gaheitman [ Mon Jan 09, 2012 9:19 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

SteveM wrote:
SteveHopwood wrote: The code should force the ea to keep trying to send the trade. Anyone spotting a flaw here, please sing out.
I'm new to Empty4 and a long time since I coded so I could very easily be way off

This is in the send single trade function, inside a for(;;) loop

Code: Select all

         Print(Symbol(), " ", WindowExpertName(), " ", stype," order send failed with error(",err,"): ",ErrorDescription(err));
         return(false);
Won't the "return (false)" part exit the function completely rather than go through the loop again?
You are correct, the return (false) skips the retry logic within SendSingleTrade() (and should be fixed), but outside of that loop in LookForTradingOpportunities(), if SendSingleTrade() returns false, it resets the bar count and tries again on the next tick.

We should probably differentiate between temporary and permanent errors and only retry on temporary ones.

From stderror.mqh:

Code: Select all

#define ERR_NO_ERROR                                  0
#define ERR_NO_RESULT                                 1
#define ERR_COMMON_ERROR                              2
#define ERR_INVALID_TRADE_PARAMETERS                  3
#define ERR_SERVER_BUSY                               4
#define ERR_OLD_VERSION                               5
#define ERR_NO_CONNECTION                             6
#define ERR_NOT_ENOUGH_RIGHTS                         7
#define ERR_TOO_FREQUENT_REQUESTS                     8
#define ERR_MALFUNCTIONAL_TRADE                       9
#define ERR_ACCOUNT_DISABLED                         64
#define ERR_INVALID_ACCOUNT                          65
#define ERR_TRADE_TIMEOUT                           128
#define ERR_INVALID_PRICE                           129
#define ERR_INVALID_STOPS                           130
#define ERR_INVALID_TRADE_VOLUME                    131
#define ERR_MARKET_CLOSED                           132
#define ERR_TRADE_DISABLED                          133
#define ERR_NOT_ENOUGH_MONEY                        134
#define ERR_PRICE_CHANGED                           135
#define ERR_OFF_QUOTES                              136
#define ERR_BROKER_BUSY                             137
#define ERR_REQUOTE                                 138
#define ERR_ORDER_LOCKED                            139
#define ERR_LONG_POSITIONS_ONLY_ALLOWED             140
#define ERR_TOO_MANY_REQUESTS                       141
#define ERR_TRADE_MODIFY_DENIED                     145
#define ERR_TRADE_CONTEXT_BUSY                      146
#define ERR_TRADE_EXPIRATION_DENIED                 147
#define ERR_TRADE_TOO_MANY_ORDERS                   148
#define ERR_TRADE_HEDGE_PROHIBITED                  149
#define ERR_TRADE_PROHIBITED_BY_FIFO                150
I would suggest we stop trying (and maybe stop the ea) if we get the following errors:

Code: Select all

#define ERR_COMMON_ERROR                              2
#define ERR_INVALID_TRADE_PARAMETERS                  3
#define ERR_OLD_VERSION                               5
#define ERR_NO_CONNECTION                             6
#define ERR_NOT_ENOUGH_RIGHTS                         7
#define ERR_TOO_FREQUENT_REQUESTS                     8
#define ERR_MALFUNCTIONAL_TRADE                       9
#define ERR_ACCOUNT_DISABLED                         64
#define ERR_INVALID_ACCOUNT                          65
#define ERR_INVALID_TRADE_VOLUME                    131
#define ERR_MARKET_CLOSED                           132
#define ERR_TRADE_DISABLED                          133
#define ERR_NOT_ENOUGH_MONEY                        134
#define ERR_ORDER_LOCKED                            139
#define ERR_LONG_POSITIONS_ONLY_ALLOWED             140
#define ERR_TOO_MANY_REQUESTS                       141
#define ERR_TRADE_MODIFY_DENIED                     145
#define ERR_TRADE_EXPIRATION_DENIED                 147
#define ERR_TRADE_TOO_MANY_ORDERS                   148
#define ERR_TRADE_HEDGE_PROHIBITED                  149
#define ERR_TRADE_PROHIBITED_BY_FIFO                150
And for these, I suggest a call to RefreshRates() and try again.

Code: Select all

#define ERR_INVALID_PRICE                           129
#define ERR_INVALID_STOPS                           130
#define ERR_PRICE_CHANGED                           135
#define ERR_OFF_QUOTES                              136
#define ERR_BROKER_BUSY                             137
#define ERR_REQUOTE                                 138
#define ERR_TRADE_CONTEXT_BUSY                      146
So, perhaps the return(false) line in SendSingleTrade() could be replace with:

Code: Select all

//check for temporary errors
if (err != ERR_NO_ERROR  &&
    err != ERR_NO_RESULT &&
    err != ERR_INVALID_STOPS && 
    err != ERR_PRICE_CHANGED &&
    err != ERR_OFF_QUOTES &&
    err != ERR_BROKER_BUSY &&
    err != ERR_REQUOTE &&
    err != ERR_TRADE_CONTEXT_BUSY)
   return(false);
I think we should collectively review the list of errors and come up with a standard procedure to evaluate error numbers an react accordingly. For example, I get the err_common_error when my data feed is messed up. I don't think I'd want to keep trading if I get a drop in connectivity, since missing bars will "break" most systems.

George
Author:  markft [ Mon Jan 09, 2012 9:55 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

We can also change the call to OrderSend to use a replacement "safe" version such as the one in liborderreliable or 7bit's version. These retry for temporary errors and give up for permanent errors... Just my 2 cents
Author:  gaheitman [ Mon Jan 09, 2012 10:12 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

markft wrote:We can also change the call to OrderSend to use a replacement "safe" version such as the one in liborderreliable or 7bit's version. These retry for temporary errors and give up for permanent errors... Just my 2 cents
I'm not familiar with the first library you mention, but I believe 7bit's is GPL. Steve would have to be willing to accept that yoke before we included it in the shell.

George
Author:  markft [ Mon Jan 09, 2012 10:42 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

True, it might not be possible due to licencing. The first libray is GPLed as well.
Author:  SteveHopwood [ Mon Jan 09, 2012 10:45 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

gaheitman wrote:
markft wrote:We can also change the call to OrderSend to use a replacement "safe" version such as the one in liborderreliable or 7bit's version. These retry for temporary errors and give up for permanent errors... Just my 2 cents
I'm not familiar with the first library you mention, but I believe 7bit's is GPL. Steve would have to be willing to accept that yoke before we included it in the shell.

George
And he isn't. So far as I am aware, the existing code isn't bust so I have no intention of fixing it.

If I am wrong and it is in fact bust, then someone please post a fix that is easily applied. I am not interested in completely replacing existing code with something different.

:D
Author:  markft [ Mon Jan 09, 2012 10:56 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

No problem, this was a suggestion to easily implement the temporary vs permanent errors idea.
Not sure if an error retry is required. Recalculate at next tick logic should also do the trick you would think.
Author:  Rapheal [ Wed Jan 11, 2012 5:20 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Dear all,
What is 'semi-auto"? How to make it work? Does it mean after I enable the EA, I need to choose "buy/sell" manually in the EA ?
thank you
Author:  fxozgirl [ Wed Jan 11, 2012 6:31 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Rapheal wrote:Dear all,
What is 'semi-auto"? How to make it work? Does it mean after I enable the EA, I need to choose "buy/sell" manually in the EA ?
thank you

Hi Raphael,

Semi Auto means you need to attach the ea to the chart when you have identified a potential trade set up. This allows you to visually confirm the signal before trading.

I personally prefer this method as I like to make sure stoch signal is clearly confirmed at the open of the candle, I also take into consideration the angle of the signal as well before trading.
eg. If stoch signal has crossed over ob/os but is running fairly flat, it would still trigger a trade with the auto ea, however I would probably give it another day to make sure price is definitely starting to trend and not just ranging.
Author:  Gamma_gallus [ Wed Jan 11, 2012 3:36 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

I just wonder how much is the impact of using different brokers / Time zones on this EA (since it takes a position on the open of a new candle)
think.gif
ex. : broker [GMT - 5h] gets a valid signal on EU today, but on a different broker [GMT +2] no more valid signal on the open of the new candle..

Results may be completly random !? (so not worth comparing them)

Anyway i like the simplicity of this system, thanks a lot Fxozgirl !

Gamma
Author:  DING [ Wed Jan 11, 2012 4:25 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Gamma_gallus wrote:I just wonder how much is the impact of using different criminals / Time zones on this EA (since it takes a position on the open of a new candle)
think.gif
ex. : criminal [GMT - 5h] gets a valid signal on EU today, but on a different criminal [GMT +2] no more valid signal on the open of the new candle..

Results may be completly random !? (so not worth comparing them)

Anyway i like the simplicity of this system, thanks a lot Fxozgirl !

Gamma
Hello Gamma,

what is the difference between Gday and your myfxbook Gfay_RevisedV_P10 ?
your Gfay_RevisedV_P10 performance seems better than Gday !
All times are UTC Page 30 of 71