WHY - EA work in strategy tester but not real trading

 
I have an EA which works perfectly in the strategy tester but when i try to attach it to a chart and the happy smiley face is on, the robot does not make a single trade. Can anybody tell me why or how or maybe have a look at my code and see the problem?
Files:
STEA_1_MAP.mq4  32 kb
 
int GetSignal(int &major)
{
  major = -1;
  double st11 = iCustom(NULL, 0, ST, MajorPeriod, MajorFactor, 0, 1);
  double st21 = iCustom(NULL, 0, ST, MajorPeriod, MajorFactor, 1, 1);
  double st12 = iCustom(NULL, 0, ST, MajorPeriod, MajorFactor, 0, 2);
  double st22 = iCustom(NULL, 0, ST, MajorPeriod, MajorFactor, 1, 2);
  double ma = iMA(NULL, 0, MaPeriod, 0, MaMethod, MaApplied, 1);
  double mapr = iCustom(NULL, 0, map, MaPeriod, MaMethod, MaApplied, 0, 1);
  if (st11!=EMPTY_VALUE) major = OP_BUY;
  if (st21!=EMPTY_VALUE) major = OP_SELL;
  st11 = iCustom(NULL, 0, ST, MinorPeriod, MinorFactor, 0, 1);
  st21 = iCustom(NULL, 0, ST, MinorPeriod, MinorFactor, 1, 1);
  st12 = iCustom(NULL, 0, ST, MinorPeriod, MinorFactor, 0, 2);
  st22 = iCustom(NULL, 0, ST, MinorPeriod, MinorFactor, 1, 2);
  if (major==OP_BUY && st11!=EMPTY_VALUE && st12!=EMPTY_VALUE && st22!=EMPTY_VALUE && Close[1]<ma  && mapr>=MaTriggerPercent) return (OP_SELL);
  if (major==OP_SELL && st21!=EMPTY_VALUE && st22!=EMPTY_VALUE && st12!=EMPTY_VALUE && Close[1]>ma && mapr>=MaTriggerPercent) return (OP_BUY);
  return (-1);
}


Your EA requires "ST.ex4" and "MaPercent.ex4". Able to also attach these indicators so that helpers can test?

The EA will only fire a trade if the rule conditions in GetSignal method are satisfied.

 
Zee Zhou Ma:


Your EA requires "ST.ex4" and "MaPercent.ex4". Able to also attach these indicators so that helpers can test?

The EA will only fire a trade if the rule conditions in GetSignal method are satisfied.

Thank you for your response! I have already installed the necessary indictors. If i hadd'nt, the EA would not work in the strategt tester either. And thats why i dont know why it does not work. i have attached the indicators here if you wanted to have a look.
Files:
MaPercent.mq4  8 kb
ST.mq4  9 kb
 

What are the EA settings you are testing on? Please supply.

You can also run the Strategy Tester on a narrower time period by configuring the Use Date From and To with To as today.

 
Zee Zhou Ma:

What are the EA settings you are testing on? Please supply.

You can also run the Strategy Tester on a narrower time period by configuring the Use Date From and To with To as today.For

Just to test if the EA works, i use this settins. This will make the most trades and almost trade 24/4.
I really apreciate that you try to help me

Files:
most_trades.PNG  94 kb
 

You can save the EA settings using the save button.


And by the way, I am not sure if you want to use this EA as it hits my free margin alert on back testing even though it is a $10,000 account.

Seems to fire lots of trades and might have high drawdown.

What is your leverage used?

 
Zee Zhou Ma:

You can save the EA settings using the save button.


And by the way, I am not sure if you want to use this EA as it hits my free margin alert on back testing even though it is a $10,000 account.

Seems to fire lots of trades..

This setting is also just for testing if the EA trades. I have some other settings for the EA when im doing real trading. But when i attach it on chart it does not trade, which is the base problem. if you have a demo account, does it work for you if you attach it?
 
Sorry may i know what is your account leverage? There is a free margin alert on my account as i use a lower leverage.
 
Zee Zhou Ma:
Sorry may i know what is your account leverage? There is a free margin alert on my account as i use a lower leverage.
My account is 1:500 leverage
 

Okay no problem using backtester on 1:500. 

What time frame are you testing on?

void OnTick()
{
  //------------------------------------------------------------------
  if (!IsConnected() || AccountNumber() == 0 || Bars <= 30 || ArraySize(Time) == 0) return;
  //------------------------------------------------------------------
  if (lastCandle != Time[0])
  {
    lastCandle = Time[0];
    Signal = GetSignal(MajorTrend);
  }
  //------------------------------------------------------------------
  if (MajorTrend==OP_SELL && IsAnyOrderActive(OP_SELL)!=-1) CloseAllOrders(OP_SELL);
  if (MajorTrend==OP_BUY && IsAnyOrderActive(OP_BUY)!=-1) CloseAllOrders(OP_BUY);
  if (Signal!=-1 && CheckTime() && DoesSignalCatched(Signal, Time[0])==-1 && (MaxTrades==0 || GetOrderCount(-1)<MaxTrades)) SetOrder(Signal);
  else Signal = -1;
  //------------------------------------------------------------------
  ManageOrders();
  //------------------------------------------------------------------
}

If you see the code, it requires 30 bars to be available before it trades. So if it is D1, it requires 30 days

You can put debugging statements there at the check statements to see what is wrong with your account environment.

 
Zee Zhou Ma:

Okay no problem using backtester on 1:500. 

What time frame are you testing on?

If you see the code, it requires 30 bars to be available before it trades. So if it is D1, it requires 30 days

You can put debugging statements there at the check statements to see what is wrong with your account environment.

Okay thank you very much i will try that. But what if i use it on 1 minute? Then it should work after 30min right?
Reason: