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

Secret Bob's Basket
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3896
Page 5 of 40
Author:  erikskenne [ Mon Oct 27, 2014 5:13 pm ]
Post subject:  Secret Bob's Basket

Pls disregard my last post
Author:  everell [ Mon Oct 27, 2014 5:18 pm ]
Post subject:  Secret Bob's Basket

Yes , of course :)
Others positions opened and closed in a perfect way, only this one is not correct
Author:  Elixe [ Mon Oct 27, 2014 6:06 pm ]
Post subject:  Secret Bob's Basket

everell » Today, 18:31 wrote:I can not understand why opened a new position: I do not see any arrow on the chart
The arrow is probably out of visible zone ;)
2014-10-27_1904.png
Author:  SteveHopwood [ Mon Oct 27, 2014 6:22 pm ]
Post subject:  Secret Bob's Basket

I have just added this to the Serious Warning in post 1:
  • Members whose posts show that they are too lazy and stupid to read this and post 2 properly will lose the ability to post at all. There will be no warnings.
Are you reading this, WorldsEnd?

:xm:
Author:  SteveHopwood [ Mon Oct 27, 2014 6:29 pm ]
Post subject:  Secret Bob's Basket

Here is an oddity that I am unable to explain.

SBB is sending trades every 5 minutes on my H1 demo, but not on the H4 or M15.

Coders, CountOpenTrades() uses int index to calculate the position of the order symbol in the PairsToTrade list. It sets PairTicketNo[index] as the most recently sent trade at line 1192.

Then line 2139 should cancel the potential trade when bool IsTradingAllowed(string symbol, int cc) is called from LookForTradingOpportunities(). Can you see a flaw in the logic?

I cannot blame crapperquotes jerrybuild for this. All my demos are running 670 or earlier.

:xm:
Author:  renexxxx [ Mon Oct 27, 2014 7:56 pm ]
Post subject:  Secret Bob's Basket

Steve, I am not sure if this explains the problem, but ...

You need to be very careful not to place an OrderSelect() inside a loop of another OrderSelect().

For instance ... in lines 1166-1232 there is a loop (iteration) over OrdersTotal() trades and in line 1169 there is an OrderSelect(). Within that loop, there is a call to InsertTakeProfit(cc, OrderTicket(), OrderType()); and LookForTradeClosure(OrderTicket(), index); but these functions are doing a OrderSelect() in their own right.

This totally messes up the Order-cursor, as Empty4 is not able to return to the cursor-position of the outer-loop.

Anyway, that's my take on it ...
Author:  SteveHopwood [ Mon Oct 27, 2014 9:31 pm ]
Post subject:  Secret Bob's Basket

renexxxx » Mon Oct 27, 2014 7:56 pm wrote:Steve, I am not sure if this explains the problem, but ...

You need to be very careful not to place an OrderSelect() inside a loop of another OrderSelect().

For instance ... in lines 1166-1232 there is a loop (iteration) over OrdersTotal() trades and in line 1169 there is an OrderSelect(). Within that loop, there is a call to InsertTakeProfit(cc, OrderTicket(), OrderType()); and LookForTradeClosure(OrderTicket(), index); but these functions are doing a OrderSelect() in their own right.

This totally messes up the Order-cursor, as Empty4 is not able to return to the cursor-position of the outer-loop.

Anyway, that's my take on it ...
All of which is true. The OrderSelect calls in the various functions are there merely to ensure the order is actually still open when the called function does its thingy, so that is not what causes the bot to send a new trade every five minutes.

The 5 minute wait is created by PostTradeAttemptWaitSeconds, so the bot is obediently doing its thingy there. The question is, why is it then sending a fresh trade once this period is passed? It is ignoring the coding in IsTradingAllowed, which is nothing to do with CountOpenTrades.

If it was that easy to spot the bloop, I would already have done so. It aint, so I haven't.

:xm:
Author:  SteveHopwood [ Mon Oct 27, 2014 9:48 pm ]
Post subject:  Secret Bob's Basket

It turns out not to be merely an H1 problem, unsurprisingly.

There is something wrong with the code that prevents multiple entries on the same candle. I do not know what this is. Do not trade this bot on a live account until I have fixed this. The fix will not come anytime soon. It is nearly 10.00 pm at night and I have been coding all day. What passes for my brain is frazzled.

:xm:
Author:  SteveHopwood [ Mon Oct 27, 2014 11:20 pm ]
Post subject:  Secret Bob's Basket

In a breathtaking bit of bloop-spotting, Elixe appears to have spotted the cause of the multiple trades sent on the same candle. What can I say, Elixe? :clap: :clap: :clap:

Guys, unless you are a coder you have no idea how hard it is to read another person's code. What Elixe just did is phenomenal. :clap: :clap: :clap:

So, the fix is in post 1 for the peasants. Non-peasants, go to line 851 and append:
ArrayResize(PairMostRecentTime, NoOfPairs);

I forgot to resize the array, so (to quote Elixe) "the array is always returning 0, OrderOpenTime is always > 0 and as you are going backward through the tickets, the older ticket found is always the one in PairTicketNo."

Yep. It really is that bog-standard basic. Isn't it always when I get something so sadly wrong?

Hey ho. I will learn to code this stuff properly one day. Until then, thanks to Elixe and the rest of you for hauling my coals out of the fire and saving the rest of us from a load of grief.

Again.

:xm:
Author:  thomasmore [ Tue Oct 28, 2014 7:04 am ]
Post subject:  To all the coders!

Image
All times are UTC Page 5 of 40