Var assignment inside if statement

 

Please tell me if I leave the return operator with zero "Return(0)"

Will it save the value of StopLevelThisPair() function inside BrokerStopLevel variable which is a global variable?

int start()
  {
   Comment("The Current StopLevel is: ",StopLevelThisPair());
   if(OpenOrdersThisPair(Symbol())>=1) // If there are more then or equal to 1 open trades on current chart do the following: 
    {
       if(UseMoveToBreakeven)MoveToBreakeven(); // If BreakEven is enabled,use it.
       if(UseTrailingStop)AdjustTrail(); //If TSL enabled, use it.
    }
   if(IsNewCandle())  
       {
         BrokerStopLevel = StopLevelThisPair();
         CheckForMaTrade();
       }
   
   return(0);
  }


Or Do I need to specify the return like this?

int start()
  {
   Comment("The Current StopLevel is: ",StopLevelThisPair());
   if(OpenOrdersThisPair(Symbol())>=1) // If there are more then or equal to 1 open trades on current chart do the following: 
    {
       if(UseMoveToBreakeven)MoveToBreakeven(); // If BreakEven is enabled,use it.
       if(UseTrailingStop)AdjustTrail(); //If TSL enabled, use it.
    }
   if(IsNewCandle())  
       {
         BrokerStopLevel = StopLevelThisPair();
         CheckForMaTrade();
         return(BrokerStopLevel);
       }  
  }
 
t0mbfunk:

Please tell me if I leave the return operator with zero "Return(0)"

Will it save the value of StopLevelThisPair() function inside BrokerStopLevel variable which is a global variable?

return  returns the value to the code where the function was called,  you don't call start()  so the return is not important other than terminating start() early.

"A return operator terminates the current function execution and returns the control to the calling program." 

if you use a globally declared variable it is "visible" from every function in your code. 

 
t0mbfunk:
Please give me a hint on what I did wrong.

I'm not going to debug and test your EA,  you need to learn how to do that efficiently,  there are ways to make your life easier though . . .  are your OrderSend() calls executed ?  or do they fail ?  why aren't you checking the return value from the OrderSend() ?

 

Read this:   What are Function return values ? How do I use them ?

Read some of the links here:  ECN   and perform this test and report back here:  https://www.mql5.com/en/forum/143043/page2#746319  #ecntest 

Also,  using Bars is unreliable when checking for a New Bar, use Time[]  instead . . . 

 
it didnt place any pending orders
 
t0mbfunk:
it didnt place any pending orders

Why ?

RaptorUK:

  are your OrderSend() calls executed ?  or do they fail ?  

Reason: