Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, 7th_zorro), 893 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
BBands Breakout Strategy : Multi-Positions Issues #484697
12/03/21 17:03
12/03/21 17:03
Joined: Dec 2021
Posts: 13
S
Sage Offline OP
Newbie
Sage  Offline OP
Newbie
S

Joined: Dec 2021
Posts: 13
Hello! I am backtesting a BBands breakout strategy. Found out that Zorro enters a new position every time a breakout happens regardless if the previous positions are closed or not meanwhile I need only one position at a time till the position either closes in loss or profit. What I need is a simple reverse strategy

Here is the code for the strategy. I just need the code to prevent multi-positions till a reverse happens



function run()
{
set(LOGFILE);
StartDate = 20050101;
EndDate = 20210101;
BarPeriod = 1440;
LookBack = 200;


vars Close = series(priceClose());
vars Prices = series(price());


BBands(Prices,50,2,2,MAType_SMA);
vars upperBand = series(rRealUpperBand);
vars lowerBand = series(rRealLowerBand);


if (crossOver(Close, upperBand)) enterLong();
else if (crossUnder(Close, lowerBand)) enterShort();

}

Attached Files Forum.PNG
Last edited by Sage; 12/03/21 17:12.
Re: BBands Breakout Strategy : Multi-Positions Issues [Re: Sage] #484698
12/03/21 21:30
12/03/21 21:30
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline
Member
MegaTanker  Offline
Member
M

Joined: Aug 2021
Posts: 101
Set MaxLong and MaxShort to 1, then Zorro will not open multiple trades in the same direction

Re: BBands Breakout Strategy : Multi-Positions Issues [Re: MegaTanker] #484699
12/03/21 23:03
12/03/21 23:03
Joined: Dec 2021
Posts: 13
S
Sage Offline OP
Newbie
Sage  Offline OP
Newbie
S

Joined: Dec 2021
Posts: 13
Perfect! It works. Thanks


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1