Hi all

I'm new to Zorro - it looks like a fabulous system.

I'm trying to put up an algo where I sell 0.05 delta puts on the SPY.

I have Workflow 8 as a base and tweaked it to the following.
However, I want to exit my put options when the profit hits 50% of initial premium, rather than wait till expiration.
How do I do it in the code below?

Thanks a lot.



// Workshop 8: Simple Option system //////////////////////////////////////////
#include <contract.c>

#define PREMIUM 2.00
#define DAYS 6*7

void run()
{
StartDate = 20120101;
EndDate = 20200401;
BarPeriod = 1440;
set(PLOTNOW,LOGFILE);

History = ".t8"; // real options data
//History = "a.t8"; // artificial options data
assetList("AssetsIB");
asset("SPY");
Multiplier = 100;

// load today's contract chain
if(!contractUpdate(Asset,0,CALL|PUT)) return;

// Enter new positions
if(!NumOpenShort) {
if(combo(
0,0,
contractFind(PUT,DAYS,PREMIUM,2),1,
0,0,0,0))
{
MarginCost = comboMargin(-1,3);
enterShort(comboLeg(2));
}
}
}