two ma cross condition. thanks - page 2

 
phade #:
I'm not sure "15" will be understood as the 15 minute timeframe, you should use "PERIOD_M15" constant
I think it can, as my code works when i only have one if condition. But let me try that. Thank you.
 
chukwudi joshua obiekwe #:
for (int i= OrdersTotal(); i>=0; i--)
            {
               if (OrderSelect(i = 0, SELECT_BY_POS)== true)
               
  1. That is nonsense. You start a loop, then assign zero to i to select the oldest position, the loop exits after that.
              Expert Placing one pair stoploss on other pair. - MQL4 programming forum - Page 2 #17 (2020)


  2. You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool).

 
William Roeder #:
  1. That is nonsense. You start a loop, then assign zero to i to select the oldest position, the loop exits after that.
              Expert Placing one pair stoploss on other pair. - MQL4 programming forum - Page 2 #17 (2020)


  2. You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool).



I already noted it to him , that he need to loop through his orders very well cause its not properly defined or structured..

But good job on those mathematical explanation..
 
William Roeder #:
  1. That is nonsense. You start a loop, then assign zero to i to select the oldest position, the loop exits after that.
              Expert Placing one pair stoploss on other pair. - MQL4 programming forum - Page 2 #17 (2020)


  2. You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool).

Thank you. Im new in creating ea. Thank you for helping me. Base on my understanding woth what you said. I should remove 0 the value of i in the if stament with the 0rderselect function . Thanks. Really appreciate it. Im not sure if i underdtand it correctly. But thanks you very much. Really appreciate it. Thanks
 
chukwudi joshua obiekwe #:


I already noted it to him , that he need to loop through his orders very well cause its not properly defined or structured..

But good job on those mathematical explanation..
Thank you sir. For helping me out. 
 
I have shifts of 0 and 1 for each ma. Im not sure really about ontick and how it works and event thing.  Should i use just ontick for two events happening.  Thank you for understanding. To tell you honestly, there are some explanation that i dont really understand but I appreaciate everyone here and thank you for helping me out.
 
Progmt4 #:
I have shifts of 0 and 1 for each ma. Im not sure really about ontick and how it works and event thing.  Should i use just ontick for two events happening.  Thank you for understanding. To tell you honestly, there are some explanation that i dont really understand but I appreaciate everyone here and thank you for helping me out.
An event is a change in price … every time there is an event, OnTick() function will run once. So all the code you want to run at a price change, you should put it inside OnTick(). If within one minute there is 1000 times price changes, OnTick() function will run 1000 times .
 
Progmt4 #:
I have shifts of 0 and 1 for each ma. Im not sure really about ontick and how it works and event thing.  Should i use just ontick for two events happening.  Thank you for understanding. To tell you honestly, there are some explanation that i dont really understand but I appreaciate everyone here and thank you for helping me out.
You should not use shift 0 and 1… use 1 and 2… if use 0 and 1 you can have several signals as price fluctuates and before candle finishes, crossing might not take place … if use 1 and 2 it is sure if crossing is there or not. Also, if use one and 2 you need to run the code only once per bar. 
 
Daniel Cioca #:
An event is a change in price … every time there is an event, OnTick() function will run once. So all the code you want to run at a price change, you should put it inside OnTick(). If within one minute there is 1000 times price changes, OnTick() function will run 1000 times .
Thank you very much. Can ontick wait for the second event to happen? Or after first then check second event if it is not true then it will go back to the top of the code again. 

Just like if bldg 3 > bldg 2 proceed to the next, then  if new bldg 3.2 > new building 3.1 then close. If second condition does not meet. Will it go back to the top of the ontick code or wait for the code to be true?. Is ontick what I need or I should not be doing it on tick as the conditions are not compatible with ontick function. 

I'm also thinking if I can use a while to wait for the second condition to happen. I'm really not sure of what I am doing. Can u please help me. Thanks. 
 
Progmt4 #:
Thank you very much. Can ontick wait for the second event to happen? Or after first then check second event if it is not true then it will go back to the top of the code again. 

Just like if bldg 3 > bldg 2 proceed to the next, then  if new bldg 3.2 > new building 3.1 then close. If second condition does not meet. Will it go back to the top of the ontick code or wait for the code to be true?. Is ontick what I need or I should not be doing it on tick as the conditions are not compatible with ontick function. 

I'm also thinking if I can use a while to wait for the second condition to happen. I'm really not sure of what I am doing. Can u please help me. Thanks. 
As I said…. At every tick(event) , everything you put in Ontick() function, will run once … it will not wait for anything … all the code you put between those brackets , will run 
Reason: