Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1703

 
Vitaly Muzichenko #:

Yes, as long as no swaps are accrued.

and even without swaps it is incorrect

for (all) the price of the common position is not as given in the code.

 
Maxim Kuznetsov #:

and even without swaps is wrong

for (all) the price of the common position is not as given in the code.

I wonder what is wrong?
 
MakarFX #:
i wonder what is wrong ?

but think about it ?

volume BUY 1 lot, SELL also...where is the total position ?

what if BUY 2, SELL 1 ?

 
Maxim Kuznetsov #:

but think about it ?

volume BUY 1 lot, SELL also...where is the total position ?

how about BUY 2, SELL 1 ?

(1 buy-0.500+1 sell-0.200)/2=0.350
(2 buy-0.500+1 sell-0.200)/3=0.400

And what is wrong?
The person asked for the average price, not the breakeven price.
 
MakarFX #:
(1 buy-0.500+1 sell-0.200)/2=0.350
(2 buy-0.500+1 sell-0.200)/3=0.400

And what's wrong with that?
The person asked for an average price, not a breakeven price.

1 buy on 1 sell gives an average price of 0. More accurately he does not give it at all :-) it's like the positions are closed, they are just gone

and you will also surprise the "human" with the result after you fold

 
Maxim Kuznetsov #:

1 buy on 1 sell gives an average price of 0. In fact it doesn't give it at all :-) it's like positions are closed, they just aren't there

and you will also surprise the "man" a lot with the result after you refill

Once again, read it carefully! The man wants the average price.
 
MakarFX #:
Once again, read carefully! The man wants an average price.

Think before you rattle

and don't post buggy code

 
Maxim Kuznetsov #:

Think before you rattle

and don't publish buggy code

Point out the bugs
 

Hello.

Can you tell me what's wrong with the code? When compiling, row - 2, column - 5 gives an error.

long current_chart_id;
string obj_name;

int init()
  {
    current_chart_id = ChartID();
    obj_name = "vertical_line";
    
    if (!ObjectCreate(current_chart_id, obj_name, OBJ_VLINE, 0, TimeCurrent, 0))
     {
       Alert("Не удалось создать объект");
       obj_name = "false";
     }
  }

int start()
  {}

int deinit()
  {
    if (obj_name == "false")
     {}
    else
     {
       ObjectDelete(obj_name);
     }
  }
 
vladimirtrader833 #:

Hello.

Can you tell me what's wrong with the code. When compiling row - 2, column - 5 gives an error.

There is no problem in the second line.

TimeCurrent() is needed here.

If a function has an int attribute, for example

int start()
{}

it should return IntegerOrExpression;


What is the point of this code, what is its purpose? What do you want to achieve? To check the ObjectCreate() function? Take an example from the help.