You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys i have been trying for the last three days to get this expert advisor to execute long trades in mt4 with no success. it only executes short trades even though the signal_buy is there . please could anyone have a look at this code and fix it for me or tell me what to do. i'm new to programming and built it from an online strategy builder. thanks in advance! the code is attached.
I am not sure about the -3 shift parameter : it shift the curve to the left, so the current bar is undefinited. Try to replace all -3 by 0 to see if the buy orders are triggered.
I would replace
double Var2 = iMA(NULL, 0, 3, -3, MODE_SMA, PRICE_CLOSE, Current + 0);
double Var3 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current + 0);
double Var4 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_LOWER, Current + 0);
double Buy1_1 = iMA(NULL, 0, 3, -3, MODE_SMA, PRICE_CLOSE, Current + 0);
double Buy1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current + 0);
double Sell1_1 = iMA(NULL, 0, 3, -3, MODE_SMA, PRICE_CLOSE, Current + 0);
double Sell1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_LOWER, Current + 0);
double CloseBuy1_1 = iMA(NULL, 0, 3, -3, MODE_SMA, PRICE_CLOSE, Current + 0);
double CloseBuy1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current + 0);
double CloseSell1_1 = iMA(NULL, 0, 3, -3, MODE_SMA, PRICE_CLOSE, Current + 0);
double CloseSell1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current + 0);by
[PHP]double Buy1_1 = iMA(NULL, 0, 3, 0, MODE_SMA, PRICE_CLOSE, Current);
double Buy1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current);
double Sell1_1 = Buy1_1;
double Sell1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_LOWER, Current);
double CloseBuy1_1 = Buy1_1;
double CloseBuy1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current);
double CloseSell1_1 = Buy1_1;
double CloseSell1_2 = iBands(NULL, 0, 20, 2, 1, PRICE_CLOSE, MODE_UPPER, Current);Rem :
- Var1,2,3,4 are not used.
- Both CloseBuy1_2 and CloseSell1_2 are the same : one is probably wrong (MODE_LOWER)
Need help with code
Michel, thanks a lot for your help, that fixed it perfectly! you guyss are the best, i can finally get some rest. I'll let you know how my testing turned out.
oh by the way, r u saying that -3 will never be able to work in this expert advisor? thanks again.
... oh by the way, r u saying that -3 will never be able to work in this expert advisor? thanks again.
To tell you the truth, I never really understood the use of this shift : if you want to know the value of an indic 3 bars before the current bar, just use 3 as shift, but the last one; the first one just shift the drawing of the curve, and if you use a negative value, it's like the past is knowing the future...
Anyway I would be happy that someone explain me it's use !
But to answer your question, try to know the exact strategy you want to follow, from where comes that -3 ?
hello
on this expert I'd like modify all sl to last orders sl same as tp but I couldn't
please help me
What have I done?
I need help coding in MT4
I have some code below:
StopLoss=EMAtrend-iClose(NULL,0,1);
TakeProfit=StopLoss
If(EMAshort>EMAlong && EMAshort_prev<EMAlong_prev)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask+StopLoss*Point,Bid+TakeProfit*Point,"Buy at close price",10000,0,Green);
}
If(EMAshortEMAlong_prev)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,0,StopLoss,Bid+TakeProfit*Point,"Sell at close price",11000,0,Red);
}
The idea were:
1. Open order at close price when criteria met;
2. I want to make the EMAtrend to be the stoploss level;
3. The distance between EMAtrend to Close price bar will be the distance for takeprofit from opened price
I try the code above but nothing happen and there is an error 130.
Please help me.
Need help with code
Hi all
I am trying to get an ea to compile, but it comes up with the following error:
Now the part of the ea causing this is right at the start of the code :
If I block this out it comes up with errors for the following bit of code :
[CODE] if(TotalTradesThisSymbol(TradeSymbol)==0) { int BS=0,SS=0,BL=0,SL=0; }
if(TotalTradesThisSymbol(TradeSymbol)>0) {
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()== Symbol) {
if(OrderMagicNumber()==11) { BS=OrderTicket(); }
if(OrderMagicNumber()==22) { SS=OrderTicket(); }
if(OrderMagicNumber()==33) { BL=OrderTicket(); }
if(OrderMagicNumber()==44) { SL=OrderTicket(); }
}//end if(OrderSymbol
}//end for
}//end if */What I am wanting to know is if there is an easy way to fix this.
I'm no good at coding , only copying and pasteing.
Thanks in advance
Basza
Hi all
I am trying to get an ea to compile, but it comes up with the following error:
Now the part of the ea causing this is right at the start of the code :
If I block this out it comes up with errors for the following bit of code :
[CODE] if(TotalTradesThisSymbol(TradeSymbol)==0) { int BS=0,SS=0,BL=0,SL=0; }
if(TotalTradesThisSymbol(TradeSymbol)>0) {
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()== Symbol) {
if(OrderMagicNumber()==11) { BS=OrderTicket(); }
if(OrderMagicNumber()==22) { SS=OrderTicket(); }
if(OrderMagicNumber()==33) { BL=OrderTicket(); }
if(OrderMagicNumber()==44) { SL=OrderTicket(); }
}//end if(OrderSymbol
}//end for
}//end if */What I am wanting to know is if there is an easy way to fix this.
I'm no good at coding , only copying and pasteing.
Thanks in advance
BaszaYou can define TradeSymbol as string on global scoop, but there you cannot evaluate the function Symbol(). So replace all "TradeSymbol" by "Symbol()", or assign the value in the init() or start() function like this:
help in programming
Hi i was trying to program an ea, and i followed your course (very intresting!)
I know quite well how to program in java and some c++
I was trying to program an ea with brain trend indicators the idea behind is
when brainTrend2stop and braintrend1stop DOTs are present buy (and viceversa)
but if i call the icustom function like this
BuyValueCurrent = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,1) ;
i get only the value of the indicator in the present bar
is there a way to make it boolean? i'd like to write a function like
buy=true
BuyCondition = (IndicatorName1=true && IndicatorName2=true);
can someone help please please please???
Control if an Entry Order is Executed...
i have an EA wich open and mange the position, but sometimes give the indikator the same signal multiple and the EA open everytime this signal comes out an new position - but i dont want a second or third and so on and on position, i will only the first one - is it possible that the EA checks the open position by the basis of the magic number and pair to avoid such multiple entrys ?
Hi i was trying to program an ea, and i followed your course (very intresting!)
I know quite well how to program in java and some c++
I was trying to program an ea with brain trend indicators the idea behind is
when brainTrend2stop and braintrend1stop DOTs are present buy (and viceversa)
but if i call the icustom function like this
BuyValueCurrent = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,1) ;
i get only the value of the indicator in the present bar
is there a way to make it boolean? i'd like to write a function like
buy=true
BuyCondition = (IndicatorName1=true && IndicatorName2=true);
can someone help please please please???