Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
One trade per Algo #467368
07/28/17 17:27
07/28/17 17:27
Joined: Dec 2016
Posts: 43
F
Fiber Offline OP
Newbie
Fiber  Offline OP
Newbie
F

Joined: Dec 2016
Posts: 43
Hi,
How can I limit only one trade/open position per Algo?
I tried
Code:
string CurrentAlgo = Algo;
for(open_trades)
if(strstr(Algo,CurrentAlgo) && !TradeIsOpen)


also
Code:
if(Algo == "TRND" &&  && NumOpenTotal == 0)


but without success.

Re: One trade per Algo [Re: Fiber] #467369
07/28/17 18:42
07/28/17 18:42
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
You are making it a bit more difficult than it is I think.
NumOpenTotal is per asset/algo, so you don't need to check what algo is currently in use.

From the manual

Code:
Limit the number of open positions
// max. 3 open long positions per asset/algo
if(my_long_condition == true) {
  exitShort(); // no hedging - close all short positions
  if(NumOpenLong < 3) enterlong();
}



Or just use reverseLong/reverseShort so e.g. instead of enterLong()
use reverseLong(x) where x is the maximum number if open positions allowed.

Re: One trade per Algo [Re: Dalla] #467370
07/28/17 19:55
07/28/17 19:55
Joined: Dec 2016
Posts: 43
F
Fiber Offline OP
Newbie
Fiber  Offline OP
Newbie
F

Joined: Dec 2016
Posts: 43
Thank you for idea, Dalla!
I use manual almost every day and still many good ideas not discovered there for me:)
Also it seems that NumOpenLong and NumOpenShort works well to limit number of trades, but NumOpenTotal doesn't and that's why I went wrong way..

Last edited by Fiber; 07/28/17 20:37.

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