Hi, I'm a new expert advisor programmer and I have issue with my new expert advisor!
I used SUFX Expert Advisor Builder to build this basic Expert and the only thing that I whant him to do is to open a position when my custom Indicator draw an arrow. A long position when I get an upTrend Arrow and a short position when I get a downTrend Arrow!

Thank you for your help!
Gabriel

Ind&Expert.zip

My indicator (In search of solution I've added a third Buffer in my indicator : TrendSignal):
/////////////////////
//Indicator property
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Blue

double Uptrend[];
double Downtrend[];
double TrendSignal[];
//--------------

//Arrows indicators init
int init()
{ SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 236);
SetIndexBuffer(0, Uptrend);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 238);
SetIndexBuffer(1, Downtrend);
SetIndexStyle(2, DRAW_NONE, EMPTY, EMPTY);
SetIndexBuffer(2, TrendSignal);

return(0);}
//--------------

//Indicators functions
int start()
{ int Limit, I, Counter;
double SlowerEMAprevious, SlowerEMAcurrent;
double FasterEMAprevious, FasterEMAcurrent;
double IntegerMACDbase, IntegerMACDsignal;
double IntegerMACDprevious, IntegerMACDfuture;
double IntegerLGprevious, IntegerLGcurrent, IntegerLGfuture;
double IntegerLGvar1, IntegerLGvar2, IntegerMACDvar1;
double Range, AvgRange;
int Counted_Bars = IndicatorCounted();
//--------------

//Error Check
if(Counted_Bars < 0) return (-1);
if(Counted_Bars > 0) Counted_Bars--;
Limit=Bars-Counted_Bars;
//--------------

//Active state loop
for(I = 0; I <= Limit; I++)
{ Counter = I;
Range = 0;
AvgRange = 0;
for (Counter=I; Counter <= I+9; Counter++)
{ AvgRange = AvgRange + MathAbs(High[Counter] - Low[Counter]);}
Range = AvgRange/10;
//////
SlowerEMAprevious = iCustom(NULL, 0, "MAVCUSTOM", 8, 0, MODE_EMA, PRICE_CLOSE, I+2);
SlowerEMAcurrent = iCustom(NULL, 0, "MAVCUSTOM", 8, 0, MODE_EMA, PRICE_CLOSE, I );
FasterEMAprevious = iCustom(NULL, 0, "MAVCUSTOM", 4, 0, MODE_EMA, PRICE_CLOSE, I+2);
FasterEMAcurrent = iCustom(NULL, 0, "MAVCUSTOM", 4, 0, MODE_EMA, PRICE_CLOSE, I );
///
IntegerMACDprevious = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_BASE, I+2);
IntegerMACDbase = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_BASE, I );
IntegerMACDsignal = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_SIGNAL, I );
IntegerMACDfuture = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_BASE, I-2);
IntegerMACDvar1 = 0;
///
IntegerLGprevious = iCustom(NULL, 0, "LaGuerreCUSTOM", 0.66, 950, 0, I+2);
IntegerLGcurrent = iCustom(NULL, 0, "LaGuerreCUSTOM", 0.66, 950, 0, I );
IntegerLGfuture = iCustom(NULL, 0, "LaGuerreCUSTOM", 0.66, 950, 0, I-2);
IntegerLGvar1 = 0.20;
IntegerLGvar2 = 0.80;
//////
if ((IntegerLGprevious < IntegerLGcurrent) && (IntegerLGcurrent > IntegerLGvar1) &&
(IntegerLGprevious < IntegerLGvar1) && (IntegerLGfuture > IntegerLGcurrent) &&
(IntegerMACDbase > IntegerMACDsignal) && (IntegerMACDfuture > IntegerMACDbase) )
{Uptrend[I] = Low[I] - Range*0.5;
TrendSignal[I] = 1.00;}
else if
((IntegerLGprevious > IntegerLGcurrent) && (IntegerLGcurrent < IntegerLGvar2) &&
(IntegerLGprevious > IntegerLGvar2) && (IntegerLGfuture < IntegerLGcurrent) &&
(IntegerMACDbase < IntegerMACDsignal) && (IntegerMACDfuture < IntegerMACDbase) )
{Downtrend[I] = High[I] + Range*0.5;
TrendSignal[I] = 2.00;}}
return(0);}
//--------------

My Expert :
///////////////////////
#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 0.01;
extern int Slippage = 0;
extern bool UseStopLoss = True;
extern int StopLoss = 5000;
extern bool UseTakeProfit = False;
extern int TakeProfit = 0;
extern bool UseTrailingStop = True;
extern int TrailingStop = 100;

int BarCount;
int Current;
bool TickCheck = False;

//Expert Initialisation
int init() {
BarCount = Bars;

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

return(0);}

//Expert Functions
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;

//Indicator Variable
double OrderSignal = iCustom(NULL, 0, "TrendFollowCUSTOM", 2, 0);

//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 BUY
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}

//BUY Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {

//Close SELL
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//SELL Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}

//Market Entry Signal
if (OrderSignal == 1.00) Order = SIGNAL_BUY;
if (OrderSignal == 2.00) Order = SIGNAL_SELL;

//Buy Function
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

//Sell Function
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

if (!EachTickMode) BarCount = Bars;

return(0);
}