Close a third of the position
Close a third of the position
05 Apr 2023, 23:51
Hi,
I was wondering if someone was able to explain how I could partially close the trade please?
So for example if I have a trade and I am risking 3% of my account balance, when the trades get to 2% profit I want to close 1% (I guess 33% of the trade volume) of that trade and then leave the other 2% (66% of the trade) open.
Cheers,
Jay
this is my current code that doesnt seem to work:
double currentVolume = position.VolumeInUnits;
double newVolume = currentVolume * 0.66;
if (position.ModifyVolume(newVolume).IsSuccessful)
{
//trade partially closed - but this never seems to get here
}
Replies
jaydcrowe1989
06 Apr 2023, 09:42
RE:
PanagiotisChar said:
Hi Jay,
You need to wrap your volume with the Symbol.NormalizeVolumeInUnits() method. See below
double newVolume = Symbol.NormalizeVolumeInUnits(currentVolume * 0.66);
Need help? Join us on Telegram
Need premium support? Trade with us
Perfect, thank you!
@jaydcrowe1989
PanagiotisChar
06 Apr 2023, 08:10
Hi Jay,
You need to wrap your volume with the Symbol.NormalizeVolumeInUnits() method. See below
Aieden Technologies
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar