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

 

Simon,

1. . . .  what ticket number is it selecting ?

RE 1.: I had a misunderstanding in a use of the OrderSelect() function in combination with OrdersHistoryTotal() function. Neither function has anything to do with the other. With this understood, I can simply remove the OrderSelect() function from the beginning of the first order send code block. It is unnecessary (remember, this code was written strictly for testing purposes, not to run in demo or live. Obviously eventually it must be corrected so it can be used on demo and live accounts.).

Also, I believe I get your repetitive point, "check return values with GetLastError() function." GOT IT. Ha ha :)

2. If you understood OrderHistoryTotal() you...

RE 2.: I understand OrdersHistoryTotal() functions purpose. I had a misconception of the use of OrderSelect() function in combination with OrdersHistoryTotal() function.

3. If you understood how {  }  braces worked...

RE 3.: I believe I do understand the proper use of braces. I also understand that braces can be unnecessary in this case-

if(OrderType()==OP_BUY)  
   OrderModify(ticket,0,OrderOpenPrice()-5000*Point,0,0,Blue);

I decided to use unnecessary braces to ensure each code block's expression(s) was isolating its function calls to each specific code block being used. Very tidy stuff, I don't want the EA's code blocks to accidentally skip their function calls due to a lacking of braces.

4. Using the variable i  as a ticket number:

RE 4.: I am a bit surprised you do not understand my interpretation of using the i variable as a dummy ticket number, not a ticket number. Variable i is simply a digit that is added every time the OrderClose() function is executed. Variable i is not defined as an actual ticket number. I am dealing with partial order closing. This is the only way I am aware of to accomplish this task. I would be open minded to a different solution. Do you have a better solution? :) I believe there might be another way, but for now, I do not see a reason to change the process being used. Again, I am open to productive ideas.

5. . . .  if the OrderSend() fails  ticket   will = -1:

RE 5.: Please be specific as to which OrderSend() function you are referring to (either the "ball roller", first order send OR order sends within the order close function calls) This clarification would guide our thoughts to the same direction and would strengthen communication between both members of this discussion.

1. Why would the 1st or 2nd (correct this plz) order send fail? (maybe because of misuse of the OrderSelect() and OrdersHistory...() function? This will be corrected.)

2. If the order send failed, why would the ticket variable represent -1? I believe if the order send failed, the the ticket variable would still represent 0 not -1. Please explain.

Thank you.

 
WhooDoo22:

Simon,

RE 5.: Please be specific as to which OrderSend() function you are referring to (either the "ball roller", first order send OR order sends within the order close function calls) This clarification would guide our thoughts to the same direction and would strengthen communication between both members of this discussion.

1. Why would the 1st or 2nd (correct this plz) order send fail? (maybe because of misuse of the OrderSelect() and OrdersHistory...() function? This will be corrected.)

2. If the order send failed, why would the ticket variable represent -1? I believe if the order send failed, the the ticket variable would still represent 0 not -1. Please explain.

Thank you.

If OrderSend() fails,  for any reason  . . .    "Returns number of the ticket assigned to the order by the trade server or -1 if it fails. "  taken from the documentation.  You use variable   ticket   to retain the returned value . . . so if the OrderSend() fails  ( for whatever reason )  your ticket number is now -1 . . . .  you don't check you just hope for the best and use whatever you get . . .  


You are using the variable  i   as a ticket number  . . . in this code . . .

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

  . . . from the documentation for OrderClose()  the first variable in the function call is an int . . .  ticket  -   Unique number of the order ticket.  So lets assume that you have just closed ticket number  34282694  what makes you think you think that doing  i++;  next is going to help you in any way shape or form ?  Perhaps you could answer this particular point and explain how it works ?

 

"I don't want the EA's code blocks to accidentally skip their function calls due to a lacking of braces." . . . accidentally skip ?  how do you think that might happen ?  the CPU gets into a coughing fit or catch a cold ?  


OK,  so you are saying that you fully understand all the issues yet rather than writing code that could work in the Strategy Tester and also in a Live/Demo environment you specifically chose to cripple your code by writing it so that it would only work in the Strategy Tester ?  this is what you are saying ?

 

Simon,

1. If OrderSend() fails,  for any reason  . . .

