+ Reply to Thread
Results 1 to 3 of 3
 0 Attachment(s)    

Thread: Hidden SL & TP

  1. #1
    Member
    Join Date
    Dec 2008
    Posts
    35

    Default Hidden SL & TP

    Hi Funyoo,

    How to code Hidden SL & TP?

    Thanks & Regards
    Jdk

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    6,833

    Default

    Quote Originally Posted by jidonk View Post
    Hi Funyoo,

    How to code Hidden SL & TP?

    Thanks & Regards
    Jdk
    Hi jidonk,

    In the extern parameters :

    Code:
    extern bool HideSL=false;//|---------------------hide stop loss
    extern bool HideTP=false;//|---------------------hide take profit
    In the start body :

    Code:
    //|---------hidden sl-tp
       
    if(HideSL&&StopLoss>0)
    {
       CloseBuyOrdersHiddenSL(Magic);CloseSellOrdersHiddenSL(Magic);
    }
    if(HideTP&&TakeProfit>0)
    {
       CloseBuyOrdersHiddenTP(Magic);CloseSellOrdersHiddenTP(Magic);
    }
    In the functions :

    Code:
    int CloseBuyOrdersHiddenTP(int Magic)
    {
      int total=OrdersTotal();
    
      for (int cnt=total-1;cnt>=0;cnt--)
      {
        OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
        if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
        {
          if(OrderType()==OP_BUY&&Bid>(OrderOpenPrice()+TakeProfit*dPoint))
          {
            OrderClose(OrderTicket(),OrderLots(),Bid,3);
          }
        }
      }
      return(0);
    }
    Code:
    int CloseBuyOrdersHiddenSL(int Magic)
    {
      int total=OrdersTotal();
    
      for (int cnt=total-1;cnt>=0;cnt--)
      {
        OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
        if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
        {
          if(OrderType()==OP_BUY&&Bid<(OrderOpenPrice()-StopLoss*dPoint))
          {
            OrderClose(OrderTicket(),OrderLots(),Bid,3);
          }
        }
      }
      return(0);
    }
    Code:
    int CloseSellOrdersHiddenTP(int Magic)
    {
      int total=OrdersTotal();
    
      for(int cnt=total-1;cnt>=0;cnt--)
      {
        OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
        if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
        {
          if(OrderType()==OP_SELL&&Ask<(OrderOpenPrice()-TakeProfit*dPoint))
          {
            OrderClose(OrderTicket(),OrderLots(),Ask,3);
          }
        }
      }
      return(0);
    }
    Code:
    int CloseSellOrdersHiddenSL(int Magic)
    {
      int total=OrdersTotal();
    
      for(int cnt=total-1;cnt>=0;cnt--)
      {
        OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
        if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
        {
          if(OrderType()==OP_SELL&&Ask>(OrderOpenPrice()+StopLoss*dPoint))
          {
            OrderClose(OrderTicket(),OrderLots(),Ask,3);
          }
        }
      }
      return(0);
    }

  3. #3
    Member
    Join Date
    Dec 2008
    Posts
    35

    Default

    Thank you very much Funyoo

    Regards,
    Jidonk

+ Reply to Thread

Similar Threads

  1. Add Hidden TP and SL into code
    By ivowetters in forum MQL programming
    Replies: 25
    Last Post: 02-23-2011, 19:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts