Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 813

 
Good day! I apologize if I'm off topic, but I'm exhausted - it's a cry from the heart! I tried to use it in MQL4 and tried to figure it out myself, but it didn't work. I dug the Internet and tried to use MQL4, but nothing works. This indicator should show the difference in pips between two CFDs as a line. I.e. (bid+ask)/2 of the first instrument minus (bid+ask)/2 of the second instrument, respectively, by candlesticks. The instrument names should be set in the settings of the indicator there should be two of them. The end part of the line should change with every new tick. And the quotes should be synchronized by time, not by candle (different number of candles per day BRN and CL). Please help, good people! I am grateful in advance.
 
CJIeCaPb:
Hello. Please help. Places orders and does nothing else. No errors.

Why would that be:

for(i=1;i<=OrdersTotal();i++) //может с OrdersTotal()-1 и до 0 разумнее было бы?
{
 if(OrderSelect(i-1,SELECT_BY_POS)==true)
 {
  if(OrderSymbol()!=Symb)continue;
  if(OrderType()==4) //тип байстоп - 4
   OrderTicketBuy=OrderTicket();
   if(OrderType()==6) //тип селлстоп - 5
   OrderTicketSell=OrderTicket();
   
  }
}

Read about the types of orders, and the rest of the manual should not be on a self-twist, first read at least 10 times.

 
fantom700:
Good day! I apologize if I'm off topic, but I'm exhausted - it's a cry from the soul! I tried to use it in MQL4 and tried to figure it out myself, but it didn't work. I dug the Internet and tried to use MQL4, but nothing works. This indicator should show the difference in pips between two CFDs as a line. I.e. (bid+ask)/2 of the first instrument minus (bid+ask)/2 of the second instrument, respectively, by candlesticks. The instrument names should be set in the settings of the indicator there should be two of them. The end part of the line should change with every new tick. And the quotes should be synchronized by time, not by candle (different number of candles per day BRN and CL). Please help, good people! Thank you in advance.
There is no Bid and Ask in history, there are prices described by MqlRates and indicators are drawing by history.
 
evillive:

Why would that be:

Read about types of orders, and the rest of the manual, do not try to screw yourself, first read at least 10 times.

BUYSTOP and SELLSTOP are set, and they have types 4 and 6 respectively.

I do not understand what I mean about OrdersTotal():" from -1 to 0"?

 
CJIeCaPb:

BUYSTOP and SELLSTOP are set, and they have types 4 and 6 correspondingly.

*I don't understand what OrdersTotal() means:" from -1 to 0"?

The bystop type is 4, sellstop is 5 and types are numbered starting from zero. With type 6, it seems only deposit/withdrawal, and even that is not documented anywhere.

*Not "from -1 to 0", but "looping from OrdersTotal()-1 to 0".

Further, the OrderSelect execution must be checked, don't be lazy, you would understand from the execution error that the tickets are incorrect.

In general, all trading functions MUST be checked for error-free execution, so do not be lazy to check. And the results returned by other functions can and must be checked.

 
evillive:
There is no Bid and Ask in history, there are prices described by MqlRates, and indicators are drawn on history.

Then just three figures: first figure: first instrument price(bid+ask)/2; second figure: second instrument price(bid+ask)/2; third figure:(bid+ask)/2 of the first instrument minus (bid+ask)/2 of the second instrument. Without any history, just on ticks at a given moment of time.

Actually I wanted to do something like this: http://www.mister-forex.ru/indikator-ma-arbitrage/

Only without any by, sell. Just an indicator in form of a line.

 
evillive:

The buystop type is 3, sellstop is 5; the order type is numbered from zero. With type 6, only depositing/withdrawing seems to be different, and even that is not documented anywhere.

*Not "from -1 to 0", but "loop from OrdersTotal()-1 to 0".

Further, the execution of OrderSelect should have been checked, don't be lazy, it would have been clear from the execution error that the tickets were wrong.

In general, all trading functions MUST be checked to perform them without errors, so do not be lazy to check. And the results returned by the other functions can and should be checked.

You are confused by the numbers!

The type of operation for theOrderSend() function. Can be any of the following values:

Constant

Value

Description

OP_BUY

0

Buy

OP_SELL

1

Sell

OP_BUYLIMIT

2

BUY LIMIT pending order

OP_SELLLIMIT

3

Pending SELL LIMIT order

OP_BUYSTOP

4

Pending BUY STOP order

OP_SELLSTOP

5

Pending SELL STOP order

 
borilunad:

You are confused by the numbers!

The type of operation forOrderSend(). Can be any of the following values:

My bad, I stand corrected
 
evillive:

Type 3 is a bystop, sellstop is 5; the numbering of types starts from zero. With type 6, only depositing/withdrawing seems to be limited and even that is not documented anywhere.

*Not "from -1 to 0", but "loop from OrdersTotal()-1 to 0".

Further, the OrderSelect execution should have been checked, don't be lazy, it would have been clear from the execution error that the tickets were wrong.

In general, all trading functions MUST be checked to perform them without errors, so do not be lazy to check. And the results returned by the other functions can and should be checked.

Ahh, pointed it out wrong, yes).

Re-checked one by one. Only the sell ticket was wrong. Checked the rest too: orders, comparisons, modification. But, still a stupor after placing orders. Everything was working separately.

The condition to enter if(MA=MA1) is not correct? Because =, is not a condition sign, the correct sign is "==", however if I spelled it that way the Expert Advisor does nothing at all. The other variants: ">=", "<=", "<", ">" that and "=" lead to placing orders and further stupor.

Files:
test3_4.mq4  15 kb
 
evillive:
My bad, I'll make it up to you.
That's okay, it happens! But you can't see your luck without mistakes! ;)