RE 1.: Hypothetically, lets just say an order fails... If what you said is true, then the ticket count is subtracted by 1 (-1 from the ticket total). So, the EA sent and closed 25 successful orders. Signal arrives to send order and the OrderSend() function fails. Is the current ticket count 24? If so, the i variable would state a false ticket count because i variable would not subtract 1 as well (-1). i variable would simply not increase and now there is a false ticket count. Correct ticket count is 24 and i variable ticket count is 25. The OrderSelect() function is now selecting the incorrect ticket number. Are we in mutual agreement? :) So it appears that the obvious solution would be to subtract 1 from the i variable if the OrderSend() function fails. Whew... Wiping sweat off my brow on that one :).

2. the CPU gets into a coughing fit or catch a cold ?..

RE 2.: Typically, if I get a flu virus, I tend to skip a few sensible thoughts when I speak. I assumed the same applied to CPUs :) With humor set aside, I believe any possibility of a function call being skipped due to the lack of "{ }", would be a simple problem to be fixed. Why not be extra careful? If there is truly no concern of a function call being skipped, then I see no reason why braces should not be removed.

3. OK,  so you are saying...

RE 3.: I believe I understand issues you have presented me thus far. 

4. you specifically chose to cripple your code by writing it so that it would only work in the Strategy Tester ?..

RE 4.: I chose to sacrifice what I believed held least priority and kept what I believed held most priority. This was a choice made based on time limitations and priority levels.

Thank you.

 
WhooDoo22:

Simon,

1. If OrderSend() fails,  for any reason  . . .

RE 1.: Hypothetically, lets just say an order fails... If what you said is true, then the ticket count is subtracted by 1 (-1 from the ticket total). So, the EA sent and closed 25 successful orders. Signal arrives to send order and the OrderSend() function fails. Is the current ticket count 24? If so, the i variable would state a false ticket count because i variable would not subtract 1 as well (-1). i variable would simply not increase and now there is a false ticket count. Correct ticket count is 24 and i variable ticket count is 25. The OrderSelect() function is now selecting the incorrect ticket number. Are we in mutual agreement? :) So it appears that the obvious solution would be to subtract 1 from the i variable if the OrderSend() function fails. Whew... Wiping sweat off my brow on that one :).

If what I said is true ?  read the documentation for yourself, I gave you a link,  click it and read . . .
 

You are totally misunderstanding how this works . . . sorry but you are.  Ticket numbers only run sequentially in the Strategy Tester . . .  the ticket count is is not subtracted . . .  the variable you are using to hold the ticket number = -1  you never subtract the variable ticket from anything in your code . . .  

" Signal arrives to send order and the OrderSend() function fails. Is the current ticket count 24?"     Nope, the  ticket  variable holds the number -1,  not 25 or 24, it holds   -1  so any OrderSelect(ticket, . . .) calls that follow this will fail because there is no order with ticket number -1 ,   it's an invalid ticket number . . .  then any OrderType() calls will also fail because the OrderSelect() failed . . . . . and then the OrderModify(ticket, . . . .) fails too . . .

As you have said  you understand all these issues but chose to ignore them and submit this code to the codebasee . . .  i guess I don't need to waste any more time trying to explain any of this as you already have a good handle on it.  Sorry for the inconvenience,  I won't take up any more of your time trying to help. 

 

Simon,

I will read the documentation as you requested.

1. the variable you are using to hold the ticket number = -1

RE 1.: Which variable are you pointing out? Variable i OR variable ticket?

2. the variable you are using to hold the ticket number = -1

RE 2: Can this also be said, "when an order send fails, the ticket number is minus one (-1)?"

if this is the case, if the EA sent and closed 24 successful orders and failed to send the 25th order, the current ticket number is minus one (-1). Correct? :)

Obviously any code blocks containing OrderSelect() function will fail due to "invalid ticket number" error. I think it's error number is 4108 as you previously wrote and the documentation reads this as well.

I did not write, "I understand all these issues." I wrote, "I believe I understand issues you have presented me thus far."

3. "As you have said  you understand all these issues but chose to ignore them and submit this code to the codebasee . . .  i guess I don't need to waste any more time trying to explain any of this as you already have a good handle on it.  Sorry for the inconvenience,  I won't take up any more of your time trying to help."

RE 3: I am not ignoring these issues presently. My discussion with you shows this. I am interested in all points you have made and continue to make. Also, I respect your knowledge of MQL4 documentation and appreciate your desire to help. It has not gone unnoticed and I thank you for this.

Thank you.

 

Hello all,

 In this code i realize that  i cannot change any of the lot price....why is that...

all the time that i was trying to do this i got an error....

 

Thanks...and waiting for ur answer....

Very good job WhooDoo22!!!! ;) 

Reason: