Missing Something?

 

if (isSellSignal())
     {
     
      if (Out==true)Short=GoShort(Lots);
      Print("Currently Out. Sell Signal Received. Going Short.");
            
      if (Long==true) Out=CloseOrder();
       Print("Currently Long. Sell Signal Received. Position Closed.");
     }
     
     if (isBuySignal())
     {
      if (Out==true) Long=GoLong(Lots);
      Print("Currently Out. Buy Signal Received. Going Long.");
      if (Short==true) Out=CloseOrder();
      Print("Currently Short. Buy Signal Received. Position Closed.");
     }  
     
     if (!Out)
     {
      if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)) TrailOrder(OrderType());
     }
I have 3 variables of global scope. Long, Short, Out. These are defined as bool.
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:

Print("NewBar Out= "+Out+" Long= "+Long+" Short ="+Short);
This runs as the first statement in Start{}
 
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.
 
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.


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
Reason: