• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 9:10pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 9:10pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Follow the trend on high timeframes - The holy grail? 23 replies

How do you Define Identify and Follow Trend? 5 replies

Follow the trend 14 replies

Follow the trend! 181 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: EA just follow the trend
Exit Attachments
Tags: EA just follow the trend
Cancel

EA just follow the trend

  • Post #1
  • Quote
  • First Post: Nov 11, 2008 2:21am Nov 11, 2008 2:21am
  •  4051fx
  • | Joined May 2008 | Status: Member | 8 Posts
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

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)
File Type: mq4 BBands Stops.mq4   5 KB | 580 downloads
  • Post #2
  • Quote
  • Nov 11, 2008 7:25am Nov 11, 2008 7:25am
  •  Trk
  • | Joined Jan 2008 | Status: Member | 226 Posts
I might be interested, PM me the details.
 
 
  • Post #3
  • Quote
  • Last Post: Mar 22, 2017 4:33am Mar 22, 2017 4:33am
  •  thangnd.1211
  • | Joined Dec 2016 | Status: Member | 244 Posts
thank for your EA, i will test it
 
 
  • Platform Tech
  • /
  • EA just follow the trend
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023