Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (AndrewAMD, TipmyPip, NewbieZorro, Grant), 14,196 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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