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

 
Why don't you fix the code that is the subject of this thread before moving on to another version . . .  you would learn so much if you did.
 
Simon,


Another point . . .

RE: It is important for me to emphasize my coding method was the fastest I could patch everything together to confirm my thoughts of Volume I/II's trading ability and worth. I do not have enough time in my life to spare in order to code everything "correctly" the first time. Typically I begin projects in phases. Example: Phase 1. Cover all the functional bases, Phase 2. Clean up the code, 3. Add beauty to the external visual side of the EA. Currently I am still working at Phase 1. There is simply much more to this EA than a typical send order, close order EA. Much time and thought has been put to the test. The test will be passed upon evolution of volume I. I am confident of your recognition to it's uniqueness.

With that said, I am considering a different option for "getting the ball rolling" for the first OrderSend() function. I am not sure witch direction I am going to go yet. Ultimately I will completely replace the condition "if(OrdersHistoryTotal()==0){" with a reliable condition. You made an important point to give this some thought. I appreciate your encouragement.

Thank you.

 
RaptorUK:

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

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

 

equals sign, should make the varilble worth something, but what is it?   I think i know what you mean, how is it possible, ++ is a good question
 
WhooDoo22:
Simon,


Another point . . .

RE: It is important for me to emphasize my coding method was the fastest I could patch everything together to confirm my thoughts of Volume I/II's trading ability and worth. I do not have enough time in my life to spare in order to code everything "correctly" the first time.

You must, at least, make it work functionally correctly . . .  this code is a long, long way away from that.   I said must  . . . .  that is incorrect,  you have a choice,  you can continue to write your code and have GBs of errors when you run the ST and have code that will not function on Live or Demo . . .  if you wish.
 

Simon,

You must, at least,..

RE: I do not concern myself with how long it will take to reach a goal, I simply keep plowing forward until the project is complete. My choice would be to not have GBs of errors :) I would rather listen to constructive criticism from my coding peers and respond and reciprocate solutions for the coding issues presented. These solutions could potentially produce less errors for Volume I/II.

Thank you.

 
WhooDoo22:

Simon,

You must, at least,..

RE: I do not concern myself with how long it will take to reach a goal, I simply keep plowing forward until the project is complete. My choice would be to not have GBs of errors :) I would rather listen to constructive criticism from my coding peers and respond and reciprocate solutions for the coding issues presented. These solutions could potentially produce less errors for Volume I/II.

Thank you.



What RaptorUK gave there, was and still is constructive criticism and reciprocate solutions to your codes
 

Simon, I'll use a Boolean variable to solve this problem. This Boolean condition is a common solution which will solve this problem until I reach phase 2. I can then give the first order send signal a unique condition reflecting my coding style. Thank you for your input.

 
WhooDoo22:

Simon, I'll use a Boolean variable to solve this problem. This Boolean condition is a common solution which will solve this problem until I reach phase 2. I can then give the first order send signal a unique condition reflecting my coding style. Thank you for your input.

Nope,  it won't . . .  your coding shows you don't understand,  if you don't understand you can't fix it.
 

Simon, I believe I do understand, what is it you believe I don't understand?

So far we have discussed two important things:

1. fix emergency sl code blocks.

2. remove current condition, "if (OrdersHistoryTotal()==0{" and replace condition with different condition (my current solution is to replace current condition with a Boolean condition to begin ordersends.).

//example

if(x==false){OrderSend()...; x=true;}

/* now, x is true and the code block will not execute again. Of course, I would add code to save variables and if connection 
   is lost from the terminal server, all variables are saved. Simple.
   I understand the code is incorrect, but I wrote this for you to understand its concept, not a completely typed up code. */

 This idea to save variables is a common solution for server disconnection and was suggested by ubzen. I give credit to him for this idea.

Thank you.

 
WhooDoo22:

Simon, I believe I do understand, what is it you believe I don't understand?

The first line in your start() function s this . . .

   OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);

  . . .  what ticket number is it selecting ?  well ticket has been declared without an initial variable setting so it will be 0 ,  so you immediately are trying to select ticket 0 ,  this will generate an error,  if you checked the return value from this OrderSend() you would see that,  it would probably be error 4108   ERR_INVALID_TICKET  . . .   if you understood how to use OrderSend() correctly why would you do this ?

 
If you understood OrderHistoryTotal() you wouldn't have used it in they way you did and you wouldn't have said that it is . . .  " searching trade history of the unique ticket variable only,"

If you understood how {  }  braces worked you wouldn't have added unneeded braces . . .  they add nothing,  they don't make your code neater or easier to read.

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

 can be replaced with . . .

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

 

Using the variable i  as a ticket number shows you don't understand how ticket numbers work outside of the Strategy Tester,  i.e. in a Demo or Live account . . . 


You don't check if your trade functions have worked or failed,  in your code this is critical because you use the following . . .

ticket = OrderSend(Symbol(),OP_BUY,0.05,Ask,30,0,0,"",0,0,Blue);

  . . .  if the OrderSend() fails  ticket   will = -1  then later in your code when you try to use this variable to select and order by ticket number  -1  it will obviously fail . . .