Strategy Tester Visual Mode Problem

 
When I run the following code within an EA on the MT4 Strategy Tester, it works OK. But, if I use Visual Mode, Error 4059 on ordersend attempts. 4059 is "Function is not allowed in testing mode".

Why does this code run OK in normal Strategy Test, but not in visual mode.

Buy code:
if(Ask-Low72<StopLoss*Point)sl=Low72; else sl=Ask-StopLoss*Point;
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,sl,Ask+TakeProfit*Point,"BUYSignal",MagicNumber,0,GreenYellow);
Thanks,
Wackena
 
I don't see GetLastError function illustrating your problem
 
stringo, sorry, I'm novice programmer and I don't understand your response above. I can send the EA to you, if you think this can help me get this problem resolved.

Wackena
 

How do You know about error 4059. Did you analyze log?

 
I saw the error in the tester journal. Then checked definition of error 4059 at docs.mql4.com. As the log is the journal, the error 4059 is recorded in this log.

Tester Log excerpt: (These tests were from 2007.03.19, but the log has 2007.01. 02. The Tester Log file name is correct 20070319.)

10:12:41 Bogie-Breakout-v1.0 inputs: Risk=5; Lots=0.1; Gap=2; TakeProfit=20; StopLoss=50; ExitStop=3; GapExitStop=15; TrailingStop=15; MinMarginLevel=250;
10:13:26 2007.01.02 05:00 Bogie-Breakout-v1.0 GBPUSD,M5: Error opening BUY order : 4059
10:17:55 Bogie-Breakout-v1.0 GBPUSD,M5: loaded successfully
10:17:55 Bogie-Breakout-v1.0 inputs: Risk=5; Lots=0.1; Gap=2; TakeProfit=20; StopLoss=50; ExitStop=3; GapExitStop=15; TrailingStop=15; MinMarginLevel=250;
10:18:14 2007.01.02 05:00 Bogie-Breakout-v1.0 GBPUSD,M5: Error opening BUY order : 4059
10:20:22 Bogie-Breakout-v1.0 GBPUSD,M5: loaded successfully
10:20:22 Bogie-Breakout-v1.0 inputs: Risk=5; Lots=0.1; Gap=2; TakeProfit=20; StopLoss=50; ExitStop=3; GapExitStop=15; TrailingStop=15; MinMarginLevel=250;
10:20:22 2007.01.02 05:00 Bogie-Breakout-v1.0 GBPUSD,M5: Error opening BUY order : 4059

I don't see any notation if test is standard or in visual mode. Again this error happens in Visual mode.
Wackena
 
"Error opening BUY order : 4059" output by Print function. Show part of source code with this Print.
 
Here is Buy and Sell code.
Wackena

if(MyOrdersTotal()==0 && AccountEquity()/(AccountMargin()+0.0001)>(MinMarginLevel/100)) 
      {
      if(Buy1==1 && ret1!=1) 
         {
         ret=0;
         ret1=1;
         if(Ask-_Low<StopLoss*Point)sl=_Low; else sl=Ask-StopLoss*Point;
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,sl,Ask+TakeProfit*Point,"BUYSignal",MagicNumber,0,GreenYellow);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
            }
            else Print("Error opening BUY order : ",GetLastError()); 
            return(0);
         }
 
      if(Sell1==1 && ret1!=2)
         {
         ret=0;
         ret1=2;
         if(_High-Bid<StopLoss*Point)sl=_High; else sl=Bid+StopLoss*Point;
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,sl,Bid-TakeProfit*Point,"SELLSignal",MagicNumber,0,Red);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
            }
            else Print("Error opening SELL order : ",GetLastError()); 
            return(0);
         }
      }
 
Try this modification
if(MyOrdersTotal()==0 && AccountEquity()/(AccountMargin()+0.0001)>(MinMarginLevel/100)) 
      {
      Print("My realy last error code=",GetLastError());
      if(Buy1==1 && ret1!=1) 
         {
         ret=0;
         ret1=1;
         if(Ask-_Low<StopLoss*Point)sl=_Low; else sl=Ask-StopLoss*Point;
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,sl,Ask+TakeProfit*Point,"BUYSignal",MagicNumber,0,GreenYellow);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
            }
            else Print("Error opening BUY order : ",GetLastError()); 
            return(0);
         }
 
      if(Sell1==1 && ret1!=2)
         {
         ret=0;
         ret1=2;
         if(_High-Bid<StopLoss*Point)sl=_High; else sl=Bid+StopLoss*Point;
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,sl,Bid-TakeProfit*Point,"SELLSignal",MagicNumber,0,Red);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
            }
            else Print("Error opening SELL order : ",GetLastError()); 
            return(0);
         }
      }
and ask , please.