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

 
itum:

It doesn't work!(
Oh, come on...
 

double Price_real = NormalizeDouble(Ask, 4);

string Price_output=DoubleToStr(Price_real, 5);

Print(Price_output);

 
New task.
I will describe the full cycle of position opening by the Expert Advisor.

1) L_1 > L_2 (Opening a Buy position.).
2) SL or TP triggers(Close Buy position.).
3) L_1 > L_2 (No trade executed).
4) L_2 > L_1 (Sell position opening).
5) The SL or TP is triggered (Close a Sell position.).
6) L_2 > L_1 (No trade is executed).

I have problems with the third and sixth parts.
> _ > "Head Off".

Can you help me with this problem?
 
Link_x:
New task.
I will describe the full cycle of position opening by the Expert Advisor.

1) L_1 > L_2 (Opening a Buy position.).
2) SL or TP triggers (Close Buy position.).
3) L_1 > L_2 (No trade executed).
4) L_2 > L_1 (Sell position opening).
5) The SL or TP is triggered (Close a Sell position.).
6) L_2 > L_1 (No trade is executed).

I have problems with the third and sixth parts.
> _ > "Head Off".

Could you help me with this problem?

With this formulation of the problem, anyone's head would be upside down. Maybe try to rephrase...
 
itum:
artmedia70:

Let's say the price is 1.52556 and we need to do 1.52550


Might help.

int iPrice=Bid/Point;
double dPrice=(iPrice/10)*10.0*Point;
 
Vinin:

With a problem statement like that, anyone would have their head screwed on. Might try to rephrase it.

That's right.

You need to write part of the code of the trading robot so that it makes a trade once if the trading conditions are met.
For example:
1) If Line_1 is higher than Line_2, a buy trade is executed,
2) The deal is closed at SL or TP,
3) If Line_1 is higher than Line_2, a trade is not executed until conditions change. .

If conditions change, i.e. Line_2 is higher than Line_1, a trade is executed. Then everything is repeated.
1) If Line_2 is higher than Line_1, a buy trade is executed,
2) The trade is closed at SL or TP,
3) If Line_2 is higher than Line_1, a trade is not executed until conditions change. .

And.
1) If Line_1 is higher than Line_2, a buy trade is executed..,
2) The trade is closed at SL or TP,
3) If Line_1 is higher than Line_2, the trade is not executed until the conditions change. .

etc.

I cannot get to grips with the part where dealing is forbidden.
 
Link_x:

That's right.

You need to write part of the code of the trading robot so that it makes a trade once if the trading conditions are met.
For example:
1) If Line_1 is higher than Line_2, a buy trade is executed,
2) The deal is closed at SL or TP,
3) If Line_1 is higher than Line_2, a trade is not executed until conditions change. .

If conditions change, i.e. Line_2 is higher than Line_1, a trade is executed. Then everything is repeated.
1) If Line_2 is higher than Line_1, a buy trade is executed,
2) The trade is closed at SL or TP,
3) If Line_2 is higher than Line_1, a trade is not executed until conditions change. .

And.
1) If Line_1 is higher than Line_2, a buy trade is executed..,
2) The trade is closed at SL or TP,
3) If Line_1 is higher than Line_2, the trade is not executed until the conditions change. .

etc.

I cannot get to grips with the part where dealing is forbidden.


That is, you want to execute a trade when the signal appears once, not to open again on the same signal
 
Vinin:

So you want to make a trade when the signal appears once, not to reopen on the same signal
Yes.

Reduced my 7 sentences. :)
 
Link_x:
Yes.

Shorten my 7 sentences. :)

Check whether or not there is a signal.

1. If there is a signal, determine the time of its start. Looking for a position among the open and closed orders, which was opened by this signal

1.1. if we find it, we do nothing

1.2 If we do not find it, we open a position.

2 No signal, do nothing
 
Vinin:

Check whether or not there is a signal.

1. If there is a signal, determine the time of its start. Looking for a position among the open and closed orders, which was opened by this signal

1.1 If we find it, we do nothing

1.2 If we don't find a signal, we open a position

2 No signal, don't do anything

In this case, the robot will perform only two trades (buy/sell) as the signal is received based on the position of two lines (Line_1 > Line_2 or Line_2 > Line_1).
It should be like this:

1) If Line_1 is higher than Line_2, a buy trade is made..,
2) The deal is closed at SL or TP,
3) If Line_1 is above Line_2, a trade is not executed until conditions change. .
4) If Line_2 is higher than Line_1, a buy trade is executed,
5) The trade is closed at SL or TP,
6) If Line_2 is above Line_1, a trade is not executed until conditions change. .

Code 1,2,4,5 parts - I can create, but 3 and 6 I cannot.