View Single Post
  #1 (permalink)  
Old 06-13-2006, 08:29 PM
Aaragorn's Avatar
Aaragorn Aaragorn is offline
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
How do I make my EA execute?

this compiles with no errors but it isn't executing any trades when it's conditions are met. I think i did the MACD's ok but I'm not certain. I just want them to be showing positive or negative and I 'think' that means the signal line is above the indicator line for positive? but i'm not sure that it's not the indicator line above the signal line for positive? I'm not used to calling them signal and indicator i just know what they look like on the chart so if i'm not confused on that point then the logic is ok.

but beyond that this is not showing any results in the tester, it's just not executing despite having passed the compiler and giving the smiley face on the corner of the chart when attached...

can someone see what's wrong with this? why it's not executing any orders?

the other thing i would like to add to it is something to make it only be in one position at a time and not open any others until the previous one is close or simultaneously when it reverses.
//+------------------------------------------------------------------+
//| This MQL is generated by Expert Advisor Builder |
//| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ |
//| |
//| In no event will author be liable for any damages whatsoever. |
//| Use at your own risk. |
//| |
//| Please do not remove this header. |
//+------------------------------------------------------------------+
#property copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = False;
extern double Lots = 1.0;
extern int Slippage = 0;
extern bool StopLossMode = True;
extern int StopLoss = 8;
extern bool TakeProfitMode = True;
extern int TakeProfit = 15;
extern bool TrailingStopMode = True;
extern int TrailingStop = 8;

#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;

if (EachTickMode) Current = 0; else Current = 1;

return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;



if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;

//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+

double Buy1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0);
double Buy1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0);
double Buy2_1 = iClose("EURUSD", PERIOD_M1, Current + 0);
double Buy2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0);
double Sell1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0);
double Sell2_1 = iClose("EURUSD", PERIOD_M1, Current + 0);
double Sell2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseBuy1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0);
double CloseBuy1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0);
double CloseBuy2_1 = iClose("EURUSD", PERIOD_M1, Current + 0);
double CloseBuy2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseSell1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0);
double CloseSell1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0);
double CloseSell2_1 = iClose("EURUSD", PERIOD_M1, Current + 0);
double CloseSell2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+

//Check position
bool IsTrade = False;

for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Close

//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+

if (CloseBuy1_1 < CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) Order = SIGNAL_CLOSEBUY;

continued on next post....
Reply With Quote