| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| My shell EA code https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=79 |
Page 3 of 23 |
| Author: | gaheitman [ Thu Dec 08, 2011 4:25 pm ] |
| Post subject: | Re: My shell EA code |
I needed to have a third trading session, one for each global banking session, so I updated the code to speak in terms of Asian, European and US sessions. Not sure if anyone else needs this, but I thought I'd post it should the need arise. Externs: Code: Select all Code: Select all Code: Select all EDIT: OK, it does change "b-r-o-k-e-r" to "criminal" in code. George |
|
| Author: | SteveHopwood [ Thu Dec 08, 2011 10:17 pm ] |
| Post subject: | Re: My shell EA code |
Latest update in post 1. This acts upon advice George gave me in our NB 10.1 about avoiding order modify errors. Question for you George, and anyone else here with ideas. A lot of the Stealth stop loss manipulation depends on HiddenPips being > 0. The usual construct is: if (HiddenPips > 0) do something; What if, right at the outset, I made the bot draw the tp/al lines, but set the colour to CLR_NONE if HiddenPips = 0? Then, we could forget about whether the user has chosen to use Stealth or not. The only thing that niggles me is this: will there be problems if the bot is trying to close a trade by Stealth that has already closed through hitting the 'hard' sl/tp? I think the code takes care of this with the very first line in bool LookForTradeClosure(int ticket) Code: Select all Any comment, guys and guyessess, or children of tender years but unimaginably high iq's? |
|
| Author: | gaheitman [ Thu Dec 08, 2011 11:05 pm ] |
| Post subject: | Re: My shell EA code |
I like the invisible lines. What I did for my own code was I changed HiddenPips to a double and set it to 0.1 and called it a day. As for the existing filter, the OrderSelect() will still select it whether it is open or not, since it is selecting by ticket number (unless it is passed a bad ticket number). The code to catch the closed ticket is the next line. I don't think you need the OrderSelect() in the second line, since it will be selected if we get past the first test. The current test: Code: Select all Code: Select all Code: Select all Reading a bit further, you probably want to call GetLastError() to see why the error happened. You don't necessarily have to do anything with it, but if there is an error and you don't check it, the "last error" is still there and other code may call GetLastError() when there wasn't an error and think there was one. Wow, that last sentence doesn't read very well. George |
|
| Author: | SteveHopwood [ Thu Dec 08, 2011 11:18 pm ] |
| Post subject: | Re: My shell EA code |
Hehe. I have learned this over the last 4 years: beat Empty4 over the head until it finally submits and allows you to do what you want. So, if a code snippet can be lumped together in one line or can be separated into multiple lines with a gazillion checks to make sure that each line has executed, then go for the second option. I know my own code does not always reflect this understanding, but that is because it has developed over 4 years. Were I to code mptm from scratch now, for example, the code would be radically different. This does nothing to change this fact of life: Empty4 is total crap and as coders, we have to spend most of our lives battling with it. George, for sure you are making my battles easier with each post you make. |
|
| Author: | dietcoke [ Thu Dec 08, 2011 11:43 pm ] |
| Post subject: | Re: My shell EA code |
Steve, FWIW, my view is that the implementation of stealth in the shell code is not complete and not really generic enough. I think the biggest problem is that there is only one value for HiddenPips which is used for both the SL and TP. I know this is probably a ridiculous amount of work but how about bringing in the stealth code in MPTM, to manage TP/SL. The two functions: void HiddenStopLoss() void HiddenTakeProfit() could form the basis of stealthy TP/SL. Instead of hidden pips This code does not use lines to manage the TP/SL at all, the calculations are done on the fly based on the trade management strategy. Doing this would give a number of advantages such as: Different values for SL and TP. Display of lines could then become an extern option when in stealth mode. You can have a stealthy stop and a visible tp. Just a thought. DC. |
|
| Author: | SteveHopwood [ Thu Dec 08, 2011 11:58 pm ] |
| Post subject: | Re: My shell EA code |
And a worthy one too. Thing is, mptm is a vast piece of software. Coders alter it at their peril. The moment anyone considers making changes, LUC starts cranking out the invitations to the party by the lorry load. The cut-down mptm functions that ship with all my bots these days bear only a passing resemblance to those in the real mptm. They work very well and target specific needs. mptm is still the grand-daddy of trade management and can be used instead of the cut-down version when more sophisticated thingies are needed. |
|
| Author: | gaheitman [ Fri Dec 09, 2011 8:52 am ] |
| Post subject: | Re: My shell EA code |
Steve (and everyone else), I need to write a procedure for my own strategy that stops trading for the day, so I thought I'd try to make a generic one for use in other bots. I was planning on calling it DoneForTheDay() and hooking it into IsTradingAllowed(). That way all the trade management stuff will still happen, just no new trades. Some options I've come up with to trigger a stop for the day: The obvious ones:
The less obvious (need more idea here):
So that should get people started. I certainly have enough to start coding. George |
|
| Author: | SteveHopwood [ Fri Dec 09, 2011 9:20 am ] |
| Post subject: | Re: My shell EA code |
That is fantastically generous again George. Hehe; in a pm, I have just described you as TIG - The Incomparable George. Sometime over the weekend I am going to adopt your trading-times code into the shell. Cheers |
|
| Author: | ironrick [ Fri Dec 09, 2011 9:15 pm ] |
| Post subject: | Re: My shell EA code |
I AGREE! Three Cheers for George! Hip! Hip! Hip! What a cool thing to have such a brain trust here! But not just a passive one -- a trust that is so generous with their time to actively help others! You have accomplished an incredible feat, Steve, over the years. And the rapid rise of your forum is the proof of others' thankfulness. Thanks! Rick
|
|
| Author: | ironrick [ Fri Dec 09, 2011 9:24 pm ] |
| Post subject: | Re: My shell EA code |
Now back to the subject at hand... Because it has been on mind, I was thinking of other trade-length time-based options. Rather then just a clock time -- End trade at 2:30pm, end the trade/trading after a certain AMOUNT of time -- Start at 7:00am/x signal/MA cross/whatever and end after 5.5 hours. Just a thought. Rick |
|
| All times are UTC | Page 3 of 23 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|