| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| My shell EA code https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=79 |
Page 22 of 23 |
| Author: | LittleCaro [ Tue Oct 08, 2019 11:44 am ] |
| Post subject: | My shell EA code |
Hello all, I have a little problem, So i'm coding an expert with the amazing steve's shell ea code, and i'm using the read indicator values module, and the close order on opposite direction signal fonction. Here is the problem, sometimes (maybe 3 times out of 10), the expert closes the order (so he reads correctly the indicators and get the good signall), BUT the opposite trade is not sent. And i didn't see any tracks of "context is busy" in the logs. I wonder if some doctors could help here ? Thanks ! |
|
| Author: | LittleCaro [ Tue Oct 08, 2019 1:44 pm ] |
| Post subject: | My shell EA code |
Hey guys, I think i got it : At the end of the code (in the lines 4400), i replace the line : Code: Select all Code: Select all And since the expert didn't miss any trades. Greatly helped with the comment in the code. ![]() |
|
| Author: | SteveHopwood [ Tue Oct 08, 2019 4:01 pm ] |
| Post subject: | My shell EA code |
| Author: | K-Lander [ Tue Jun 16, 2020 4:50 pm ] |
| Post subject: | My shell EA code |
Hello Everyone, I´ve been using the Barebones shell to code different strategies based on price action. One problem I have stumbled upon several times, and was unable to solve due to my limited coding skills, is related to the fact that many of my strategies consider the price action since the beginning of a given bar and how the bar develops in time. The problem is that if the EA works on H1 and a trade closes at, let´s say, 15:33, I have no way to make the EA get back to work at 16:00, i.e. at the beginning of the next H1 bar (the same applies to any other timeframe). The "Sleep After Trade Closure" input only allows me to make the EA sleep for a fixed number of minutes, while I need it to sleep until the beginning of the next bar. I think it would be a nice addition to the shell. I would be truly happy and grateful if anyone could propose a solution. Thanks y´all, and stay safe. Ariel |
|
| Author: | SteveHopwood [ Tue Jun 16, 2020 7:00 pm ] |
| Post subject: | My shell EA code |
Great to see you getting your hands dirty. I will tell you what to do because this is usually the hardest part to work out. You can work out the actual code because it is more satifsying for you, but post again if you get hopelessly stuck. Declare a boolean in the general inputs section, that tells your bot whether to wait for the open of the next candle or not, so you can experiment if need be: Code: Select all Code: Select all Code: Select all Code: Select all |
|
| Author: | K-Lander [ Tue Jun 16, 2020 7:54 pm ] |
| Post subject: | My shell EA code |
Great Steve, will give it a try this week and post again for help if need be. I was thinking in a much more complicated way to do it, actually. Your approach makes a lot more sense. Thanks a bunch, Ariel |
|
| Author: | K-Lander [ Wed Jun 17, 2020 12:49 am ] |
| Post subject: | My shell EA code |
Hi Steve, I understand the logic; not so sure about the syntax and where to insert it within Bare Bones. I came up with this time-checking routine though. Would you mind take a look? Thanks, bool DidTradeCloseBeforeCurrentCandle() { total = OrdersHistoryTotal(); for(i = total - 1; i >= 0; i--){ OrderSelect(i, SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol() == Symbol()) { if(OrderCloseTime()>=iTime(NULL,0,0)) return (false); }} return (true); } Great to see you getting your hands dirty. I will tell you what to do because this is usually the hardest part to work out. You can work out the actual code because it is more satifsying for you, but post again if you get hopelessly stuck. Declare a boolean in the general inputs section, that tells your bot whether to wait for the open of the next candle or not, so you can experiment if need be: Code: Select all Code: Select all Code: Select all Code: Select all |
|
| Author: | SteveHopwood [ Wed Jun 17, 2020 11:13 am ] |
| Post subject: | My shell EA code |
You are on the right track. A tip. Next time you post code, encase it within the code button for readability - 5th button along. Compare this: bool DidTradeCloseBeforeCurrentCandle() { total = OrdersHistoryTotal(); for(i = total - 1; i >= 0; i--){ OrderSelect(i, SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol() == Symbol()) { if(OrderCloseTime()>=iTime(NULL,0,0)) return (false); }} return (true); } with this: Code: Select all Errors would show up if you tried to compile your version i.e.
Code: Select all |
|
| Author: | K-Lander [ Wed Jun 17, 2020 4:12 pm ] |
| Post subject: | My shell EA code |
Well, here it is. Attached I am posting Bare Bones with the new feature. I´ll be running it to make sure it indeed works as expected. In the meantime, if you could check the code, it would be great. The extern user input is in line 229, right after TradingHours; The routine that checks whether there is a closed trade in the current candle is in lines 2187 to 2200. The conditional within IsTradingAllowed is in lines 1175 to 1182. It compiled ok. Strange, no mismatching parentheses this time. Must be doing something right for a change |
|
| Author: | SteveHopwood [ Wed Jun 17, 2020 5:58 pm ] |
| Post subject: | My shell EA code |
Looks good to me. By the by, what I wrote about OrderSelect() was slightly incorrect and only applies to orders selected by ticket, not pos. Even so, stick with BetterOrderSelect() because: it makes sure you never fall foul of the OrderSelect() function; when one of the genius coders here replaces a Crapql4 function with his/her own code, then it is best to use it. The subconscious is an amazing thingy and mine was at work as I typed the above. It just told me that I had given you duff info about the call to the function as well. Think about this call: Code: Select all Code: Select all |
|
| All times are UTC | Page 22 of 23 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|