Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 1,290 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Exiting a specific trade #446395
10/13/14 19:51
10/13/14 19:51
Joined: Sep 2014
Posts: 24
M
mustang Offline OP
Newbie
mustang  Offline OP
Newbie
M

Joined: Sep 2014
Posts: 24
------- The documentation below -------------
exitTrade (TRADE* trade, var price, int lots)
Exits a particular trade at market or at a given price limit.
Parameters:
algo Optional algorithm identifier of the trade, or 0 for the current Algo, or "*" for exiting all open trade positions with the current asset regardless of their identifiers.
trade The patricular trade to be closed.
-------------- My question below ------------
Could someone please post an example of code for achieving this?
I have multiple assets and I want to exit a specific asset under specific conditions. Example: Exit USD/JPY of size 1 but keep USD/JPY of size 2 open.

Last edited by mustang; 10/13/14 20:08.
Re: Exiting a specific trade [Re: mustang] #446413
10/14/14 13:28
10/14/14 13:28
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
The simplest way is enumerating all open trades and closing the trades that fulfil the condition, like this:

Code:
for(open_trades) {
   if(TradeAsset == "USD/JPY" and TradeLots == 1)
      exitTrade(ThisTrade);
}


Re: Exiting a specific trade [Re: jcl] #446416
10/14/14 16:31
10/14/14 16:31
Joined: Sep 2014
Posts: 24
M
mustang Offline OP
Newbie
mustang  Offline OP
Newbie
M

Joined: Sep 2014
Posts: 24
Thank you very much JCL and Zorro team, I love the simplicity!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1