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
1 registered members (AndrewAMD), 677 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 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