what error u get ?
Hi
There is no error, it compiles fine but when the market reaches the desired buy or sell figure and all the other conditions are satisfied then there is just no position taken by the EA.
Thanks
Antony
The problem has to lie with the logic of
if(MacdCurrent[i] > SignalCurrent[i] && SignalCurrent[i] >= 0.1*Point && Rsi <RsiBuyLevel &&
MaRed[i] > MaBlue[i] && PRICE_CLOSE == BuyLevel && SignalBuy == true)
{
Add a comment/Print/Alert to check it is doing as you expect it to.
Alternatively break the if down so that you can see all conditions apply with
if(MacdCurrent[i] > SignalCurrent[i] ) { if (SignalCurrent[i] >= 0.1*Point) { if (Rsi <RsiBuyLevel ) { if (MaRed[i] > MaBlue[i] ) { if( PRICE_CLOSE == BuyLevel ) { if( SignalBuy == true) { } } } } } }Which is a way of debuging multiple condition if statements
2 problems at least:
if( PRICE_CLOSE == BuyLevel ) // is flawed as PRICE_CLOSE is not a price but enum
extern int BuyLevel = 134.42; // is flawed - assigning real/double value to int loses decimal places
int start() { ... double Rsi,Crossover;{ for(int i = BarsToProcess+2; i >= 0; i--){ return(iRSI(Symbol(),Period(),RsiPeriod,0,i));
Nothing below this line will be executed.- On a 5 digit broker your TP= one pip, SL=1.5 pips. You must adjust TP, SL, and slippage
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
On an ECN broker you must open the order and THEN set the TP/SL if(MaRed[i] > MaBlue[i] && MacdCurrent[i] > SignalCurrent[i] && SignalCurrent[i] >= 0.1*Point) SignalBuy = true;
SignalCurrent[] is set below the test. MACD is a number +/- 1 you don't want to multiply by Point// but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
Always count down when closing/deleting in the presence of multiple order (multiple charts.) Always test your return codesfor(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair.
if (!OrderModify(...) Alert("OrderModify() failed: ",GetLastError());
total=OrdersTotal(); if(total<1)
This assumes only one chart and no manual orders, not good.for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair. // Have open order(s) ... return(0); } // No open orders(s) ...
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
I have modified an EA to suit my needs. This EA has to buy /sell at a specified price (in this case 134.42), the problem is I cant seem to get it to buy or sell t the specified price or even at all. Please note I am a novice coder, I have tired commenting out all other conditions to the buy sell prices are only tested, but still no trade:
Thanks
Antony