• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 7:38am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:38am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Hanover replies to PMs 1,425 replies

Trading profitably using Recent Strength 58 replies

Hanover - can you help me with MT4 qs please? 4 replies

  • Commercial Content
  • /
  • Reply to Thread
  • Subscribe
  • 69
Attachments: Hanover: an auto-trader using Recent Strength
Exit Attachments
Tags: Hanover: an auto-trader using Recent Strength
Cancel

Hanover: an auto-trader using Recent Strength

  • Last Post
  •  
  • 1 121314Page 1516 17
  • 1 14Page 1516 17
  •  
  • Post #281
  • Quote
  • Nov 3, 2011 6:59pm Nov 3, 2011 6:59pm
  •  magft
  • | Joined Apr 2011 | Status: Member | 208 Posts
Steve, great work once again you have taken a good idea and made it reality.

I've been have a quick look through the code and i have one comment, not wishing to feel the full wrath, but it is more of an observation really.

PHP Code
 // table is full, now we can check for the big moves

   
if (TickDiff > Threshold) 
   {
      
TakingEmergencyAction = true;//Used in SendSingleTrade to create a mahoosive slippage allowance
      
      //Calculate the direction of the move
      
direction = down;
      if (
TickTable[tc] > TickTable[tc + 1] ) direction = up;
      
      
// The price difference between the latest and the first entry in
      // our table is above the threshold, so take action. 
From reading the article and code by Carsten TickDiff is the difference between the first and the last values in the tick array. So you check if the difference is greater than the threshold set, all good.

Then to decide the movement you check the last stored tick value with the value prior to it, is this correct? Or should it be that the comparison should be between first and last values to determine direction?

Just a thought to ponder, i have the EA on EU, UJ and GJ ready for tomorrow with rest ootb.

Mike
 
 
  • Post #282
  • Quote
  • Nov 3, 2011 7:04pm Nov 3, 2011 7:04pm
  •  magft
  • | Joined Apr 2011 | Status: Member | 208 Posts
Quoting MadCow
Disliked
I must be missing some sort of scale factor. When I compare ATR(1) to ATR(60) the ATR(1) exceeds ATR(60) very often. See image. Please enlighten me how you got the image in your post.
Thanks
MC
Ignored
I didn't do anything fancy just added the two ATRs to the chart in same window nothing more.
 
 
  • Post #283
  • Quote
  • Nov 3, 2011 7:15pm Nov 3, 2011 7:15pm
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
Quoting magft
Disliked
Steve, great work once again you have taken a good idea and made it reality.

I've been have a quick look through the code and i have one comment, not wishing to feel the full wrath, but it is more of an observation really.

[php]// table is full, now we can check for the big moves
if (TickDiff > Threshold)
{
TakingEmergencyAction = true;//Used in SendSingleTrade to create a mahoosive slippage allowance

//Calculate the direction of the move
direction = down;
if (TickTable[tc] > TickTable[tc + 1] ) direction...
Ignored
My understanding, using Carsten's wonderful idea of creating the 20 boxes in a row and then bending the row so it forms a circle is this:

 

  1. at whatever point in the circle we are, this contains the latest tick.
  2. from here, count backwards 20 boxes. It doesn't matter which way we bend the row, so long as we count back 19, 18, 17 etc, we will arrive at the last box being the current one plus 1.

Therefore, we should be comparing current box with current box plus 1, in whatever direction we bended the row.

Mind, if this happens to be wrong, just remember what usually happens to the messenger.

Plus, I might have misunderstood your post and be talking even more rubbish than usual. What passes for my brain has fried.

 
 
  • Post #284
  • Quote
  • Nov 3, 2011 7:17pm Nov 3, 2011 7:17pm
  •  ArrietaTech
  • | Joined Oct 2010 | Status: Douche | 272 Posts
Quoting SteveHopwood
Disliked
Really? Gosh. Let me just check........ I believe I mentioned in my post..... Yes. I did.
No. This is not about scalping a few pips. If you think it is the you have not been reading what has been going on.

If you have nothing intelligent to say, stay quiet.

Very quiet.
Ignored
I've read what's going on, and I never implied that your code was only meant for scalping a few pips.

I'm only experimenting and trying to find more (and why not, better) uses for the code you provide. Turns Out I've made 110 pips since the thing started trading by doing what I posted before by manually closing the extra trades the pop out.

I really have no idea why you come with such a rude reply when people try to come, help and contribute to get the best out of the code you provide.

Diego
 
 
  • Post #285
  • Quote
  • Nov 3, 2011 7:20pm Nov 3, 2011 7:20pm
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
Quoting acostafulano
Disliked
I've read what's going on, and I never implied that your code was only meant for scalping a few pips.

I'm only experimenting and trying to find more (and why not, better) uses for the code you provide. Turns Out I've made 110 pips since the thing started trading by doing what I posted before by manually closing the extra trades the pop out.

I really have no idea why you come with such a rude reply when people try to come, help and contribute to get the best out of the code you provide.

Diego
Ignored
Suit yourself. You were warned.
 
 
  • Post #286
  • Quote
  • Nov 3, 2011 7:45pm Nov 3, 2011 7:45pm
  •  magft
  • | Joined Apr 2011 | Status: Member | 208 Posts
Quoting SteveHopwood
Disliked
My understanding, using Carsten's wonderful idea of creating the 20 boxes in a row and then bending the row so it forms a circle is this:

 

  1. at whatever point in the circle we are, this contains the latest tick.
  2. from here, count backwards 20 boxes. It doesn't matter which way we bend the row, so long as we count back 19, 18, 17 etc, we will arrive at the last box being the current one plus 1.

Therefore, we should be comparing current box with current box plus 1, in whatever direction we bended the row.

Mind, if this happens...

Ignored
I'm not surprised your brain is fried

I have had a play around with the example EA by Carsten and you are right, if you look at the out put from the modified version i have added various positions in the ticktable to see the values. TickTable[(tc + 1) % TableSize] seems to give the same value as TickTable[tc + 1] so that is good enough for me.

Nice work.
Attached File(s)
File Type: mq4 Tick table example mg.mq4   3 KB | 186 downloads
 
 
  • Post #287
  • Quote
  • Nov 3, 2011 7:55pm Nov 3, 2011 7:55pm
  •  astral77
  • | Joined Nov 2009 | Status: Member | 1,196 Posts
Fantastic, great work Steve. I have attached the tick charts for the first couple of hours of Monday morning so people can see what happened (tick wise that is) when the BOJ intervention happened.

Kind regards
Attached File(s)
File Type: csv USDJPY_Ticks_31.10.2011-01.11.2011.csv   884 KB | 260 downloads
 
 
  • Post #288
  • Quote
  • Nov 3, 2011 7:57pm Nov 3, 2011 7:57pm
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
Quoting magft
Disliked
I'm not surprised your brain is fried

I have had a play around with the example EA by Carsten and you are right, if you look at the out put from the modified version i have added various positions in the ticktable to see the values. TickTable[(tc + 1) % TableSize] seems to give the same value as TickTable[tc + 1] so that is good enough for me.

Nice work.
Ignored
Well, whilst frying brains, how about a look at Sandy's post at http://www.forexfactory.com/showthre...93#post5099393 and the next one down. It isn't just Sandy who has noticed this; there was a contribution in the newbies thread about this s well.

The relevant code is within bool IsTradingAllowed()

Buggered if I can see why it doesn't work.

Cheers

 
 
  • Post #289
  • Quote
  • Edited 8:31pm Nov 3, 2011 8:17pm | Edited 8:31pm
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
Got it. I declared a variable as the wrong type.

It should be
Inserted Code
[color=Red]datetime [/color]TargetTime = OrderCloseTime() + (MinHoursBetweenTrades * 60) * 60;
not

Inserted Code
[color=Red]double [/color]TargetTime = OrderCloseTime() + (MinHoursBetweenTrades * 60) * 60;
This is Hanover we are talking about here, guys. Make the change yourself manually or download the fix from post 1. Either way, it is an essential fix.

 
 
  • Post #290
  • Quote
  • Nov 3, 2011 8:19pm Nov 3, 2011 8:19pm
  •  scooby-doo
  • Joined Jul 2009 | Status: Member | 2,158 Posts
Just had a phone call from Singapore.

Second wave of BOJ intervention is likely.

So, if you have trades open on a live account, then close them.

Scoobs
 
 
  • Post #291
  • Quote
  • Nov 3, 2011 8:26pm Nov 3, 2011 8:26pm
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
Cheers scoobs.

 
 
  • Post #292
  • Quote
  • Edited 10:22pm Nov 3, 2011 10:08pm | Edited 10:22pm
  •  pah
  • | Joined Apr 2011 | Status: Basket Case | 245 Posts
Quoting SteveHopwood
Disliked
Well, whilst frying brains, how about a look at Sandy's post at http://www.forexfactory.com/showthre...93#post5099393 and the next one down. It isn't just Sandy who has noticed this; there was a contribution in the newbies thread about this s well.
Ignored
I see you spotted the bloop, good catch.

Aside from that, applying a date range filter to your history will render the check of orders in history invalid depending on when the check is made, the time of day, whether you have just restarted your terminal and when there is a full moon.

e.g. If you are in the habit of viewing history just for 'Today' to see where you're up to and time rolls over to the next day, any refresh of the history will remove your latest trade from the history view thus allowing another trade to open too early (within the restricted wait time you've set).


Another thought I had relates to the use of a decrementing loop to check the history trades. It is conceivable that you could miss a trade that goes into history (order hits SL/TP/etc) if this happens just after you have started the check. If you use an incrementing loop it would always check up to the last trade available (but doing this may cause the check to run slightly more slowly as it will potentially have to check more trades before finding one of interest).

I'd suggest try and keep your history view set to the last 3 days or a week whilst the EA is running. This will ensure the latest ones are visible but keep the total number of trades down to a reasonable level.

Regards, Paul.

P.S. MT4 has no knowledge of lunar cycles

P.P.S At least not until Steve's done the LCC module
 
 
  • Post #293
  • Quote
  • Nov 4, 2011 2:30am Nov 4, 2011 2:30am
  •  Carsten
  • | Joined Nov 2010 | Status: Member | 17 Posts
Quoting SteveHopwood
Disliked
My understanding, using Carsten's wonderful idea of creating the 20 boxes in a row and then bending the row so it forms a circle is this:

 

  1. at whatever point in the circle we are, this contains the latest tick.
  2. from here, count backwards 20 boxes. It doesn't matter which way we bend the row, so long as we count back 19, 18, 17 etc, we will arrive at the last box being the current one plus 1.

Therefore, we should be comparing current box with current box plus 1, in whatever direction we bended the row.

Mind, if this happens...

Ignored
That's exactly right.



Quoting magft
Disliked
I'm not surprised your brain is fried

I have had a play around with the example EA by Carsten and you are right, if you look at the out put from the modified version i have added various positions in the ticktable to see the values. TickTable[(tc + 1) % TableSize] seems to give the same value as TickTable[tc + 1] so that is good enough for me.

Nice work.
Ignored
No. Please don't do that. That's bad.

Well of course (tc+1) is going to be the same as (tc+1)%TableSize. The modulo operator doesn't change anything as long as (tc+1) < TableSize.
But you will get into serious trouble as soon as tc reaches the value (TableSize - 1).
Because that's what the modulo is for. To send an access to the element with index TableSize back to element 0.
So, most of the ticks, everything's going peachy. But every TableSize ticks, everything might get batshit insane.
I don't know how the MQL language and the MetaTrader platform handle this kind of access error, because I'm new to both, but in the best case scenario the platform is going to give you an error message saying "you can't do that".
In the worst case scenario, it just lets you access TickTable[TableSize]. Which is not part of the tick table, but rather the 8 bytes following the tick table, presented in the form of a number. Which could be anything, if it's valid at all.
Or, well, another option is that it could make MT4 crash. But crashing is not as bad as crazy trades or something.
 
 
  • Post #294
  • Quote
  • Edited 7:08am Nov 4, 2011 6:48am | Edited 7:08am
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
Quoting pah
Disliked
Another thought I had relates to the use of a decrementing loop to check the history trades. It is conceivable that you could miss a trade that goes into history (order hits SL/TP/etc) if this happens just after you have started the check. If you use an incrementing loop it would always check up to the last trade available (but doing this may cause the check to run slightly more slowly as it will potentially have to check more trades before finding one of interest).

I'd suggest try and keep your history view set to the last 3 days or a week whilst...
Ignored
LCC can stand for a number of things. How about:

 

  1. Lunatic Code Contemplation
  2. Laughable Coding Cockup
  3. Largely Cobbled Coding

Latest update to Hanover in post 1. I have added code that should deal with the potential snag that Paul has spotted.

Those of you who can, go to start() (always the final function in my robots right at the bottom of the code) and add the highlighted snippet:

Inserted Code
///////////////////////////////////////////////////////////////////////////////////////////////
   //Find open trades.
   [color=Red]//First check to see if a trade has closed and wait until it appears in the history tab.
   //TicketNo stores the open trade ticket during each call to DoesTradeExist().
   if (TicketNo > -1 && !OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) )
   {
      while (!OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_HISTORY) ) Sleep(100);
   }//if (TicketNo > -1 && !OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) )[/color]
   
   TradeExists = DoesTradeExist(TradePair);
   if (TradeExists)
   {
      //if (OrderProfit() > 0) TradeManagementModule();
      LookForTradeClosure();
   }//if (TradeExists)

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
  • Post #295
  • Quote
  • Nov 4, 2011 7:28am Nov 4, 2011 7:28am
  •  pah
  • | Joined Apr 2011 | Status: Basket Case | 245 Posts
Quoting SteveHopwood
Disliked
LCC can stand for a number of things. How about:

 

  1. Lunatic Code Contemplation
  2. Laughable Coding Cockup
  3. Largely Cobbled Coding

Ignored
lol, you might have started something now.

I was thinking of changing the code in the MinHoursBetweenTrades check from
Inserted Code
for (cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
to
Inserted Code
for (cc = 0; cc < OrdersHistoryTotal(); cc++)
to ensure that the history check includes all possible trades including any that appeared in history immediately after you start the above loop.

Regards, Paul.
 
 
  • Post #296
  • Quote
  • Nov 4, 2011 8:33am Nov 4, 2011 8:33am
  •  magft
  • | Joined Apr 2011 | Status: Member | 208 Posts
Quoting Carsten
Disliked
That's exactly right.




No. Please don't do that. That's bad.

Well of course (tc+1) is going to be the same as (tc+1)%TableSize. The modulo operator doesn't change anything as long as (tc+1) < TableSize.
But you will get into serious trouble as soon as tc reaches the value (TableSize - 1).
Because that's what the modulo is for. To send an access to the element with index TableSize back to element 0.
So, most of the ticks, everything's going peachy. But every TableSize ticks, everything might get batshit insane.
I don't know how...
Ignored
Cartsen, thanks for replying. What Steve said makes complete sense, i was not thinking clearly at the time and was just going on what the code said not the method itself.

Quoting pah
Disliked
lol, you might have started something now.

I was thinking of changing the code in the MinHoursBetweenTrades check from
Inserted Code
for (cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
to
Inserted Code
for (cc = 0; cc < OrdersHistoryTotal(); cc++)
to ensure that the history check includes all possible trades including any that appeared in history immediately after you start the above loop.

Regards, Paul.
Ignored
Paul the only issue with this is if the EA has been running for a while it could take some time to run this loop. What about checking the OrderHistoryTotal() variable each step and if changed from starting value then restart loop, this should give a marginal execution time increase if there are a lot of orders in the history. For example:

PHP Code
 //Store Current number of trades

int OrderTotal=OrderHistoryTotal();

for (
cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
{
    if (
OrderTotal!=OrderHistoryTotal) cc = OrdersHistoryTotal() - 1; continue;  
    
    
// rest of code 
Or something similar to reset loop to check last new trade closed.

Mike
 
 
  • Post #297
  • Quote
  • Nov 4, 2011 8:59am Nov 4, 2011 8:59am
  •  magft
  • | Joined Apr 2011 | Status: Member | 208 Posts
Steve, i had UseCBI = True on EU chart and this morning it fired. CloseOnCBI = true caused it to close the trade in wrong direction and TradeOnCBI = true tried to open another trade. BUT I forgot to set ECN=true so i have a series of invalid stop errors as TradeOnCbiTP and TradeOnCbiSL were both on .

So on first test it seems to "does what it says on the tin", the EAs i have running with this are in DD at the moment. I will look to put this in the index one i have and see how it fairs next week.

Good work, yet again.

Mike
 
 
  • Post #298
  • Quote
  • Edited 9:33am Nov 4, 2011 9:02am | Edited 9:33am
  •  pah
  • | Joined Apr 2011 | Status: Basket Case | 245 Posts
Quoting magft
Disliked
Cartsen, thanks for replying. What Steve said makes complete sense, i was not thinking clearly at the time and was just going on what the code said not the method itself.

Paul the only issue with this is if the EA has been running for a while it could take some time to run this loop. What about checking the OrderHistoryTotal() variable each step and if changed from starting value then restart loop, this should give a marginal execution time increase if there are a lot of orders in the history. For example:

[php]//Store Current number of trades
int...
Ignored
What you propose doesn't feel right to me. I'll run a quick test to see how long we are actually talking to loop through a small versus large history. If it's negligible I would stand by my original proposal.

edit: test results
I can find no significant differences (all instant sub 1 second ) in execution times when executing the loop using ++ and -- and with 5 & 3000 history records. My conclusion is that you may as well use
Inserted Code
for (cc = 0; cc < OrdersHistoryTotal(); cc++)
to ensure you check all records up to the last possible instance in time while the loop is executing.

Regards, Paul.
 
 
  • Post #299
  • Quote
  • Nov 4, 2011 9:09am Nov 4, 2011 9:09am
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
I left Generic running on GJ through NFP and it traded like a nutter.

I could not be at the computer at the time, as I was giving a piano lesson. Looking at the history tab, it kept on selling, then hedging its way back in the right direction and emerging with a profit $150 trading 1 lot on a $50,000 demo. Not bad for 3 minutes trading.

It looks as though the initial trade code needs tightening up and the Threshold probably needs doubling, at least.

We probably need some sort of trade-1-cycle-only filter. I shall mull that over.

With a bit of tweaking, it looks as though we may have a goer to experiment with properly here. StuffTheNews will emerge in time for demoing next week.

 
 
  • Post #300
  • Quote
  • Nov 4, 2011 11:04am Nov 4, 2011 11:04am
  •  SteveHopwood
  • | Commercial Member | Joined Apr 2007 | 8,331 Posts
I have to go out for a while, so I am leaving this for the coders to investigate.

Attached is the first version of StuffTheNews. I have removed all the code we shall not need in a news trader.

I have added more info to the screen display so we can see what is going on. From left to right, once the chart has been populated:

 

  1. tc: tick counter.
  2. most recent tick
  3. first tick in the table
  4. the direction of movement from a comparison of the two ticks
  5. the difference between the two ticks
  6. the threshold

As you can see, there is some inaccuracy.

 

  1. The most recent tick on the display and that shown by the Bid are often different.
  2. The difference value looks wrong to me, but my brain has turned to mush again and I cannot work out what is wrong. The calculation lives in void StoreQuote()
  3. when tc = 4, the highest possible given the default TableSize of 5, the first tick in the table often shows up as zero

There will be a little logic bloop somewhere, probably a calculation in the wrong place, but I am blowed if I can spot it. The attached pic highlights some of the wrong thingies.

If anyone can spot what is wrong, that would be fabulous.

More later.

Attached Image (click to enlarge)
Click to Enlarge

Name: stuff.gif
Size: 13 KB
Attached File(s)
File Type: mq4 StuffTheNews.mq4   56 KB | 230 downloads
 
 
  • Commercial Content
  • /
  • Hanover: an auto-trader using Recent Strength
  • Reply to Thread
    • 1 121314Page 1516 17
    • 1 14Page 1516 17
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023