EA tries to open orders over the weekend?

 

I am trying to use

if(IsStopped()){ sStat=" *STOPPED*"; Print("EA Stopped"); EAComment(); return; } //- STOPPED

if live trading is stopped ..

I am trying to use

if(!IsConnected()){ sStat=" *NO-TICKS*"; Print("Terminal not connected."); EAComment(); return; } //- NO TICKS

if the EA is not connected to the broker ...

and on top of that(on a side note)

I am trying to stop EA if there is not enough bars

if(Bars<MA_Period){ sStat=" *NO-BARS*"; Print("Not enough bars for calculation. Bars: " + IntegerToString(Bars)); EAComment(); return; } //- NO BARS

if I go to weekly chart it says bars is 118.. then how can moving average 200 period even be displayed?

This last one doesn't seem to work appropriately ...


Anyway I get an error from the EA trying to open orders

if(ticket<=0){Print("OrderSend Error: ",strError(GetLastError()));}

 

case 4109: return("Trade Is Not Allowed In The Expert Properties");

Well this doesn't make sense either, because it's the weekend, terminal is connected ...

And I have been reading the CheckUp and getting no where is basically why I seek help

Checkup - MQL4 Reference
Checkup - MQL4 Reference
  • docs.mql4.com
Checkup - MQL4 Reference
 
Brian Lillard:

case 4109: return("Trade Is Not Allowed In The Expert Properties");

if (!IsTradeAllowed()) {
      Alert("Please Enable Auto Trading to run this EA");
      ExpertRemove();
   }
 
Mohamad Zulhairi Baba:

Still getting order send errors though and now get OrderSend Error: 131: Invalid Trade Volume


case 131: return("131: Invalid Trade Volume");

I guess my question is can the OnTick module return before trading if not possible to send an order? like over the weekend?

Just remember to disabled auto trading over the weekends?

It's trying to send a 0.15 lot btw

 

Ok I think it's working

if( !IsTradeAllowed(Symbol(),Time[0]) ) return;

The time it gives is 2018.06.08 00:00:00 after Friday is over. This time is the beginning of Friday?

And it didn't work like this

if( !IsTradeAllowed() ) return;

It just doesn't seem to be the right usage for prohibiting trading over the weekend

 

Now I've got OnTick like this

 if(!IsConnected() || !IsTradeAllowed(strSymbol,Time[0])){ sStat=" *NO-TICKS*"; EAComment(); return; } //- NO TICKS/STOPPED
 if(Bars<MA_Period){ sStat=" *NO-BARS*"; EAComment(); return; } //- NO BARS

And it doesn't allow trades over the weekend ..

But about Bars? On Weekly chart theres only 118 bars and it'd not enough to make a 200 period moving average calculation.

So theres bars in chart set to 65000 and then bars in history set to 512000 ...

Bars reads 118 and yet moving average displays

 

Well Brian what can we say ?

Bars

Number of bars in the current chart.