Script's TP modified and never closes the order?

 

Hi,

Being a total newbie in programming, I'm trying to understand why the orders placing script's TP function does not work properly. (I did not write the script)

So here is the weird problem (active buy order example):

When the approaching ask-line hits the originally set TP and moves forward, script start to continuously adjust TP forward to ask-line's current position..so the following bid-line, which would close the trade, never gets to hit the TP.

Here is the part of code I think is responsible for this:

if (OrderType() == OP_BUY) {
ld_16 = MathMin(Bid - ai_4 * Point, OrderOpenPrice() + ai_8 * Point);
if (ld_16 > OrderStopLoss()) {
ld_24 = MathMax(OrderTakeProfit(), Bid + MarketInfo(Symbol(), MODE_STOPLEVEL) * Point);
ld_16 = NormalizeDouble(ld_16, Digits);
ld_24 = NormalizeDouble(ld_24, Digits);
li_12 = OrderModify(-ai_0, OrderOpenPrice(), ld_16, ld_24, 0, CLR_NONE);

Could anyone see what causes the problem? How to disable this TP's modification and to just normally close the trade as original TP is hit?

Any advise would be very much appreciated!

 
digi_fx:

How to disable this TP's modification and to just normally close the trade as original TP is hit?

Any advise would be very much appreciated!

Please use this to post code . . . it makes it easier to read.

 
RaptorUK:

Please use this to post code . . . it makes it easier to read.

Just comment out the OrderModify line if you want a quick and dirty "fix" . . .


Thanks a lot for your reply..and for letting me know about the SRC-option, I will use it next time.

I thought that OrderModify does not quite belong there in TP function.

Could you or someone else see what is the actual purpose of that line..to really move the TP?...or may be there is some error in the previous code lines that causes it to modify? Those "Bid + " and "Bid -" may be?

 

Sorry, just noticed your code . . .

DON'T USE OR POST DECOMPILED CODE