I need a code

13

Hi
I have problem at writing a code for close positions
I need a code that  if price was higher than the open buy position to close position(for buy mode)
And
If the price was less than open sell position to close position(for sell mode)

thanks

```bool BuyMode;
bool SellMode;
double slB;
double slS;
extern double Price_Distance=10;
extern double LotSize=0.2;
int ticket;
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{

SellMode = ((iWPR(NULL,0,2,1)<-70));

// StopLoss & TakeProfit---------------------------------------------+

slB = iLow (Symbol(), 0 , iLowest (Symbol(),0,MODE_LOW , 2000 , 0) );
slS = iHigh(Symbol(), 0 , iHighest(Symbol(),0,MODE_HIGH, 2000 , 0) );

//Orders Counting & Close Orders------------------------------------+

int orderscnt=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
//--------------------------------------
{
orderscnt++;
}

{
OrderClose(OrderTicket(),OrderLots(),Bid,1,Black);

}

//-Close Positione Sell if
if((OrderSymbol()==Symbol()) && (OrderType()==OP_SELL))
{
}
}

// Buy AND Sell Orders ----------------------------------------------+

{
}

if((SellMode) && (orderscnt<1))
{
ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,2,slS,0,"Nothing",123456789,0,Red);
}

return(0);
}
//+------------------------------------------------------------------+```

15551

mohsenvix: I need a code that  if price was higher than the open buy position to close position(for buy mode)

Babel. What price was higher? What closed position? If you can't post a concrete question, you can't code it.
learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.