How can I add TrailingStop program with 5min on 30min EA

Discussion in 'Trading' started by calvet, Sep 18, 2012.

  1. calvet

    calvet

    I'm new here. I am trying to reduce some risk of not getting profit when I can possibly close with lower timeframe.
    I could not find any posts. Please help me.
    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
    {
    if(OrderType()==OP_BUY) // long position is opened
    {
    // should it be closed?
    if(buyclchk==1 )
    {
    OrderClose(OrderTicket(),OrderLots(),Bid,SlipPage,Pink); // close position
    // return(0); // exit
    }
    // check for trailing stop
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>Point*TrailingStop)
    {
    if(OrderStopLoss()<Bid-Point*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Orange);
    // return(0);
    }
    }
    }
    }