can any one help pls?

 

double tak=0;
tak=CurrentBasket/Ilo;
int Spread = (Ask - Bid) / Point + 0.1;



if(tak>=60){TrailingStop = 20;}

if (OpenPos==1) {

if(tak<=-50){Print(tak);
static int statik=1;}
if (statik==1){if(tak >-30)CloseEverything();statik =0;}

}

2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: Order 0 failed to close. Error:0

2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: Alert: Order 0 failed to close. Error:4051

2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: OrderClose error 4051

2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: invalid ticket for OrderClose function

2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: Order opened : EURUSD Buy @ 1.47877000 SL @ 1.47747000 TP @1.48877000 ticket =1

2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: open #1 buy 0.10 EURUSD at 1.47877 sl: 1.47747 tp: 1.48877 ok

getting this error...

------------------------------------------------

vieri3225 2011.07.30 00:43edit | delete

I mean for example my original stoploss is 20 pips.but if it reaches 15 pip I want it to set 8.........like trailing stop.

modifying stop loss..

-20...................

-18 => -11

-17 => -10

-16 => -9

-15 => -8

negative trailingstop is -7 for example.it reachs 17 I dont want to wait till it became positive or it comes -20.

 

  1. The code you showed has NOTHING to do with your question
  2. The error messages you showed has NOTHING to do with your question
  3. Don't DOUBLE POST
  4. I still have no Idea what you're asking
    original stoploss is 20 pips.but if it reaches 15 pip I want it to set 8
    What is 'it'
  5. Post your code. No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
  6. int Spread = (Ask - Bid) / Point + 0.1;
    Spread not adjusted for 4/5 digit brokers. Adding 0.1 to an int won't change much.
 

avatar
38
APeng 2011.07.30 01:10
void Skip_SL_to_openprice()
{
if(Use_skip_SL_to_open_price == true)
{
OrderSelect(ticket,SELECT_BY_TICKET);

//BUY order: if price is above skip level -> SL = OrderOpenPrice
    if (OrderType() == OP_BUY && Bid > OrderOpenPrice()+Skip_SL_to_Open_price*Point)
     {
      SL = OrderOpenPrice();
      Alert("SL is set to open Price: ",SL);
     }
//SELL order: if price is below skip level -> SL = OrderOpenPrice
     if (OrderType() == OP_SELL && Ask < OrderOpenPrice()-Skip_SL_to_Open_price*Point)  
     {
      SL = OrderOpenPrice();  
      Alert("SL is set to open Price: ",SL);
     } 
}     
}    
he said but I dont know how to add it to code.my true SL is 15.if it reaches -15 I dont want it to close order,but give it 5 more pips to make it max -20,then I will wait it to fall -10.so my loss is not 15 or 20.it will be 10 for some of trades.its like modify order(trailing stop).until it reaches 7 pips trail is 5,then when my profit reaches 7 or more,trailingstop will be 2,so if the chart falls my profit is 5(7-2) instead of 2(7-5).
 
Error:4051 means you have error in the part of calling OrderClose() function https://docs.mql4.com/trading/OrderClose