I am wanting to hedge my positions using a single asset (Hedge = 2;)

Is there a way to close all trades (both long and short) when a certain condition is met.

I have tried the following with the "if statement" on the outside as well.
for(open_trades)
{
if(condition)
exitLong();
exitShort();

}

This seems to only close long trades.

I read on the forum about using the tick() function but no luck either.

I have tried using functions like a portfolio but no luck.

Any ideas?