Stop Loss in profit by using ordermodify

 

Hi guys

I want to move stop loss to profit using ordermodify, but I can´t write:

OrderModify(OrderTicket(),0,Ask+100*Point,Ask+300*Point, 0,Yellow)

Some alternative.

Sorry for my bad english.

 

Maybe you should write something like . . .

OrderSelect(. . . . . );

OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+ X * Point, OrderTakeProfit(), 0, Yellow)
 

Hi, thanks for help quickly, but still not working.

The code is the following and nots moves sl or tp

if (Ask>= limitecima)
{
if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+50*Point,OrderOpenPrice()+200*Point, 0,Yellow);
RefreshRates();
}

}

but if I write (changing the positive sign for negative) alreadys works.

if (Ask>= limitecima)

{
if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-50*Point,OrderOpenPrice()+200*Point, 0,Yellow);
RefreshRates();
}

}

Will be limitation for the broker??

 

Hi, thanks for help quickly, but still not working.

The code is the following and nots moves sl or tp


if (Ask>= limitecima)
{
if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+50*Point,OrderOpenPrice()+200*Point, 0,Yellow);
RefreshRates();
}
}

but if I write (changing the positive sign for negative) alreadys works. (OrderOpenPrice()-50*Point)

if (Ask>= limitecima)

{
if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-50*Point,OrderOpenPrice()+200*Point, 0,Yellow);
RefreshRates();
}
}

Will be limitation for the broker??

 
xspeculator:

Hi, thanks for help quickly, but still not working.

The code is the following and nots moves sl or tp


but if I write (changing the positive sign for negative) alreadys works. (OrderOpenPrice()-50*Point)

if (Ask>= limitecima)

Will be limitation for the broker??


If you do that modifie directly after opening then you have an incorrect Stoploss The price is lower then your Stoploss
 
xspeculator:
I want to move stop loss to profit
What part of LOSS in stop loss was unclear. Stop Loss is always below (buy) current market.
 

To be more clear, I want to do following:

if (Ask>= OrderOpenPrice()+100*Point)
         {
         if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
            {
            OrderModify(OrderTicket(),0,Ask +50 * Point,Ask+200*Point, 0,Yellow);
            RefreshRates();
            }
         }

Exists Any alternative? (Scripts (lines in graphs), metatrader5)

This is for use when I´m sleeping, therefore, I have find a 100% automated method


Thanks for all

 

Read the documentation .. . . you cant use OrderOpenPrice() unless you have selected the Order using OrderSelect()

Your TP and SL have to be either side of current price. They can't both be above or both be below . . . otherwise your trade will be stopped out or will take profit.

 
xspeculator:

To be more clear, I want to do following:

if (Ask>= OrderOpenPrice()+100*Point)
         {
         if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
            {
            OrderModify(OrderTicket(),0,Ask +50 * Point,Ask+200*Point, 0,Yellow);

Let me be clear. Stop Loss is always below (buy) current market. Ask+50 will never work.

You want: when market is 100 points above open price, move SL to open price+50 or equivalently SL to market price - 50.

for a buy order TP and SL are relative to the BID

If you want a trailing stop (for a buy) it is always Bid - Xpips

 
xspeculator:

To be more clear, I want to do following:

Exists Any alternative? (Scripts (lines in graphs), metatrader5)

This is for use when I´m sleeping, therefore, I have find a 100% automated method


Thanks for all


if (Ask>= OrderOpenPrice()+100*Point)
         {
         if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
            {
            //OrderModify(OrderTicket(),0,Ask +50 * Point,Ask+200*Point, 0,Yellow);
             OrderModify(OrderTicket(),OrderOpenPrice(),Ask +50 * Point,Ask+200*Point, 0,Yellow);
            }
         }
Why do you trie to modifie for an opened order the orderopenprice() to 0 (zero) modifieing Orderopenprice() can only work for trades still pending...
 

Sorry,

But I discovery other problem,

The order is modify in th same moment of open trade, Why??

So I thought that Ask equals OrderOpenPrice, sorry

What is wrong???

  if (Hour()==01 && Minute()==00)// for example
      {           
      int Orderticketbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,3000,NULL,0,18,Green);
                
      OrderSelect(Orderticketbuy,SELECT_BY_TICKET);
      int limitecima = OrderOpenPrice ();
      RefreshRates();
      }
if (Bid > limitecima +100*Point)
      {  
      if (OrderSelect(Orderticketbuy,SELECT_BY_TICKET)==True)
         {             
         OrderModify(OrderTicket(),OrderOpenPrice(),Bid-50*Point,Bid+100*Point, 0,Yellow);
         }   
      }  
Reason: