Heiken Ashi EA

 

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye

Files:
 
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Files:
 
WSAStartup:
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Thanks!! I tested it .....

:-)

 
cmsdeveloping:
WSAStartup:
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Thanks!! I tested it .....

:-)

the tester did:

2008.04.13 23:59:35 2008.03.27 02:46 Tester: not enough money for sell 1.00 EURUSD at 1.5819 sl: 1.5859 tp: 1.5813 [2008.03.27 02:46]


why? :-(

 
cmsdeveloping:
cmsdeveloping:
WSAStartup:
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Thanks!! I tested it .....

:-)

the tester did:

2008.04.13 23:59:35 2008.03.27 02:46 Tester: not enough money for sell 1.00 EURUSD at 1.5819 sl: 1.5859 tp: 1.5813 [2008.03.27 02:46]


why? :-(

  • rder send error 134
 
cmsdeveloping:
cmsdeveloping:
WSAStartup:
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Thanks!! I tested it .....

:-)

the tester did:

2008.04.13 23:59:35 2008.03.27 02:46 Tester: not enough money for sell 1.00 EURUSD at 1.5819 sl: 1.5859 tp: 1.5813 [2008.03.27 02:46]


why? :-(

  • rder send error 134
 
cmsdeveloping:
cmsdeveloping:
cmsdeveloping:
WSAStartup:
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Thanks!! I tested it .....

:-)

the tester did:

2008.04.13 23:59:35 2008.03.27 02:46 Tester: not enough money for sell 1.00 EURUSD at 1.5819 sl: 1.5859 tp: 1.5813 [2008.03.27 02:46]


why? :-(

  • rder send error 134
 

stevesouders wrote: I can't get that EA to work is there something I'm suppossed to do to get it to work??

Please Help,

Steve

cmsdeveloping:
cmsdeveloping:
cmsdeveloping:
WSAStartup:
cmsdeveloping:

Hello, nice day!


Alex here, and i'am newbie with mq4/EA. I want to create "the most simple Ea" with Heiken ashi Smoothed (not only indicator ), but a simple EA that operate the same pair long&short using 1minute time frame (or max 5 min) with this criteria :


...go buy with the first "10seconds convalidate blu candle"

...close buy with the first "10second convalidate red candle"

...go short with the first "10seconds convalidate red candle"

...close short with the first "10second convalidate blu candle"


can someone help me ? Thanks 1000


Regards, ALEX


Ps: i'am attach. the simple indicator that want to used with the criteria above.... bye


OK, the first try. Get the indicator Values:

haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Check For Conditions and Times:


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);

haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);

if((haOpen>=haClose)&&(haOpen2<haClose2))
{
if(nTrend==2)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=2;
}
}

else
{
if(nTrend==1)
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan)
{
if(OrdersTotal()==0)
nTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);

}
}

else
{
CandleTime=TimeCurrent();
nTrend=1;
}
}



At the beginning it has to check our open order:

datetime TimeNow;

if(OrdersTotal()!=0)
{
OrderSelect(nTicket,SELECT_BY_TICKET);
if(OrderMagicNumber()==Magic)
{
if((OrderType()==OP_SELL)&&(nTrend==1))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}

if((OrderType()==OP_BUY)&&(nTrend==2))
{
TimeNow=TimeCurrent();
if((TimeNow-CandleTime)>TimeSpan) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
}
}



The ea is attached. Set TimeSpan to a suitable value.

Thanks!! I tested it .....

:-)

the tester did:

2008.04.13 23:59:35 2008.03.27 02:46 Tester: not enough money for sell 1.00 EURUSD at 1.5819 sl: 1.5859 tp: 1.5813 [2008.03.27 02:46]


why? :-(

  • rder send error 134


 
How do I used Heiken Ashi Smoothed indicator in my EA?

I want to know how to define if there is a blue color or red color on a heiken candle. Sometimes there are both colors on one candle.

How do I code my EA to figure out whether a heiken candle is blue, or red or has both colors in it?

Or are there calculations I can use to determine the type of candle it is, instead of going by color?
 

both colors in one candle ?

 
mindreality:
How do I used Heiken Ashi Smoothed indicator in my EA?

I want to know how to define if there is a blue color or red color on a heiken candle. Sometimes there are both colors on one candle.

How do I code my EA to figure out whether a heiken candle is blue, or red or has both colors in it?

Or are there calculations I can use to determine the type of candle it is, instead of going by color?

Use the condition from the indicator that decides the colour like this one.

if (haOpen<haClose)

Reason: