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

 
AlexeyVik:

Well, unless it's written on the spot.


Thank you very much.
 
fmv_for_a_way:

Citizens, can you tell me why the Alpari terminal is unable to place an order?

The OrderSend function looks like this

There are no parameters equal to zero. I have checked it.

The minimum stop and profit distance according to the terminal conditions = 0.1.

The terminal generates error 130 and writes about an invalid profit or stop.

SL and TP parameters are 11 and 1 (after normalization), respectively.

On terminals Aforex, Diven FX, ForexClub, AlfaForex - no problems with the same code.

For Buy Stop and Take are counted from the Bid price - this is one.

Second - since stop prices are calculated, they need to be normalised. The previous normalization of SL and TP is nothing. Then in the trade order you substitute the non-normalized value of the expression.

Third, all prices must comply with trading requirements and restrictions. The StopLevel level, for example, may be greater than the size of the stop order.

 

Please advise why this is the case.

There are three conditions (in bold), when executed simultaneously, an order is successfully opened.

int start()

{

int ot = OrdersTotal();

int index=iHighest(NULL,0,MODE_HIGH,20,1);
int index1=iLowest(NULL,0,MODE_HIGH,20,1);
int index3=iLowest(NULL,0,MODE_HIGH,40,20);

if(Low[index1]==Low[1])

if(High[index]==High[20])

if(Low[index3]==Low[40]

if ( Bid==Low[40])

if (ot==0)

OrderSend(Symbol(),OP_SELL,0.1,Bid,1,Ask+1500*Point,Ask-300*Point, "jfh",123 )

PROBLEM

As soon as I add a fourth condition (marked in red), an order is opened ONLY if the fourth condition is fulfilled.

Theprevious three conditions are ignored by the program.

I tried to write the conditions through &&.... does not work

How to make so that the warrant would be opened when all four conditions are fulfilled simultaneously.

Thanks.

 
solnce600:

Please advise why this is the case.

There are three conditions (highlighted in bold) which, when executed at the same time, successfully open an order.

int start()

{

int ot = OrdersTotal();

int index=iHighest(NULL,0,MODE_HIGH,20,1);
int index1=iLowest(NULL,0,MODE_HIGH,20,1);
int index3=iLowest(NULL,0,MODE_HIGH,40,20);

if(Low[index1]==Low[1])

if(High[index]==High[20])

if(Low[index3]==Low[40]

if ( Bid==Low[40])

if (ot==0)

OrderSend(Symbol(),OP_SELL,0.1,Bid,1,Ask+1500*Point,Ask-300*Point, "jfh",123 )

PROBLEM

As soon as I add a fourth condition (marked in red), the order opens when the fourth condition is fulfilled ONLY.

The program ignoresthe previous three conditions.

I tried to write the conditions through &&.... does not work

How to make so, that the warrant would be opened at once execution of all four conditions.

Thank you.

Expand the curly brackets as the algorithm should work.
 
artmedia70:

For Buy, stop and take are calculated from the Bid price - that's one.

Secondly, if you calculate stop order prices, they need to be normalised. The fact that SL and TP were normalized earlier is no big deal. Then in the trade order you substitute the non-normalized value of the expression.

Third, all prices must comply with the requirements and restrictions for trading operations. The level of StopLevel, for example, may be larger than the size of the stop order.



on alpari since yesterday switched to market execution i.e.

First buy/sell sl=0;tp=0; then modify sl=100;tp=300;

 
AlexeyVik:
Expand the curly braces as the algorithm should work.

Thank you.
 
pako:


on alpari since yesterday switched to market execution i.e.

first buy/sell sl=0;tp=0; then modification sl=100;tp=300;

This is also in the same place. Of course - one does not contradict the other. It counts stop orders for Buy from Ask. It does not normalize them. Does not check for StopLevel distance limit.

In short - a hodgepodge.

 
Great, questions get deleted, great.
 
pako:


Alpari has switched to market execution since yesterday, i.e.

first buy/sell sl=0;tp=0; then modification sl=100;tp=300;


Thank you for the advices. I will look into it. Does switching to market execution mean that pending orders should also be placed with zero stops and profits and then modified?
 
artmedia70:

That goes there too. Naturally - one does not contradict the other. He's counting stop orders for the Buy from the ask. Doesn't normalize them. Doesn't check for StopLevel distance limitation.

In short, it is a hodgepodge.



I got it, thank you. I really messed up with the prices. StopLevel should be checked before placing a pending order. Stops and lots are also checked for the same lousiness.

In this particular case the stop leveller according to the broker's terms = 0, and the stop and profit are set much further back. As for the market order price, as far as I understand it, it is opened at the nearest market price and the stop level has nothing to do with it in this case. Right?

Reason: