Gamestudio Links
Zorro Links
Newest Posts
Removing outliers from files
by AndrewAMD. 12/02/26 15:26
SGT_FW
by Aku_Aku. 11/30/26 08:19
Experiences with cTrader
by JeyKey II. 11/27/26 09:04
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (EvanTJ), 6,200 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 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 | 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