Hello friend,
I am fairly sure that this part of your code is not helping.
if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++;
The first if(statement) is executed, the second If(statement) is thrown out.
Hello friend,
I am fairly sure that this part of your code is not helping.
The first if(statement) is executed, the second If(statement) is thrown out.
Please use the </> button to insert your above code.
okay. I don't see how to edit though.
I have done it for you this time, next time please use the button that Eleni has shown you when posting code.
Hello friend,
I am fairly sure that this part of your code is not helping.
if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++;
The first if(statement) is executed, the second If(statement) is thrown out.
Not so,
both if conditions will be tested.
Not so,
both if conditions will be tested.
My EA is not executing Sells, that part is calculating current orders.
That same code set up is used in many EA's I see.
My EA is not executing Sells, that part is calculating current orders.
Yes, I know what it does.
I was responding to GrumpyDuckMan's post and his incorrect observation.
Hello friends,
This code hasn't been tested.
int CheckForOpen() { int res; // make global //--- get indicator readings sto_main_curr = iStochastic (Symbol() ,PERIOD_CURRENT ,k_period ,d_period ,slowing ,ma_method ,price_field ,MODE_MAIN ,0); RSI0=iRSI(NULL,0,period_RSI,PRICE_CLOSE,0); RSI1=iRSI(NULL,0,period_RSI,PRICE_CLOSE,1); //--- sell conditions if(RSI0 < sto_main_curr && RSI1 >= over_bought) { res=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"",MagicNumber,0,FireBrick); Alert("TAIA SELL- ",Period(),"min ",Symbol()," ", Bid); // Alert return(res); } //--- buy conditions if(RSI0 > sto_main_curr && RSI1 <= over_sold) { res=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"",MagicNumber,0,Green); Alert("TAIA BUY- ",Period(),"min ", Symbol()," ",Ask); // Alert return(res); } //--- }
Maybe change your SL/TP
stoploss=MarketInfo(NULL,MODE_STOPLEVEL)*_Point
If you know the ticket number or magic number, why use select by pos?
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
I do something like this to close positions down.
bool ClosePosition() { bool Trade=(OrderSelect(Ticket[Get_Position],SELECT_BY_TICKET)==true); Trade=OrderClose(OrderTicket(),OrderLots(),0,0,clrNONE); return(Trade); }
this may be of some help also.
bool Buy() { ticket=OrderSend(Security,OP_BUY,0.01,Ask,Slippage,0,TakeProfit,BPT,BuyMagicNumber,0,clrBlue); if(ticket<0) { return (errorlevel=(GetLastError() )); } else errorlevel=(GetLastError() ); return(errorlevel); }
this way I can debug if OrderSend(); has successfully placed the order.
Not so,
both if conditions will be tested.
if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++;
Edited to include the code that is referred to.
Hello again,
The first if statement buy++ is always going to greater than the second if statement sell++.
True, or not?
if(buys>0) return(buys); else return(-sells);buys and -sells are only variables to a function.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, any help is appreciated, I can't figure out why my EA only does buy positions. I need it to do sell positions also, on multiple time frames simultaneously.
Here's the code: