Anyone have thought to use simple indicator like Moving Average must be chasing the price. I mean if you have buy signal then start buy and then if appear sell signal close the buy position's and start trade with sell position after closing buy. And close after appear buy signal again and so forth. No matter its minus when closing the profitable trade will discover the losses.
I have an example ea with just MA 50 with rule above.
Buy signal if the candle close above the line
Sell signal if the candle close below the line
The result like this: GBPUSD TimeFrame H1
http://img231.imageshack.us/img231/4739/31957914zi4.jpg
My problem is i want to change this Moving Average with my indicator (attached)
So anyone can help me to create this ea based on bbands_stop indicator?
I have an example ea with just MA 50 with rule above.
Buy signal if the candle close above the line
Sell signal if the candle close below the line
Inserted Code
//+------------------------------------------------------------------+ //| ContohEA3.mq4 | //| Copyright © 2008, Forexindo | //| http://www.forexindo.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, Forexindo" #property link "http://www.forexindo.com" extern double RiskPercent=5; extern int StopLoss=3000; extern int TakeProfit=10000; extern string txComment="Order EA1"; extern int MagicNumber=12345; extern double Lots=0.1; extern int Slippage=5; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if (BuySignal() ) //kalau ada signal buy { Print("Switch to buy"); //1=sell closePos(1); if (bolehTrade()) { OrderSend(Symbol(),OP_BUY,itungLot(),Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,txComment,MagicNumber,Blue); } } else if (SellSignal() ) //kalau ada signal sell { Print("Switch to sell"); //0=buy closePos(0); if (bolehTrade()) { OrderSend(Symbol(),OP_SELL,itungLot(),Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,txComment,MagicNumber,Red); } } //---- return(0); } //+------------------------------------------------------------------+ bool BuySignal() { //kalau harga close candle sebelumnya lebih besar/diatas EMA 10 pada candle sebelumnya if (iClose(Symbol(),0,1) > iMA(Symbol(),0,50,0,MODE_EMA,PRICE_CLOSE,1) ) { return(true); } else { return(false); } } bool SellSignal() { //kalau harga close candle sebelumnya lebih kecil/dibawah EMA 10 pada candle sebelumnya if (iClose(Symbol(),0,1) < iMA(Symbol(),0,50,0,MODE_EMA,PRICE_CLOSE,1) ) { return(true); } else { return(false); } } bool bolehTrade() { //kalau jumat, EA ga trade ; atau kalau ada order terbuka, EA juga ga trade if (DayOfWeek()==5 || OrdersTotal()>0) { return (false); } else { return(true); } } double itungLot() { //ini untuk itung lot secara otomatis berdasarkan SL dan persen risk double xLots=Lots; //xLots=NormalizeDouble(AccountBalance()*RiskPercent/100 /StopLoss / 10,1); return (xLots); } int closePos(int otype) { for (int a=0; a<OrdersTotal(); a++) { Print("Order found"); OrderSelect(a,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber()==MagicNumber) { if (otype==0) { if (OrderType()==OP_BUY) { Print("Closing buy"); OrderClose(OrderTicket(),OrderLots(),Bid,Slippage); } } else if (otype==1) { if (OrderType()==OP_SELL) { Print("Closing sell"); OrderClose(OrderTicket(),OrderLots(),Ask,Slippage); } } } } }
The result like this: GBPUSD TimeFrame H1
http://img231.imageshack.us/img231/4739/31957914zi4.jpg
My problem is i want to change this Moving Average with my indicator (attached)
So anyone can help me to create this ea based on bbands_stop indicator?
Attached File(s)
BBands Stops.mq4
5 KB
|
638 downloads