[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 848

 

I think that's why

while (att_to_modify_sell<= attempt_to_modify)
 
vasya_vasya:

I think that's why.

Thanks, noticed and deleted the post immediately, but you managed to reply to it :)

I still don't like my cyclic pattern...

The task is to close order after n-number of unsuccessful attempts to modify it according to the market!

Please show me how to do this nicely in code.

Thank you!

 
vasya_vasya:

I think it's because of this.

att_to_modify=2;
att_to_modify_sell=0;
            
Print("att_to_modify_sell="+att_to_modify_sell);
Print("Модификация SL, попытка установить новый СЛ, ord_open_sell="+ord_open_sell+" stop_TP="+stop_TP+" Старый СЛ= "+ord_sl+" Bid="+Bid+" ord_take_profit="+ord_take_profit+" Ask="+Ask);
Print("Модификация в цикле1");   
ticket=OrderModify(ticket_sell,0,NormalizeDouble((ord_open_sell-stop_TP*Point),Digits),NormalizeDouble(ord_take_profit,Digits),0,0); //первый перенос СЛ
  if(ticket<0)
  {               
    Print("OrderModify(SELLSTOP install first SL) failed with error #",GetLastError());
    att_to_modify_sell+=1;
    Sleep(3000);
    if (att_to_modify_sell>=attempt_to_modify /*&& Ask<(ord_open_sell-stop_TP*Point-p_TS_DIST*Point)*/)                     
    {
      OrderClose(ticket_sell,ord_lots,MarketInfo(Symbol(),MODE_ASK),3,Green);
    }
    if(ticket>=0)
    {
      att_to_modify_sell=attempt_to_modify+1;
      Print("Модификация прошла успешно");
    }  
    Print("att_to_modify_sell!!!="+att_to_modify_sell);           
  }

Conclusion:

2010.09.14 16:46:04 2010.06.07 00:00 MM1.20 EURUSD,M5: OrderModify error 130
2010.09.14 16:46:04 2010.06.07 00:00 MM_1.20 EURUSD,M5: In-Cycle1 Modification
2010.09.14 16:46:04 2010.06.07 00:00 MM_1.20 EURUSD,M5: SL modification, trying to set a new SL, ord_open_sell=1.19799000 stop_TP=200 Old SL=1.20499000 Bid=1.19470000 ord_take_profit=1.19479000 Ask=1.19483000
2010.09.14 16:46:04 2010.06.07 00:00 MM_1.20 EURUSD,M5: att_to_modify_sell=0


There was an error, so why am I not processing the condition

if(ticket<0) ?????


and consequently no prints are displayed...

Print("OrderModify(SELLSTOP install first SL) failed with error #",GetLastError());
Print("att_to_modify_sell!!!="+att_to_modify_sell); 


A piece of code closes an order on the market after att_to_modify attempts!

Thank you!

 
Is it possible for the EA to disable itself?
 
Elliotttrader:

Output:

2010.09.14 16:46:04 2010.06.07 00:00 MM1.20 EURUSD,M5: OrderModify error 130
2010.09.14 16:46:04 2010.06.07 00:00 MM_1.20 EURUSD,M5: Modification in loop1
2010.09.14 16:46:04 2010.06.07 00:00 MM_1.20 EURUSD,M5: SL modification, try to set new SL, ord_open_sell=1.19799000 stop_TP=200 Old SL=1.20499000 Bid=1.19470000 ord_take_profit=1.19479000 Ask=1.19483000
2010.09.14 16:46:04 2010.06.07 00:00 MM_1.20 EURUSD,M5: att_to_modify_sell=0

There was an error, so why am I not processing the condition

and therefore no prints are printed...

A piece of code closes an order on the market after att_to_modify attempts!

Thanks!


Error 130 - wrong stops.

Analyze the 3rd parameter in the function

ticket=OrderModify(ticket_sell,0,NormalizeDouble((ord_open_sell-stop_TP*Point),Digits),NormalizeDouble(ord_take_profit,Digits),0,0); //first transfer SL

this is a sell order, as I understood it, and the stop price is lowered

Maybe we need "+" - ord_open_sell+stop_TP*Point

 
abolk:


Error 130 - wrong stops.

Analyze the 3rd parameter in the function

ticket=OrderModify(ticket_sell,0,NormalizeDouble((ord_open_sell-stop_TP*Point),Digits),NormalizeDouble(ord_take_profit,Digits),0,0); //first rollover of SL

this is a sell order, as I understood it, and you set the stop by the price

Maybe we need the "+" - ord_open_sell+stop_TP*Point

I'm not asking about this error. I'm asking why it's not being processed.
if(ticket<0)
Thank you!
 
Elliotttrader:
I'm not asking about this error. I'm asking why it's not working for me.
Thank you!

First, print the value of the ticket print after the modification
 
abolk:

For starters, print the ticket value after the modification


I am writing a question but it did not change anything, the problem is not solved, so I will repeat it in the hope to get a solution to the problem:

I'm writing myself an indicator, I need about 2000 bars from history, such a loop:

for (int i=1; i<1900; i++)

it will retrieve only 1000 bars.

I try to set the Bars variable, but it says, that its value is 1000, despite the fact, that I have drawn the chart and historical data till 2000.

Why is this happening, what is wrong????

Please advise!!!!

 
abolk:

For starters, print ticket value after modification

Shortened to

               Print("Модификация SL, попытка установить новый СЛ, ord_open_sell="+ord_open_sell+" stop_TP="+stop_TP+" Старый СЛ= "+ord_sl+" Bid="+Bid+" ord_take_profit="+ord_take_profit+" Ask="+Ask);
               Print("Модификация в цикле1");             
               ticket=OrderModify(ticket_sell,0,NormalizeDouble((ord_open_sell-stop_TP*Point),Digits),NormalizeDouble(ord_take_profit,Digits),0,0); //первый перенос СЛ
               Print("ticket="+ticket);

               if(ticket<0){Print("OrderModify(SELLSTOP install first SL) failed with error #",GetLastError());}

               Print("Модификация закончена");


2010.09.14 20:35:26 2010 06.07 00:00 MM_1.20 EURUSD,M5: Modification complete
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: ticket=0
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: OrderModify error 130
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: Modification in Loop1
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: SL modification, trying to set a new SL, order_open_sell=1.19799000 stop_TP=200 Old SL=1.20499000 Bid=1.19470000 order_take_profit=1.19479000 Ask=1.19483000

2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: att_to_modify_sell=0


Guys, I'm getting a glitch. How on error can

ticket
be naive 0-lu?
 
Elliotttrader:

Shortened to

2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: Modify finished
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: ticket=0
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: OrderModify error 130
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: Modification in Loop1
2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: SL modification, trying to set a new SL, order_open_sell=1.19799000 stop_TP=200 Old SL=1.20499000 Bid=1.19470000 order_take_profit=1.19479000 Ask=1.19483000

2010.09.14 20:35:26 2010.06.07 00:00 MM_1.20 EURUSD,M5: att_to_modify_sell=0

Guys, I'm getting a glitch. How on error can

be naven 0-lu?

print -- ticket_sell and show ticket variable type
Reason: