help needed

 
double C1=iClose(Symbol(),5,1);
double M1=iMACD(Symbol(),5,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
double P0=iSAR(Symbol(),5,0.02,0.2,0);
double P1=iSAR(Symbol(),5,0.02,0.2,1);
double P2=iSAR(Symbol(),5,0.02,0.2,2);
double B1,B2,B3,B4;
double S1,S2,S3,S4;
double MB1,MB2,MB3,MB4;
double MS1,MS2,MS3,MS4;
int totalO = OrdersTotal();
bool TRADING=false;
if(TRADING==true && GlobalVariableCheck("DONE")==false)
{
//looking for stochastic crosses and setting variables to be able to assess them
if(ST2 < 50 && ST1 > 50)
{
GlobalVariableSet("B1",C1);
GlobalVariableSet("MB1",M1);
}
if(ST2 > 50 && ST1 < 50)
{
GlobalVariableSet("S1",C1);
GlobalVariableSet("MS1",M1);
}

I have this EA written and compiled with no issues but no trades are placed. I understand there may be other issues but could someone please tell me if I am trying to set the global variables incorrectly? Thank you to everyone that helps us novices straighten coding out! :) Daniel
 
The syntax for setting a global variable is correct. My question would rather be, why are you setting these variables global for the whole terminal? Wouldn't it be enough to just set them globally for the EA only? in other words, is there an other EA using these vars? And maybe you even don't want to use the values in other functions... then a static declaration within the function scope would be sufficient.

double gdBla = 1.2345; // available in all functions of EA

int start(){
   GlobalVariableSet("bla",1.2345); // available in all ea's running in metatrader 
   static double ldBla = 1.2345; // available in function scope ( keeps it value after restarting function )
   double ldBlah = 1.2345; // available in function scope ( value reset after restarting function )
}
hth
 

  1. bool TRADING=false;
    if(TRADING==true && GlobalVariableCheck("DONE")==false)
    { // THIS IS NEVER REACHED
    You probably want
    extern bool

  2. if(a_bool==true) is redundant just use
    if(TRADING && !GlobalVariableCheck("DONE")) // Read: if trading and not done.