Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
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, Ayumi, Quad, PeWi), 488 guests, and 6 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
Close All Trades (Long and Short) #480840
07/18/20 02:14
07/18/20 02:14
Joined: Jun 2019
Posts: 24
Q
Qw3rty Offline OP
Newbie
Qw3rty  Offline OP
Newbie
Q

Joined: Jun 2019
Posts: 24
I am wanting to hedge my positions using a single asset (Hedge = 2;)

Is there a way to close all trades (both long and short) when a certain condition is met.

I have tried the following with the "if statement" on the outside as well.
for(open_trades)
{
if(condition)
exitLong();
exitShort();

}

This seems to only close long trades.

I read on the forum about using the tick() function but no luck either.

I have tried using functions like a portfolio but no luck.

Any ideas?

Re: Close All Trades (Long and Short) [Re: Qw3rty] #480841
07/18/20 07:44
07/18/20 07:44
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
for(open_trades)
{
if(condition){
exitLong();
exitShort();
}
}

Re: Close All Trades (Long and Short) [Re: danatrader] #480846
07/18/20 10:46
07/18/20 10:46
Joined: Jun 2019
Posts: 24
Q
Qw3rty Offline OP
Newbie
Qw3rty  Offline OP
Newbie
Q

Joined: Jun 2019
Posts: 24
Originally Posted by danatrader
for(open_trades)
{
if(condition){
exitLong();
exitShort();
}
}


This is awesome, thanks for the update. That makes sense.

Re: Close All Trades (Long and Short) [Re: Qw3rty] #480854
07/19/20 11:21
07/19/20 11:21
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
so, i thinking this:
Code
for(open_trades)
{
if(condition){
exitLong();
exitShort();
}
}


is the same like
Code
if(condition){
exitLong();
exitShort();
}


Exits all long or all short trades that match the given filter condition (see below), at market or at a given price limit, until the given number of lots is closed.

Re: Close All Trades (Long and Short) [Re: Qw3rty] #480864
07/20/20 09:17
07/20/20 09:17
Joined: Jun 2019
Posts: 24
Q
Qw3rty Offline OP
Newbie
Qw3rty  Offline OP
Newbie
Q

Joined: Jun 2019
Posts: 24
Just tested and can confrim the output is th same with either choice of code. No need for a loop then.


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