You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey Tim,
I was up till about 2am yesterday transforming the PSC into C (pseudocode into code). Started straight after I got home from work.
Finishing the first draft I realised i) we had a few things missing, ii) we have to make everything 'pair' specific.
just to check if I'm on the right lines, could you share some wisdom on this:
1. We can't use 3 ema's without specifying the symbol when we declare each iMA or the EA won't work properly. thus we have to declare 15 ema's (5 symbols with 3 Ma's per symbol)?
2. We missed out CountOrders function. Again, because of 5 pairs. We need 10 functions. eg: EUR_USD_BuyCount, EUR_USD_SellCount; etc. ?
3. I realised there's an efficient way to write the code, and a 'newbie' way. I'l do the newbie way and then would appreciate if you could show me how to make it efficient.
4. Magic Numbers. I aspire to what you are doing and thus would like to run multiple EA's at once. I looked into Magic Numbers but for the life of me can't really grasp it, not even from other code. Could you direct me somewhere where I can learn more about how to make sure the computer differentiates between the different EA's.
Thank you
Nick
Hi Nick
I'm sorry but you are loosing me here. We seem to be putting the cart before the horse again and consequently are going backwards. In my previous posting I suggested that you set up a basic structure for your program using the MetaTrader EA wizard and the pseudo code that we had already written . Can you go back and complete that step and post the results ( The mq4 file) on this forum for me to have a look at?. Then we can move onto the next step. You certainly dont need 15 ema's, 10 functions or magic numbers for that matter either and in the unlikely event we have issues with specific broker requirements we can deal with them if and when we come to them.
I can probably guide you through the process of writting your first EA but only if you are willing to do it one step at a time and post the results back to this forum each time for me to review. Otherwise I think this little project will just run off the rails, wasting my time and yours.
You said - I'l do the newbie way and then would appreciate if you could show me how to make it efficient.
Nick it is a frustrating and time consuming exercise trying to sort out someones bad code. Usually it is just not worth the effort.
Regards
Tim
Hey Tim,
Sorry to have frustrated you, I misunderstood you. You said I should code now even though it wont' run and so I thought I should go ahead and code it. Thus I spend quite a bit of time coding it, trying to aleviate the work off you - but it turned out to be the other way round.
But no worries, I'l post the PseudoCode in the EA framework if that's what you mean. Then you could guide me through each block if you have not lost the patience by then :)
Hey Tim,
I attached the Pseudo Code in an EA Format with brackets editing it. Let me know if I still didn't get what you meant and I'l change it as needed. Only the flags and filters I declared to save you time. I didn't touch anything else. I didn't create names for functions because I still don't understand what they will be, as you clearly understood from my last message. What's the next step from here boss?
Hey Tim,
I attached the Pseudo Code in an EA Format with brackets editing it. Let me know if I still didn't get what you meant and I'l change it as needed. Only the flags and filters I declared to save you time. I didn't touch anything else. I didn't create names for functions because I still don't understand what they will be, as you clearly understood from my last message. What's the next step from here boss?
Hi there. I got impatient - whilst I agree with the need for pseudocode, I think you guys were going a bit overboard (sorry Tim).
Just knocked this up. Only really spent half an hour on it, haven't checked it for errors, syntax, etc. etc.
But if you give it a whirl, it should be fairly close to what you need. I've purposely left it as a bare bones to let you see the structure but so that you'll still have work to do. As an example, I've purposely left out all error checking in the fnTrade function and an error in the TakeProfit handling.
CB
UPDATE: Due to Tim's subsequent post, I've deleted the EA I created for you and will back off and let Tim do it instead.
TIM: With reference to your post about the multi-currencies logic, I had structured that EA to be symbol-agnostic, as that was what Nick told me he wanted whilst I was working with him before you arrived to take over.
Hi Nick. Cloudbreaker
Cloudbreaker, I note your frustration at the slow progress. I thought the point of this exercise was to teach Nick how to program using MT4. Judging by a lot of the code and discussions related to coding that I have seen on this forum, I stand by my assertion that a systemic approach is the most reliable and often the quickest way to produce good quality code.
I do take your point however that this is quite a trivial project and that any proficient programmer would knock up something like this very quickly with a minimum of formality. I'll endeavour to move things along as fast as I can to minimise the frustration to eveybody but please keep in mind that learning often takes time and it is easy for those who can do to get frustrated with those who are trying to learn.
Nick,
The code that you posted wasn't quite quite what I was looking for. I have tided things up a bit and made a few notes for you in the code with a few things for you to do.
The next task is to provide a way to handle the different currency pairs without writing seperate procedures for each pair.
One way to do this would be to declare the currency pairs as an ARRAY of STRINGS in the global declaration area.
Then in the main program block - (start function) Use a FOR loop to index through the array
Nick have a go at programming this code and then post it back on the forum
We also need to start thinking about error handling. testing and debugging. One common way to do this in MetaTrader is using the log files. I've added a few lines in the EA to try and get you started.
Please have a look and try and understand what I have done. You can run the code and have a look at the log file on an active account or in the strategy tester.
Regards
Tim
Hey guys,
Thank you both for your support on this journey! I agree a systematic approach is essential for a newbie, but just as important is delving into the code. Those two components help each other grow and encourage the learning process. This is what I realised and thus I spent time on both. The better one understands the coding process the better their pseudocode and the subsequent program will be.
I'l proceed with this endeavour, working with both documents in parallel - I think that would speed up the learning process like nothing else, as I'l have a specific point of reference.
The main focus will be on transforming the pseudocode into the code, but I'l use CB's document for ideas on how and what parts to add as well as use it in parallel to learn, of course also with Tim's guidance along the way.
Nick
Hey guys,
Thank you both for your support on this journey! I agree a systematic approach is essential for a newbie, but just as important is delving into the code. Those two components help each other grow and encourage the learning process. This is what I realised and thus I spent time on both. The better one understands the coding process the better their pseudocode and the subsequent program will be.
I'l proceed with this endeavour, working with both documents in parallel - I think that would speed up the learning process like nothing else, as I'l have a specific point of reference.
The main focus will be on transforming the pseudocode into the code, but I'l use CB's document for ideas on how and what parts to add as well as use it in parallel to learn, of course also with Tim's guidance along the way.
Nick
Hi Nick, I'll back off now. See amendment to my post above.
CB
Hi Nick, I'll back off now. See amendment to my post above.
CB
Hey CB, I thought you would, so I was quick enough to download it. As I mentioned before, anything regarding the idea I have is helping me learn, your code won't discourage my learning as I won't copy it into Tim's template, I will try and understand it instead to see how things can be done diffrerently :)
Anything helps as they say!
Hey CB, I thought you would, so I was quick enough to download it. As I mentioned before, anything regarding the idea I have is helping me learn, your code won't discourage my learning as I won't copy it into Tim's template, I will try and understand it instead to see how things can be done diffrerently :)
Anything helps as they say!
No worries. With only a few amendments, it should actually do the job for you.
You should start by amending the TakeProfit "error" I built in for you. Have a look at how the StopLoss is done for a clue.
Once you've got it working, I hope you'll start adding in error handling, and some operator-friendly stuff like Print() statements so you can see easily in the logs what it is doing.
Pseudo code is important before committing to code (even for seasoned programmers), but don't overcook it.
You seem to attract help due to your good-natured manner. My guess is that you either work in HR or are interested in human psychology?
CB