Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Quad, EternallyCurious, 1 invisible), 726 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
limiting number of open trades per asset #459446
05/20/16 12:37
05/20/16 12:37
Joined: Apr 2015
Posts: 26
T
trader6363 Offline OP
Newbie
trader6363  Offline OP
Newbie
T

Joined: Apr 2015
Posts: 26
Hi
Im using the following code to limit only 1 trade open per asset but I have noticed that sometimes two trades are opened for a single asset. Does anyone have any ideas why this is happening or a better way to control number of open trades per asset?

int tradelimit = 1;
int tradecount;
string CurrentAsset;

function run (){
BarPeriod = 1;
LookBack = 60;
Lots = 10;
Hedge = 2;
Stop = 100*PIP;
asset("EUR/USD");
tradecount = 0; //reset trade count
CurrentAsset = Asset;
for (open_trades) if(strstr(Asset,CurrentAsset) and TradeIsOpen) tradecount++; // count number of trades
if (tradecount<tradelimit) enterShort(); // if number of trades is less than trade limit of 1 enter short trade
}

Last edited by trader6363; 05/20/16 12:40.
Re: limiting number of open trades per asset [Re: trader6363] #459448
05/20/16 14:51
05/20/16 14:51
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Hi,
why do not use reverseLong/Short(1)or test NumOpenLong/Short system variable before opening the trade?

Ciao

Re: limiting number of open trades per asset [Re: MatPed] #459450
05/20/16 18:52
05/20/16 18:52
Joined: Apr 2015
Posts: 26
T
trader6363 Offline OP
Newbie
trader6363  Offline OP
Newbie
T

Joined: Apr 2015
Posts: 26
I thought reverseLong/Short was only for reversing trades. How do you use NumOpenLong/Short?
Thanks

Re: limiting number of open trades per asset [Re: trader6363] #459451
05/20/16 21:37
05/20/16 21:37
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Try, but I guess reverseLong(1) could work.

just pseudocode:

if(NumOpenLong == 0) enterLong();
else dosomethingelse;

Re: limiting number of open trades per asset [Re: MatPed] #459483
05/23/16 18:00
05/23/16 18:00
Joined: Apr 2015
Posts: 26
T
trader6363 Offline OP
Newbie
trader6363  Offline OP
Newbie
T

Joined: Apr 2015
Posts: 26
Thanks that was helpful!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1