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

Nanningbob 10.2 auto-trading EA
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=552
Page 28 of 54
Author:  phil_trade [ Mon May 28, 2012 10:13 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

SteveHopwood wrote:Re the rapid opening/closing of trades thingy, no guarantee that what I am about to write is accurate but I have been involved with Empty4 long enough to be reasonably sure that it is.

Between them, Matt and Phil have provided industrial-strength code to overcome the more criminally-programmed aspects of this bloody platform.

Users of EA's must ensure that they run Matt's ForceHistorical script thingy, linked in the first post of every one of my threads since Matt first published it, before running the EA on a new platform. Not many people bother to read my post 1 properly, and have only themselves to blame for ignoring the information contained within it.

This is not to say definitively that there is no bug in the EA code, but until it manifests itself on my platform, there is nothing I can do about it. These days, I am far more inclined to blame Empty4 than once I was.

:D
Hello Steve

I suggest to include this check module to avoid all bad surprise in future :

Code: Select all

// Try to avoid rapid open/close trades
bool CheckIfBadTrade()
{

int NbHistoTrade = OrdersHistoryTotal();
if (NbHistoTrade == 0) return(false);

// check  max last 10 trades
int NbTradeToAnalyse = MathMin(10, NbHistoTrade);
   for (int i=NbHistoTrade; i > NbHistoTrade-NbTradeToAnalyse; i--)
   {
   if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue;
   if (OrderSymbol() != Symbol()) continue;   
   if (TimeCurrent() - OrderOpenTime() < 60) return(true);
   }
return(false);
}  //bool CheckIfBadTrade()
and to adapt START() with

Code: Select all

   if (!StopTrading && CheckIfBadTrade()==false)
   {      
      LookForTradingOpportunities();
   }//if (!StopTrading)
This will check if no trade within 60 last seconds...

Philippe
Author:  SteveHopwood [ Mon May 28, 2012 10:45 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

phil_trade wrote:This will check if no trade within 60 last seconds...

Philippe
Nice one Phil.

V 1w is in post 1 incorporating Phil's latest. This will not solve the problem if it is caused by a bug in the EA code; it will help if it is a Empty4 thingy.

:D
Author:  phil_trade [ Mon May 28, 2012 10:50 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

Steve

New bug found in InserStopLoss :o

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_SELL);
should be

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_BUY);
Author:  SteveHopwood [ Mon May 28, 2012 11:02 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

phil_trade wrote:Steve

New bug found in InserStopLoss :o

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_SELL);
should be

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_BUY);
Oh crap. I cannot believe even me can make a mistake that basic.

V 1x in post 1, for those of you who have not yet lost the will to live.

:D
Author:  mackaozy [ Mon May 28, 2012 11:18 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

SteveHopwood wrote:
mackaozy wrote:Hi

If anyone has been getting good results with this EA any chance you could please post your setfile? My results have not been too good. :cry:

I also got like 15 EUR/GBP trades in one go that all opened then closed immediately. I would post however I'm not at home - trades are on myfxbook.



:)

Cheers

Steve
Remember that Bob designed and developed this system using Cowboy IBFX. Different crims with different timescales etc could easily lead to radically different results.

:D
Cheers Steve. I'm running it on Alpari. I'll fire up my Vantage fx account and run it side by side with fresh demos with your updated version and give it a go. :D Thanks for all your efforts by the way :D
Author:  SteveHopwood [ Mon May 28, 2012 11:32 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

mackaozy wrote:Cheers Steve. I'm running it on Alpari. I'll fire up my Vantage fx account and run it side by side with fresh demos with your updated version and give it a go. :D Thanks for all your efforts by the way :D
Hehe. You might be better off thanking Phil for his correcting my best efforts. :lol:
Author:  mackaozy [ Mon May 28, 2012 11:53 pm ]
Post subject:  Re: 10.2; the auto-trading EA is born.

phil_trade wrote:Steve

New bug found in InserStopLoss :o

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_SELL);
should be

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_BUY);
Thanks again Phil!! Appreciate the effort :D
Author:  phil_trade [ Tue May 29, 2012 6:09 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

mackaozy wrote:
phil_trade wrote:Steve

New bug found in InserStopLoss :o

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_SELL);
should be

Code: Select all

   if (OrderType() == OP_BUY)
   {
      stop = CalculateStopLoss(OP_BUY);
Thanks again Phil!! Appreciate the effort :D

I suspect Steve to leave a few bugs so I can be useful. Steve very charitable. :lol:

More seriously, above a level of technical difficulty, four eyes are essential! :idea:
Author:  phil_trade [ Tue May 29, 2012 9:32 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

Steve

I found an incorrect code that could do some strange things

in modules LookForD1H4TrendTrade and LookForD1TrendTrade, you define double Target in If Buy...so if it's a SELL, MQL found a no declared variable target = xxxx

You always have to declare variables at top of module to avoid this... of course...if you're kind enough :lol:
Author:  phil_trade [ Tue May 29, 2012 10:40 am ]
Post subject:  Re: 10.2; the auto-trading EA is born.

Steve

a friend has an Empty4 on Alpari which generates the Open/close bug.

I have add a Print in LookForTradeClosure() to see value

as you can see TP is 0.77782 but take read from line is 80.65200 so for a sell BID < take and LookForTradeClosure() close the trade !

Now we have to find why line is set to 80.652 :mrgreen:

2012.05.29 10:37:11 Nanningbob 10.2 auto-trading EA EURGBP,H4: open #1800554604 sell 0.60 EURGBP at 0.79938 sl: 0.83496 tp: 0.77782 ok
2012.05.29 10:37:13 Nanningbob 10.2 auto-trading EA EURGBP,H4: close #1800554604 sell 0.60 EURGBP at 0.79938 sl: 0.83496 tp: 0.77782 at price 0.79949
2012.05.29 10:37:13 Nanningbob 10.2 auto-trading EA EURGBP,H4: EURGBP Close By LookForTradeClosure() : Bid = 0.79937 take = 80.65200 stop = 0.00000
All times are UTC Page 28 of 54