trading - How to access the second if statement -


i totally drain out second if statement couldn't executed.

my original idea when volatility in range of 90 - 110, program send one , one order. , wait , see till volatility reaches in range of 111 - 150, , send the second order.

if don't use bool function here, program send countless order when range reached.

could please me?

  if (  todaymaxvolatilitypercentage >= 90.0      && ( daytrend  == 1 )      && orderopened == false         )   {         print( "entered if clause" );      // print( "today volatility percentage is: ", todaymaxvolatilitypercentage + "%" );      // ticket: returns number of ticket assigned order trade server or -1 if fails.         ticket = ordersend( symbol(),                             op_sell,                             0.3,                             bid,                             3,                              0 * mypoint,                             30 * mypoint,                             null,                             magicnumber,                             0,                             blue                             );         print( "order opened on", orderopentime()+" @ price: ", orderopenprice() );         print( "trend number ",daytrend );          if (  ticket > 0 )         {               if (  takeprofit > 0 ) thetakeprofit = bid - takeprofit * mypoint;               orderselect( ticket, select_by_ticket ); // bool value            /* ordermodify( orderticket(),                            orderopenprice(),                            0,                            normalizedouble( thetakeprofit, digits  ),                            0,                            green                            );                          */         }         orderopened = true;         if (  todaymaxvolatilitypercentage >= 110.0 ) orderopened = false;                 }   if (  todaymaxvolatilitypercentage >= 110.0      && ( daytrend  == 1 )      && orderopened == false         )   {         print( "entered second if clause" );      // ticket: returns number of ticket assigned order trade server or -1 if fails.         ticket = ordersend(  symbol(),                              op_sell,                              0.3,                              bid,                              3,                               0 * mypoint,                              30 * mypoint,                              null,                              magicnumber,                              0,                              blue                              );         if (  ticket > 0 )         {               if (  takeprofit > 0 ) thetakeprofit = bid - takeprofit * mypoint;               orderselect( ticket, select_by_ticket ); // bool value            /* ordermodify( orderticket(),                            orderopenprice(),                            0,                            normalizedouble( thetakeprofit, digits ),                            0,                            green                            );                        */         }         orderopened = true;      } 

a hidden show-stopper:

by design, first successfull ordersend() returns value assign ticket = ordersend(...).

the devil hidden in detail.

[mql4-help] says:

returns number of ticket assigned order trade server or -1 if fails.

so first successfull ordersend() ticket# returned 0 ( in strategytester, real mt4/server rather runs high numbers drawn it's db.pool of tickets ).

thus second if ( ticket > 0 ) never let in.

it common rather use if ( ticket > empty ) deconfuse intention , use symbolic instead of -1 integer constant


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -