Variables of global scope (variables defined before Start{} function) and global
variables (variables defined AS globalvariables with GlobalVariableSet() function)
are not the same!
The first one does get reinitialized, the second one does not, the platform keeps the value for I guess 30 days after last use.
The first one does get reinitialized, the second one does not, the platform keeps the value for I guess 30 days after last use.
Zap:
Variables of global scope (variables defined before Start{} function) and global variables (variables defined AS globalvariables with GlobalVariableSet() function) are not the same!
The first one does get reinitialized, the second one does not, the platform keeps the value for I guess 30 days after last use.
Variables of global scope (variables defined before Start{} function) and global variables (variables defined AS globalvariables with GlobalVariableSet() function) are not the same!
The first one does get reinitialized, the second one does not, the platform keeps the value for I guess 30 days after last use.
thanks Zap...I meant of global scope. So I modified my code
if (isSellSignal()) { if (!getPosition())GoShort(Lots); //Print("Currently Out. Sell Signal Received. Going Short."); if (getPosition() && (OrderType()==OP_BUY))CloseOrder(); Print("Currently Long. Sell Signal Received. Position Closed."); }
bool getPosition() { int total=OrdersTotal(); for(int pos=0;pos<total;pos++) if(OrderSelect(pos,SELECT_BY_POS)) { Ticket=OrderTicket(); return(true); } else { return(false);Print("GetPositions returned an error of ",GetLastError()); } }
It seems to be working. And for now I will only ever have one position in any one pair...So I think my logic is sound...
I miss my debugger/unit tests

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
My question is: everytime Start runs does it re-initialize values for global variables?
I am trying to keep track of my current position. But Even though they should have a value the check I am doing is showing them all a 0(false)
Check:
This runs as the first statement in Start{}