Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, Quad, VoroneTZ, 1 invisible), 623 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Stop and profit/loss targets #482491
02/14/21 11:44
02/14/21 11:44
Joined: Feb 2021
Posts: 6
J
jpslvie Offline OP
Newbie
jpslvie  Offline OP
Newbie
J

Joined: Feb 2021
Posts: 6
Hey guys.

My name is João, I'm from Portugal and I have an academic background in economics, finance and financial markets. Started using Zorro to backtest some momentum strategies, but I really have no knowledge in C.

I have a very basic question: how would I define a stop loss of -5% from the initial open/entry/trade price? Apologies for the very basic question.

Anyway, thanks in advance and congrats for the Zorro project. It's a great edge to have.

Cheers!

Re: Stop and profit/loss targets [Re: jpslvie] #482496
02/15/21 09:19
02/15/21 09:19
Joined: Feb 2021
Posts: 6
J
jpslvie Offline OP
Newbie
jpslvie  Offline OP
Newbie
J

Joined: Feb 2021
Posts: 6
Ok, I think this is it (pretty basic, I know...):

Stop = 0.05 * priceClose();

I have another question, how do I exit a trade if price is higher than Keltner (C, 20, 3)?

Thank you!

Last edited by jpslvie; 02/15/21 16:10.
Re: Stop and profit/loss targets [Re: jpslvie] #482506
02/16/21 01:16
02/16/21 01:16
Joined: Feb 2021
Posts: 6
J
jpslvie Offline OP
Newbie
jpslvie  Offline OP
Newbie
J

Joined: Feb 2021
Posts: 6
Why doesn't this work?

var Band = 3 * ATRS(20);
var SMATP = SMA(priceClose, 20);

TakeProfit = SMATP + Band;

(I get: Error 010: Invalid SPY TakeProfit: -0.0000)


Last edited by jpslvie; 02/16/21 01:24.
Re: Stop and profit/loss targets [Re: jpslvie] #482523
02/17/21 13:46
02/17/21 13:46
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline
Newbie
strimp099  Offline
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
priceClose() is a function and needs parentheses and the first arg to SMA is of type series. Example from the manual

Code

function run()
{
  vars Price = series(priceClose());
  vars SMA100 = series(SMA(Price,100));
  vars SMA30 = series(SMA(Price,30));
 
  if(crossOver(SMA30,SMA100))
    enterLong();
  else if(crossUnder(SMA30,SMA100))
    enterShort();
}


Last edited by strimp099; 02/17/21 13:54.
Re: Stop and profit/loss targets [Re: jpslvie] #482544
02/21/21 20:50
02/21/21 20:50
Joined: Feb 2021
Posts: 6
J
jpslvie Offline OP
Newbie
jpslvie  Offline OP
Newbie
J

Joined: Feb 2021
Posts: 6
Thank you!

Re: Stop and profit/loss targets [Re: jpslvie] #482548
02/22/21 19:08
02/22/21 19:08
Joined: Feb 2021
Posts: 6
J
jpslvie Offline OP
Newbie
jpslvie  Offline OP
Newbie
J

Joined: Feb 2021
Posts: 6
(removed)


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1