Modify Stop loss price and Modify Take profit price
Modify Stop loss price and Modify Take profit price
07 Apr 2020, 22:37
Dear all,
I am testing one bot and there is one thing that is not really clear to me:
I open position with following command:
ExecuteMarketOrder(TradeType.Buy, position.SymbolName, volume, "Buy");
Since there is no option that I execute trade with already setted SL price and TP price (i do not want to set number of pips for TP and SL) I am doing following:
Positions[Positions.Count - 1].ModifyStopLossPrice(entrypositionprice);
Positions[Positions.Count - 1].ModifyTakeProfitPrice(takeprofitprice);
In this case both SL price and TP price are correctly moved. I see also in debugger Visual Studio:
But if I check my console in Ctrader i see following:
What could be wrong?
Regards
firemyst
04 Sep 2020, 09:07 ( Updated at: 21 Dec 2023, 09:22 )
RE:
WienAT said:
What could be wrong if you could have multiple positions open, which I can see from your bottom screen capture you do.
How do you know what position is in "Positions[Positions.Count - 1]"?
When you increase a position size, or open a new position, the position of your "Buy" position could change in the Positions object.
So you need to check the name of the position at "Positions[Positions.Count - 1]" or you need to search the Positions object for your specific label "Buy".
Example:
@firemyst