GlobalVariableSet not working
Try move it to start .. not oninit ...
void CPanelDialog::OnClickBtn1(void) { int type; if(rd1.State()==false && rd2.State()==false){} else { if(rd1.State()==true){ type=OP_BUY; }else if(rd2.State()==true){ type=OP_SELL; } if(OpenOrder(type,StringToDouble(edit2.Text()))) { if(GlobalVariableGet("TradeAllowed")==1) { GlobalVariableSet("TradeAllowed",0); } } } }
GlobalVariableCheck = check if TradeAllowed existed or not without checking its value.
GlobalVariableGet = check if the TradeAllowed value matched or not or whatever value we want is there.
GlobalVariableCheck = check if TradeAllowed existed or not without checking its value.
GlobalVariableGet = check if the TradeAllowed value matched or not or whatever value we want is there.
int OnInit() { //check if GlobalVariable is present if(!GlobalVariableCheck("TradeAllowed"))//check if the GlobalVariable "TradeAllowed" is present. { GlobalVariableSet("TradeAllowed",1);//if not present, create the GlobalVariable "TradeAllowed" with a value of 1. } else { GlobalVariableSet("TradeAllowed",1);//if present, set the GlobalVariable "TradeAllowed" value with 1. } }but the thing is, after the EA has been initialized, the value of the GlobalVariable "TradeAllowed" is always 0, sometimes it will have a value of 1 but after i put the Slave EA it will change its value to 0 to which the Slave EA has no code to change the value of the GlobalVariable "TradeAllowed".
Last try ...
int OnInit() { //check if GlobalVariable is present if(GlobalVariableGet("TradeAllowed")!=1)GlobalVariableSet("TradeAllowed",1); GlobalVariablesFlush(); }
By the way, what you put on deinit() ?
Last try ...
Use Print() after each function to see which one is the culprit.
if(OpenOrder(type,StringToDouble(edit2.Text()))) { if(GlobalVariableCheck("TradeAllowed")) { GlobalVariableSet("TradeAllowed",0); } }
That code snippet must be always true which leads to
GlobalVariableSet("TradeAllowed",0);
Hi guys,
I would like to ask if i had a proper coding when dealing with GlobalVariables.
I have this code so that the other EA's(slave) will not trade not until one EA(master) have made the first move(or the first trade) which has this code.
The problem is that, everytime i load the EA or start the EA, the GlobalVariable "TradeAllowed" always have a value of 0 instead of 1 which i declared above.
Can anyone help me with this problem.
Thanks.