Coding help - page 210

 

Mladen can you help me once again?

I have to modify an open order only once with the SL. Then, when the order is 10 pips in profit, I want to set a trailing stop. How can I realize that? It only modifys again, when it's 10 pips upwards and then sets the SL breakeven.

Thank you!!!

 
arroganzmaschine:
Mladen can you help me once again?

I have to modify an open order only once with the SL. Then, when the order is 10 pips in profit, I want to set a trailing stop. How can I realize that? It only modifys again, when it's 10 pips upwards and then sets the SL breakeven.

Thank you!!!

arroganzmaschine

That is a bit more complicated

Did you check the existing EAs that are dealing with trailing stops (like these : trailing stop - Search Results - Forex-TSD )?

 
mladen:
arroganzmaschine

That is a bit more complicated

Did you check the existing EAs that are dealing with trailing stops (like these : trailing stop - Search Results - Forex-TSD )?

Thank you! I will read trough the topics.

One more question: How do I set the StopLoss 2 Pips under opening price? When I try SL=OrderOpenPrice() it works fine (BreakEven), but when I try OrderOpenPrice()-20 (5 digits), then there is a failure.

 
arroganzmaschine:
Thank you! I will read trough the topics. One more question: How do I set the StopLoss 2 Pips under opening price? When I try SL=OrderOpenPrice() it works fine (BreakEven), but when I try OrderOpenPrice()-20 (5 digits), then there is a failure.

arroganzmaschine

Use this : OrderOpenPrice()-20*Point

 
mladen:
arroganzmaschine Use this : OrderOpenPrice()-20*Point

Thank you mladen, great! Will try it later.

Is this the same with indices? Like I enter a trade at 9101 and wand to set SL to 9899. Then I have to take your code with 20?

 
arroganzmaschine:
Thank you mladen, great! Will try it later. Is this the same with indices? Like I enter a trade at 9101 and wand to set SL to 9899. Then I have to take your code with 20?

arroganzmaschine

Yes, It should be the same for indices too

 

Thanks mladen!

How can I get the current price of the symbol?

 
arroganzmaschine:
Thanks mladen! How can I get the current price of the symbol?

One of these ways (the function way - with the "desiredSymbol" argument - is for the case when you want a symbol different than the current charts symbol) :

Close[0] or iClose(desiredSymbol,0,0) -> current close

Olose[0] or iOpen(desiredSymbol,0,0) -> current open

Low[0] or iLow(desiredSymbol,0,0) -> current low

High[0] or iHigh(desiredSymbol,0,0) -> current high

 

Ok, I will try it. I only need the price of a tick.

 
arroganzmaschine:
Ok, I will try it. I only need the price of a tick.

arroganzmaschine

What does the "price of a tick" mean?

If it is a bid or ask price, then use :

MarketInfo(desiredSymbol,MODE_BID) or

MarketInfo(desiredSymbol,MODE_ASK)