MMA_Breakout_strategy_volume I (without MM or MF) - coded by WhooDoo22

 
I thought it would be helpful for new coders (and experienced coders) to post an updated version of MMA_Breakout_strategy_Volume I, so novice/experienced coders alike could have a chance of understanding the two important updates  required for this EA (volume I) to run smoother and more efficiently. This version does not include money management or market filtration and is still considered volume I. (I am still deciding how to implement both money management and market filtration features into volume I to ultimately evolve volume I to volume II. I will share a portion of my thoughts of accomplishing both tasks of MM (money management) and MF (market filtration). MM: As you well know, volume I uses a single order and partially closes its order as the moving averages cross. This goal for MM is to increase the lot size as the account balance grows (example: account balance increases $1,000, code block will adjust the current lot size to double the current lot size. This code block will also decrease the lot size to half the current lot size if the account balance loses $1,000. This is the current objective for MM. As for MF: I am thoroughly considering all options before opening this door to my inexperienced coding territory. I can think of multiple ways to accomplish this task. The question remains for me, which option should I choose? I have begun coding versions of volume II with MF feature to become familiar with new and different techniques. Repetition of trial and error will guide me to the completion of this project. Be sure to run from 1999-2012.10 on M15 time frame EURUSD to verify most recent back test posted of volume I (it is also considered partly volume II). On a side note, I am blown away volume I has been downloaded 10,000 times within two or so months! WOW! :) I am so glad my work has proven itself valuable to coders/traders. Thank you. - WhooDoo22.
 
How can you select a ticket with a number of 0 on a Live or Demo account ?  what happens if any of your OrderSelect() calls fail ?  why aren't you checking return values and reporting errors ? 

What are Function return values ? How do I use them ?
 
Hello Simon, I understand there are currently minor issues of less priority than MM and MF for the time being. I do plan to scour volume II after adding MM and MF. I will trim it by adding code to select orders by magic number, code to run volume II on 4-5 digit brokers, etc. I do understand there are many small details of note to be overseen, but for now, the more difficult work will be undertaken first. Your incite is well received and I plan to cross this bridge when I get to it. I will visit the link you provided. Thank you.
 
WhooDoo22:
Hello Simon, I understand there are minor issues of less priority than MM and MF for the time being. I do plan to scour volume II after adding MM and MF. I will trim it by adding code to select orders by magic number, code to run volume II on 4-5 digit brokers, etc. I do understand there are many small details of note to be overseen, but for now, the more difficult work will be undertaken first. Your incite is well received and I plan to cross this bridge when I get to it. I will visit the link you provided. Thank you.
If I thought what I had written in that link was a nicety or option or something to be added at a latter date if time allowed I wouldn't have taken the time to write it . . . .  it's essential IMO !  how many posts are there asking about error 130 ?  or error 138 ?  check the return values,  if you have a problem print the error and all relevant variables . . . .  then when you have a problem you will have the information needed to determine the cause.  

You can't go back in time to find what the Ask was when you tried to place an Order and it failed  . . . 
 

What is variable  i  how can it be a ticket number when you do this to it ?

i++;

 I have 4 live trades at the moment,  their ticket numbers are not sequential . . .

 

Simon,

If I thought what I had written...

RE: I understand that this fix is a necessity. I will fix this, I believe sooner than I thought because u seem very adamant in this fix being applied. I agree that this fix should be applied and will run tests with the error check function to isolate the error source. I will get back to this Simon. Thank you.

What is variable  i...

RE: Variable i is a dummy ticket variable, but ;) i is not actually a ticket; i is considered a simple variable by the EA. The EA counts variable i instead of counting the actual ticket number (alternative method of counting current ticket).

 how can it be a ticket number when you do this to it ?..

RE: Variable i is not actually a ticket number. i is a dummy ticket variable which is counted by the EA to keep up with the current ticket number count. Bottom line, variable i is not considered a ticket number.


I wished to answer your posts asap, but cannot provide extensive answers until I possess time to explain and discuss.

Thank you for your important post!

 
WhooDoo22:

Simon,

I wished to answer your posts asap, but cannot provide extensive answers until I possess time to explain and discuss.

Thank you for your important post!

You can answer when you have time,  that is OK  :-)

 

If  i  is a dummy ticket number . . . .  what is the point of doing this ?

OrderClose( i,  0.01,Ask,30,CLR_NONE); 

 isn't that guaranteed to fail ?

 
I believe there are multiple ways to select orders, All methods of selecting orders should use the OrderSelect() function. With that said, I do not see why this would fail because the EA clearly performs the OrderClose() function for all orders without error in the strategy tester. It is possible that errors will present themselves, but I have not noticed any as of late. I will be more specific by stating this: "Variable i" is a substitute for the ticket number AND variable i is used by the OrderClose() function blocks. It has been some time now, but I believe the reason I wrote the code as written was because I begin the program in the first OrderSend() code block IF the OrdersHistoryTotal() == 0. I needed to select a ticket not variable i in order for the OrdersHistoryTotal() function to recognize what ticket I was selecting so it could "give the green light" to send an order. It can be difficult for me to clearly express this in words. Thank you.
 
WhooDoo22:
I believe there are multiple ways to select orders, All methods of selecting orders should use the OrderSelect() function. With that said, I do not see why this would fail because the EA clearly performs the OrderClose() function for all orders without error in the strategy tester. 
How does it perform on a Demo account where you have ticket numbers that do not start at 1 and go up incrementally ?
 
I am not familiar of the differences between demo and live except for the concept of virtual and actual funds for accounts. I am unaware of this difference. Currently I believe OrdersHistoryTotal() starts at 0 before any order is submitted AND terminated. I believe the OrderClose() function would not be executed unless ;) there was a variable to select. This is where variable i is presented in the first code block in the execution below "i++". Once i variable is 1 aka i++, OrderClose() function checks for the 1. The OrderClose() function is like, "yeah, I see ya i, we are good to close this order now. Thank you.
 
WhooDoo22:
I am not familiar of the differences between demo and live except for the concept of virtual and actual funds for accounts. 
OK,  I'm talking about the difference between the Strategy Tester and Demo/Live . . .  in the ST the first order is ticket 1 . . .  I just placed a Demo trade and my ticket number is 46322730 . . . if I place a 2nd trade it's ticket number will not be 46322731   In this situation how does incrementing the variable you are using for the ticket number work ?
Reason: