Results 1 to 3 of 3
 0 Attachment(s)    

Thread: Hidden SL & TP

  1. #1

    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
    7,002

    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

    Default

    Thank you very much Funyoo

    Regards,
    Jidonk

Similar Threads

  1. Add Hidden TP and SL into code
    By ivowetters in forum MQL programming
    Replies: 26
    Last Post: 11-11-2015, 20:14
  2. hello can you help me to find Hidden trailing stop
    By m4hfoud in forum Trading discussion
    Replies: 0
    Last Post: 11-08-2015, 21:28
  3. The hidden face of the Moon
    By fxtester in forum General discussion
    Replies: 1
    Last Post: 02-27-2015, 17:13
  4. Hidden take profit idea
    By logan113 in forum MQL programming
    Replies: 2
    Last Post: 12-10-2009, 16:30

Tags for this Thread

funyoo, magic, profit, stop, stoploss, thank you

Posting Permissions

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