i need it for my ea becaus i use trailing stop with just 10point ( 0.00010) and my broker accepts minim stoploss 20pip

I have tried to work trailing stop does not use stop loss but it did not work with me











//__________________________________________________ __________________________________________________ ____________________//

input int TrailingStop=500;
double stoplossbuy;
double stoplosssell;

//__________________________________________________ __________________________________________________ ____________________//
//__________________________________________________ __________________________________________________ ____________________//
//__________________________________________________ __________________________________________________ ____________________//
//__________________________________________________ __________________________________________________ ____________________//

TrailingPositionsBuy(TrailingStop);
TrailingPositionsSell(TrailingStop);
closetrailingstop();
//__________________________________________________ __________________________________________________ ____________________//

if (OrdersTotal()==0)
{

stoplossbuy=0;
stoplosssell=0;
}
}




//__________________________________________________ __________________________________________________ ____________________//
//__________________________________________________ __________________________________________________ ____________________//
//__________________________________________________ __________________________________________________ ____________________//

//Closeall

void closeall()
{

int total=OrdersTotal();
for(int cnt=OrdersTotal()-1; cnt<total; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);

if(OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,Violet) ;
}

if(OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,0,Violet) ;
}

if(OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)
{
OrderDelete(OrderTicket());
}

}
}


//__________________________________________________ __________________________________________________ ____________________//
//__________________________________________________ __________________________________________________ ____________________//


//__________________________________________________ __________________________________________________ ____________________//
void TrailingPositionsBuy(int trailingStop) {
for (int z=0; z<OrdersTotal(); z++)
{
if (OrderSelect(z,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
// if (Bid-OrderOpenPrice()>trailingStop*Point)
// {
if (stoplossbuy < Bid-trailingStop*Point)
stoplossbuy=(Bid-trailingStop*Point);
// }
}
}
}
}

}


//__________________________________________________ __________________________________________________ ____________________//
void TrailingPositionsSell(int trailingStop) {
for (int w=0; w<OrdersTotal();w++)
{
if (OrderSelect(w,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol()==Symbol())
{
if (OrderType()==OP_SELL) {
// if (OrderOpenPrice()-Ask>trailingStop*Point) {
if (stoplosssell >Ask+trailingStop*Point)
stoplosssell=(Ask+trailingStop*Point);

// }
}
}
}
}

}


//__________________________________________________ __________________________________________________ ____________________//

void closetrailingstop()
{
OrderSelect(0,SELECT_BY_POS);
if (OrderType()==OP_BUY)
{
if (Bid<=stoplossbuy && stoplossbuy!=0){
closeall();}


}
if (OrderType()==OP_SELL)
{
if (Ask>=stoplosssell && stoplosssell!=0){
closeall();}
}


OrderSelect(1,SELECT_BY_POS);
if (OrderType()==OP_BUY)
{
if (Bid<=stoplossbuy && stoplossbuy!=0){
closeall();}
}
if (OrderType()==OP_SELL)
{
if (Ask>=stoplosssell && stoplosssell!=0){
closeall();}
}



}