Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
EXCLUSIVE FORUM
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Thanks for the help.
To be honest, I have been so busy working on a solution, I forgot that I posted the question.
I spent that day going through the mql4 manual and figured out a way to do it.
When it is time to start trading, I set a variable called "OpeningTime" equal to the current time. During the trading session and if a trade has been closed, I have the EA cycle through the order history and look for any orders that are from the given chart and EA and also have a closing time that is greater than "OpeningTime". It then compares the profit (or loss) of the order (using the OrderProfit() function) with what I have set (with an external variable) as being enough. I set it up so that I can stop trading if I made enough of a profit and/or if I have lost a given amount.
Backtesting has shown that it really doesn't improve the results of an already optimized EA any (in fact, more often it makes them worse), which is to be expected because we never know if the next trade (which I have now eliminated) will make things better or worse.
It does allow me to set more stringent conditions from the start though. So, the EA can be optimized using the "get out, I've had enough" option from the start. And that does seem to make my results quite a bit better.
void history()
{max_loss=0;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
//---- check selection result
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("Access to history failed with error (",GetLastError(),")");
break;
}
if (OrderSymbol()==Symbol()&&OrderProfit()>=max_loss)max_loss=OrderProfit();
{
//code
}
}
}
Fastbrokersfx has a free (they call exclusive) Automated Expert Advisor Builder.
They say, "FastBrokersFX offers a free Expert Advisor Builder. With us you don't need to be an experienced programmer to design your trading robots for MT4. Just a few clicks, save your generated EA file and you're done!"
Never seem to get anyone to help, guys please respond
With a moderate amount of guess work, I would suggest that the problem is with the indicator, or your extension to it, and not your use of iCustom. Perhaps it would be better to assign buffers 2 and 3 together with the alerts? (Though I couldn't work out how/when their index-zero ([0]) values would be assigned anyhow.)
My exits and entry are based on signals generating a condition on the open of the next bar (entry and exit), should I be using the open prices for indicators and moving averages? I always have used end of day data for stock trades, so naturally that's what I've gravitated toward. What's the consensus out there?
how do you set a trailing stop at the pairs minimum Stop Level so if the stop level is at 4 pip or 25 pip the sl will kick in at that depending on the pair.
I should say that how do you use the contract specification for each pair.
Hi all,
I've had a go at my first EA but it won't compile; I get an error "'\end of program' - unbalanced left parenthesis" and I've gone through it a few times but can't find the problem. Don't worry about the logic of the trading strategy (unless you're keen), I'll work on that once it compiles and runs...
Apparently I don't have permission to attach files, so sorry about the cut and paste too.
Thanks,
Rob,
Perth, Aus
//---------------
//+------------------------------------------------------------------+
//| Rob_Ea.mq4 |
//| Rob Cousins |
//| |
//+------------------------------------------------------------------+
#property copyright "Rob Cousins"
#property link ""
#define MAGICMA 20090216
//---- input parameters
extern double Lots;
extern int Short_MA=5;
extern int Long_MA=15;
extern double Stoch_Upper=70.0;
extern double Stoch_Lower=30.0;
extern double RSI_Upper=80.0;
extern double RSI_Lower=20.0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
if (MA_Short>MA_Long) Current_MA_Indicator="BUY";
if (MA_Short<MA_Long) Current_MA_Indicator="SELL";
// set the previous and current value using the shifted MA (the last '1' in the options)
if (iMA(NULL,0,Short_MA,0,1,PRICE_MEDIAN,1)>iMA(NULL, 0,Long_MA,0,0,PRICE_MEDIAN,1)) Previous_MA_Indicator="BUY";
if (iMA(NULL,0,Short_MA,0,1,PRICE_MEDIAN,1)<iMA(NULL, 0,Long_MA,0,0,PRICE_MEDIAN,1)) Previous_MA_Indicator="SELL";
if ((Current_MA_Indicator=="BUY") && (Previous_MA_Indicator=="BUY")) MA_Indicator="BUY";
if ((Current_MA_Indicator=="SELL") && (Previous_MA_Indicator=="SELL")) MA_Indicator="SELL";
if ((Current_Stoch_Indicator=="BUY") && (Previous_Stoch_Indicator=="BUY")) Stoch_Indicator="BUY";
if ((Current_Stoch_Indicator=="SELL") && (Previous_Stoch_Indicator=="SELL")) Stoch_Indicator="SELL";
if ((Current_RSI_Indicator=="BUY") && (Previous_RSI_Indicator=="BUY")) RSI_Indicator="BUY";
if ((Current_RSI_Indicator=="SELL") && (Previous_RSI_Indicator=="SELL")) RSI_Indicator="SELL";
//----------------------------------------
// Figure out if you're in a buy or sell situation
//----------------------------------------
//----------------------------------------------------------------------
// If the signal has changed direction the first thing to do is Close
// the current open trade before opening another.
//-----------------------------------------------------------------------
void CloseTrade(string symbol)
{
// double ma;
//---- go trading only for first tiks of new bar
// if(Volume[0]>1) return;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false ) break; // there are no open trades
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
// leaving both options for the moment in case I want to do it differently
// eg have a different colour, or whatever. Otherwise the two commands are the same
// and you'd only need one. Except the different prices I suppose... Doh!
//-----------------------------------------------------------
// Open a position if that's what the tea leaves say
//------------------------------------------------------------
void OpenTrade(string symbol,string Type)
{
int res;
//---- buy conditions
if(Type=="BUY") OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"ROB EA TEST",MAGICMA,0,Blue);
//---- sell conditions
if(Type=="SELL") OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"ROB EA TEST",MAGICMA,0,Red);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void start()
{
//----
//---- calculate open orders by current symbol
//--- If there are no open trades, then simply open one...