Gamestudio Links
Zorro Links
Newest Posts
Indicator coding
by danatrader. 05/30/20 21:41
Out of Sample
by AndrewAMD. 05/30/20 21:12
Trading Community Project
by danatrader. 05/30/20 20:28
MT4/5 - wrong M1 time
by Grat. 05/30/20 19:14
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 05/30/20 15:18
Windows 10 file_write error
by AndrewAMD. 05/30/20 13:57
stencil blur does not work - SOLVED
by NicolaB. 05/30/20 12:13
Question about Pattern - Workshop7
by danatrader. 05/30/20 09:09
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
10 registered members (3run, danatrader, AndrewAMD, alibaba, Grat, ozgur, kvm, Dooley, 2 invisible), 525 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
PBSeven, Hardi01, Giuseppe, AdamWu, gariki
18460 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to take profit on a short put at 50% of initial premium #479532
04/04/20 16:26
04/04/20 16:26
Joined: Apr 2020
Posts: 1
T
tanhwuser Offline OP
Guest
tanhwuser  Offline OP
Guest
T

Joined: Apr 2020
Posts: 1
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));
}
}
}

Re: How to take profit on a short put at 50% of initial premium [Re: tanhwuser] #479542
04/05/20 07:50
04/05/20 07:50
Joined: Apr 2008
Posts: 299
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 299
Austria
A combo has at least two legs. Combos with no first leg probably won't work.

For the profit taget I think, select the contract and then set TakeProfit = 0.5 * contractPrice(ThisContract).



Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1