[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 895

 
belck:

I told you not to take it too much. We are not here to fight. I also do not like it when someone refuses to help - that is, it decides for me, I need advice or need to read a book. As they say - clever!

Once again, guys, please do not take it aggressively or my request is still a contradiction, if so, then I will not write it anymore.

No one has the right to forbid you to write and ask questions... But it is useful to read what many of you have started with. And we ask questions too, but, IMHO, very different ones...

You are not being refused help - you are being given a source of knowledge. What can't the SC book help you with???????????????

What didn't you like about Igor Kim's fully working features??????????

First I gave you a link to Igor's thread - take it or leave it... Use it, insert it into your code. You can assemble from them, like from bricks, YUMO different fully working Expert Advisors...

What have you started to do with them?

Your next post was a completely incomprehensible construct... ...Piled up code, in which iniit and start and deinit and all functions were practically written in a line...

I suggested you get familiar with modular programming, gave you a link to a tutorial...

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You asked me in response to post this tutorial here (!) in this thread !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

WHY????????????????????

You have a huge variety of different tutorials in front of you...

But, according to you, everyone should urgently drop what they're doing and get in line for an answer to your question. And the answer is, in fact, right in front of your eyes

 

Thank you.

 
artmedia70:

No one has a right to forbid you to write and ask... But it is worthwhile to read what many of you started with. And we ask questions too, but, IMHO, quite different ones...

You are not being refused help - you are being given a source of knowledge. Why can't the SC book help you??????????????? The answer is help!!!

What didn't you like about Igor Kim's fully working functions?????????? The answer is that it takes a long time to put them all together and go through them all.

First I gave you a link to Igor's thread - take it or leave it... Use it, paste it into your code. You can assemble from them, like from bricks, UYMU of various fully working Expert Advisors...

What have you started to do with them?

Your next post was a completely incomprehensible design, ... Piled up code, where iniit and start and deinit and all functions were practically written in a line...

I suggested you get familiar with modular programming and gave you a link to a tutorial...The answer - I read it and didn't get it all

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your response was to ask me to post this tutorial here (!) in this thread !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

WHY???????????????????? Why do you think so!

You have a huge amount of different tutorials in front of you... The answer is yours.

But, in your opinion, everyone should urgently abandon their cases and get in line for an answer to your question. The answer - all according to you And the answer, in fact, lies with you the answer - again, in front of your eyes

 
artmedia70:

You select a position from the ticket. But you do not check WHERE exactly it is. The position can be in already closed ones:

bool OrderSelect( int index, int select, int pool=MODE_TRADES)

This function selects an order for further manipulation. Returns TRUE if the function completes successfully. Returns FALSE if the function fails. Call the GetLastError() function to get information about the error.

The pool parameter is ignored if the order is selected by the ticket number. The ticket number is the unique identifier of the order. To determine from which list an order is selected, its closing time must be analysed. If the time of closing of the order is 0, then the order is open or pending and is taken from the list of open positions of the terminal. An open position can be distinguished from a pending order by its type. If the time of closing is not equal to 0, then the order is closed or pending and has been selected from the history of the terminal. The distinction between a closed order and a deleted pending order can also be made by order type.

The 4051 bug reports an invalid function !!!!!

int total=OrdersTotal();
int n=0;
for (int i=total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
n++;
}
}
if (total == 1)
{
for (int k=total-1; k>=0; k--)
{
if(OrderSelect(k,SELECT_BY_POS, MODE_TRADES))
{
//Alert("order is ", k);
if ((OrderType()==OP_BUY)&&(OrderTakeProfit()==0)&&(OrderStopLoss()==0))
{
OrderModify(k,OrderOpenPrice(),slb,tpb,0,Blue);
Alert("error ", GetLastError());
}
}
}
}}

return(0);


I'll go gray and die soon if I don't solve this issue

 
VOLDEMAR:

The error 4051 is written with an invalid function !!!!!

int total=OrdersTotal();
int n=0;
for (int i=total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
n++;
}
}
if (total == 1)
{
for (int k=total-1; k>=0; k--)
{
if(OrderSelect(k,SELECT_BY_POS, MODE_TRADES))
{
//Alert("order is ", k);
if ((OrderType()==OP_BUY)&&(OrderTakeProfit()==0)&&(OrderStopLoss()==0))
{
OrderModify(k,OrderOpenPrice(),slb,tpb,0,Blue);
Alert("error ", GetLastError());
}
}
}
}}

return(0);


I'll go gray and die soon if I don't solve this issue




ERR_INVALID_FUNCTION_PARAMVALUE 4051 Invalid function parameter value
 
artmedia70:

You'll have plenty of that :)

Thank you very much, I didn't guess to look among the constants.

 
VOLDEMAR:

error 4051 wrong function !!!!!

why

if (total == 1)
{
for (int k=total-1; k>=0; k--)
{

????

I don't see any logic - the cycle inside the condition won't always work

 
VOLDEMAR:

error 4051 wrong function !!!!!

int total=OrdersTotal();
int n=0;
for (int i=total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
n++;
}
}
if(total == 1)
{
for(int k=total-1; k>=0; k--)
{
if(OrderSelect(k,SELECT_BY_POS, MODE_TRADES))
{
//Alert("order exists ", k);
if ((OrderType()==OP_BUY)&&(OrderTakeProfit()==0)&&(OrderStopLoss()==0))
{
OrderModify(k,OrderOpenPrice(),slb,tpb,0,Blue);
Alert("error ", GetLastError());
}
}
}
}

return(0);


I'm going to go gray and die if I don't solve this problem.



You have a position number in the variable k, and you need to pass the order TICKET into the OrderModify() function as its first parameter.

Before modifying, take the ticket of the position, for example, int ticket = OrderTicket(); and pass ticket instead of k

Something like this somewhere. I wrote it on my knees, didn't check anything - just an idea... Didn't even get into your code.

int i, k, n=0, ticket=0, total=OrdersTotal();
for(i=total-1; i>=0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS))
         {
            if(OrderSymbol()==Symbol())
            n++;
         }
   }
if (total == 1)
   {
      for (k=total-1; k>=0; k--)
         {
            if(OrderSelect(k,SELECT_BY_POS, MODE_TRADES))
               {
                  Alert("ордер есть ", k);
                  if (OrderType()==OP_BUY && OrderTakeProfit()==0 && OrderStopLoss()==0)
                     {
                        ticket = OrderTicket();
                        OrderModify(ticket,OrderOpenPrice(),slb,tpb,0,Blue);
                        Alert("ошибка ", GetLastError());
                     }
               }
         }
   }

return(0);
 
IgorM:

why

if (total == 1)
{
for (int k=total-1; k>=0; k--)
{

????

I don't see any logic in it - the loop within the condition won't always hold.

Igor, the meaning is not clear here...

If the total number of orders is one (total==1), the loop from zero (total-1) to zero k>=0

Do you understand anything????? Me too... :))

 

Hi.

Here's a question. I want to take a take profit like this:

double TakeProfit =  ((LineIndicator - Ask)/2); // но мне нужно указать, что если эта цифра меньше допустимого значение, то выставляется автоматом минимальное допустимое 
значение, а это 10 пунктов.

That was the first point, but now here's another one:

The indicator line changes its position after a certain period of time. how do I make sure that take profit does not change, but stays the same as it was set when I opened it?

Reason: