ModifyPositionAsync within OnPositionsModified loops 4 times
ModifyPositionAsync within OnPositionsModified loops 4 times
04 Dec 2018, 10:46
Hello Panagiotis
Actually, the code bellow should loop for over (which of course I don't want) but it loops exactly 4 times. Got several trades on the same asset, what I want to achieve is, when I drag one TP to a new price, all remaiing order of the same asset should also change TP to that new price. It works, however, it loops 4 times, so it changes TP for times for every order. Any suggestions?
void OnPositionsModified(PositionModifiedEventArgs obj) { foreach (Position pos in Positions.FindAll(obj.Position.SymbolCode)) { ModifyPositionAsync(pos, obj.Position.StopLoss, obj.Position.TakeProfit); System.Threading.Thread.Sleep(500); } }
Thank you
Patrick
Replies
sifneos4fx
04 Dec 2018, 11:08
RE:
Yeah, great!!! sorry for that uncessary question!!!!
Panagiotis Charalampous said:
Hi Patrick,
A suggestion is to check the position's take profit before modifying. If it is the same with the position you want to copy from, skip modification. This should break the loop.
Best Regards,
Panagiotis
@sifneos4fx
PanagiotisCharalampous
04 Dec 2018, 10:57
Hi Patrick,
A suggestion is to check the position's take profit before modifying. If it is the same with the position you want to copy from, skip modification. This should break the loop.
Best Regards,
Panagiotis
@PanagiotisCharalampous