I am trying to develop a strategy where I may have to exit a previous long/short position with a certain quantity and enter
in the other direction with a different quantity (the difference in quantities is because of position sizing).
Currently I am doing something like this:
quantity = get_quantity(); // for position sizing for both long and short
if (enterLong) {
EnterLong(quantity, "long");
}
else if (enterShort) {
Entershort(quantity, "short");
}
else if (exitLong) {
ExitLong("long");
}
else if (exitShort) {
ExitShort("short");
}
Will this work when the long and short quantities are different ?
Can you please provide me an example to do this correctly.
Thanks.
Comment