Parameters of IsTradeAllowed() - page 2

 
Gooly, thanks a lot. I will try your code.
 

Nungen,

try this - I think IsTradeAllowed("symbol", Time) is broker-time dependent - and not whether the market is open or not, whether you get ticks or not!

string dax1,dax2;
void OnTick() {
  	if ( StringFind(dax1,"TRUE   @")<0 && IsTradeAllowed(".DE30Cash",TimeCurrent()) ) 
  		dax1 = "\n.DE30Cash      changes to TRUE   @ GMT: "+TimeToStr(TimeGMT(),TIME_DATE|TIME_SECONDS)+"  TmeC: "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
  	else if ( StringFind(dax1,"FALSE  @")<0 && !IsTradeAllowed(".DE30Cash",TimeCurrent()) ) 
  		dax1 = "\n.DE30Cash      changes to FALSE  @ GMT: "+TimeToStr(TimeGMT(),TIME_DATE|TIME_SECONDS)+"  TmeC: "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);

  	if ( StringFind(dax2,"TRUE   @")<0 && IsTradeAllowed(".DE30CashXE",TimeCurrent()) ) 
  		dax2 = "\n.DE30CashXE   changes to TRUE   @ GMT: "+TimeToStr(TimeGMT(),TIME_DATE|TIME_SECONDS)+"  TmeC: "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
   else if ( StringFind(dax2,"FALSE  @")<0 && !IsTradeAllowed(".DE30CashXE",TimeCurrent())) 
  		dax2 = "\n.DE30CashXE   changes to FALSE  @ GMT: "+TimeToStr(TimeGMT(),TIME_DATE|TIME_SECONDS)+"  TmeC: "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
  		
   Comment("GMT: ",TimeToStr(TimeGMT(),TIME_DATE|TIME_SECONDS),"  TmeC: ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n",
      "Just empty      isTrdAllowd:  ",IsTradeAllowed(),"\n",
   	Symbol(),"        isTrdAllowd:   ",IsTradeAllowed(Symbol(),TimeCurrent()),"  normal Forex\n",
   	".DE30Cash     isTrdAllowd:   ",IsTradeAllowed(".DE30Cash",TimeCurrent()),"  DAX\n",
   	".DE30CashXE  isTrdAllowd:   ",IsTradeAllowed(".DE30CashXE",TimeCurrent()),
   	" DAX Xetra Trading Hours (9:00.17:30 Ffm == 7:00-15:30 GMT now!)",
   	dax1,dax2
   );
   
}
 
Carl Schreiber:

Nungen,

try this - I think IsTradeAllowed("symbol", Time) is broker-time dependent - and not whether the market is open or not, whether you get ticks or not!

Could you clarify what you mean by: "broker-time dependent"? Please see the code below (I have activated auto trading):

void OnStart()
{
   Alert(IsTradeAllowed()); //alert 1
   Alert(IsTradeAllowed(NULL, TimeGMT())); //alert 2
   Alert(IsTradeAllowed(Symbol(), TimeGMT())); //alert 3
   Alert(IsTradeAllowed("GBPUSD", TimeGMT())); //alert 4
}

This returns:

true //for alert 1
true //for alert 2
false //for alert 3
false //for alert 4

I have tried running the code and multiple times of the day and the week on weekdays.  I have also tried putting the code in a script and an EA.  Every time I get the same result.  Is there an explanation for this? As alert 2 returns: true, then I would expect alert 3 and alert 4 to return true.  Thanks.

Reason: