| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| New Bar in MTF code https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4010 |
Page 1 of 1 |
| Author: | Radar [ Wed Dec 24, 2014 1:44 pm ] |
| Post subject: | New Bar in MTF code |
Hey Gang, I'm working on a multi-timeframe EA, and am having a problem with detecting a new bar on the higher timeframes. The EA sits on an M1 chart, and loops through the timeframes, and uses an ATR/AverageSpread filter to determine which timeframe to enter trades on. I have another filter in place to ensure that only 1 trade is entered per bar, but it's not quite right Here's the code for the M1 (the code for the other timeframes are the same, Just replace M1_ with M5_, M15_, etc)... Code: Select all Have fun! Radar =8^) |
|
| Author: | gringoh [ Wed Dec 24, 2014 3:27 pm ] |
| Post subject: | New Bar in MTF code |
Hi Radar, In MPTM EA is trading multiple pairs I have a control to limit trades to 1 trade per bar. If you check the code, you can find a solution which should suits your needs. Control is line 1855 “OneTradePerBar”, it is using CountOpenTrades first to identify open trades. Hope it can help. Merry Christmas. Cheers, G |
|
| Author: | Radar [ Wed Dec 24, 2014 3:29 pm ] |
| Post subject: | New Bar in MTF code |
Thanks, Gringoh edit... Looks like we're doing the same thing, but different Code: Select all Note that I said was... Even though I haven't changed the code, it is now working properly... I've noticed this a few times when testing my code in the backtester... Something will go haywire for the first few tests, then, after messing with the code for hours, and eventually going back to the original code, the damn thing works properly, and doesn't mess up again. If I coded more often, I'd remember that bit 'Ave a good one, Radar =8^) |
|
| Author: | dietcoke [ Fri Dec 26, 2014 11:41 pm ] |
| Post subject: | New Bar in MTF code |
Radar, I have a library function which can identify whether there is a new bar on any timeframe. just add it as an include file in your EA and run LookForNewBars(Symbol()) on every pass. The bool variables IsNewM1bar IsNewM5bar IsNewM30bar IsNewH4bar IsNewM15bar IsNewD1bar IsNewH1bar IsNewW1bar IsNewMN1bar are available for you to use. eg. Code: Select all |
|
| Author: | Radar [ Sat Dec 27, 2014 4:51 am ] |
| Post subject: | New Bar in MTF code |
Hey Dietcoke, Thanks for that Have fun! Radar =8^) |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|