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

 
oleg68:

Good evening to all. I am a beginner and would like to ask the following question. How to place a stop loss and take profit from the current price correctly? tried to put a sell limit the current price was 1.3649 put Sell lemit 1.3700 stop 1.3600 teik 1.3750 and the order does not put!

i would like to ask you if it is because of

MarketInfo (Symbol(),  MODE_STOPLEVEL) // Минимально допустимый уровень стоп-лосса/тейк-профита в пунктах

MarketInfo (Symbol(),MODE_FREEZELEVEL) // Уровень заморозки ордеров в пунктах. Если цена исполнения находится в пределах, определяемых уровнем заморозки, 
                                       // то ордер не может быть модифицирован, отменен или закрыт.

or maybe because of a broker that only allows open positions with 0 sl and 0 tp (don't know for sure or is this common on pending orders).

 
    if(OrderSelect(Symbol(), OrderType() == OP_BUY) == true)
    {
    Key = Sell_Key;
    }
    //|+---------------------------------------------------------------------------------------------------+
    if(OrderSelect(Symbol(), OrderType() == OP_SELL) == true)
    {
    Key = Buy_Key;
    }
Another option.
Will it work?


Nope.
invalid integer number as parameter 1 for 'OrderSelect' function.
 
oleg68:

Good evening all, I am a newbie and would like to ask the following question. How to place a stop loss and take profit from the current price correctly? I tried to place a sell limit the current price was 1.3649 I put Sell lemit 1.3700 stop 1.3600 teik 1.3750 and the order does not put!


In a sell limit order type - take profit is set below the selling price, and stop loss is higher than the selling price.

But in your case it is vice versa.

That's where the message about the wrong stop and take comes out.
 
 
Link_x:
Another option.
Will it work?


No.
invalid integer number as parameter 1 for 'OrderSelect' function.

Open the documentation on the OrderSelect() function and you will see that this function has parameters. Where do you have them? And in general, can you explain clearly what task you want to solve?
 
Copy.

If we represent Buy_Key as -1 and Sell_Key as 1, we can arrange a skip function X when an order is opened, through the fulfillment of an if condition.
The logical chain of the skipping function X:
Buy_Key = -1
Sell_Key = 1
0 Opening of a trade.
1 Determine the order type based on the comment.
1.1 If the comment is Buy_Key, buy.
1.2 If the comment is Sell_Key, sell.
2 Opening of a subsequent trade.
1.1 If X is greater than zero, it is possible to open a Buy trade and impossible to open a Sell trade.
1.2 If X is less than zero, a Sell trade may be opened, and a Buy trade cannot be opened.
3 Repeat the cycle.

Again the question is: "How to make X variable dependent on Sell_Key or Buy_Key?



I read this about two weeks ago.
 
The "Text Label" graphical object does not know how to output text on multiple lines? I.e. when I add "\n" to the line, it doesn't respond, it ignores it as if.
 

Hi camradics.

Who has the SP500 to trade with via MT4-5 ?

 
Link_x:
Copy.

If we represent Buy_Key as -1 and Sell_Key as 1, a skip function X can be arranged when an order is opened, through the execution of an if condition.
The logical chain of the skipping function X:
Buy_Key = -1
Sell_Key = 1
0 Opening of a trade.
1 Determine the order type based on the comment.
1.1 If the comment is Buy_Key, buy.
1.2 If the comment is Sell_Key, sell.
2 Opening of a subsequent trade.
1.1 If X is greater than zero, it is possible to open a Buy trade and impossible to open a Sell trade.
1.2 If X is less than zero, a Sell trade may be opened, and a Buy trade cannot be opened.
3 Repeat the cycle.

Again the question is: "How to make X variable dependent on Sell_Key or Buy_Key?
You must be confusing yourself and others with these skipping functions. Just describe exactly what you need to do. And you may not need skipping functions at all. For example, describe your question in the following way: you need to open one buy order and one sell order if there is some condition. And do not invent any unnecessary variables. Just describe the actions to be taken in terms of opening or closing orders. Then you can instantly get the code.
 
Copying again.

You need to write a part of the code of the trading robot so that it will make 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 above Line_2, the trade is not executed until the conditions change. .

etc.
Reason: