Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Closing a certain number of lots #453739
08/10/15 14:55
08/10/15 14:55
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
I'm trying to get my script to partially close a trade, that is, to close only a certain number of lots. However, the code below closes all open lots. I used the printf statement to check my work and it confirms that the number (lotsOpen_y - targetLots_y) is less than the total lots open, so I presume there is something syntactically incorrect in my code. Just can't figure out what that might be.

Both variables are type int. The NFA flag is not set.

Code:
if (lotsOpen_y > targetLots_y) { 
			exitLong(0,0,(lotsOpen_y - targetLots_y));
			printf("\nclosing some long y: %d\n", lotsOpen_y - targetLots_y);
		}


Re: Closing a certain number of lots [Re: boatman] #453757
08/11/15 10:38
08/11/15 10:38
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Anyone? I am at a loss to explain what could be causing this!

Re: Closing a certain number of lots [Re: boatman] #453762
08/11/15 12:46
08/11/15 12:46
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
I also do no see anything suspicious in your code - so whatever the problem is, it is not in your 3 posted lines.

Disable the rest of your code until the remainder is a simple script that just opens and closes trades - just like the "TradeTest" script, but with partial closing. Then add the rest code again step by step until partial closing does not work anymore.

Re: Closing a certain number of lots [Re: jcl] #453764
08/11/15 13:38
08/11/15 13:38
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Does your broker support partial closing?

Re: Closing a certain number of lots [Re: DdlV] #453773
08/12/15 00:14
08/12/15 00:14
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Thanks for the replies jcl and DdlV. Clearly its not a simple syntax issue then. jcl, I only posted those three lines in order to find out if the issue was related to them specifically. Clearly I don't expect anyone to identify my problem if it lies outside of that context.

My broker does support partial closing, but I'm only backtesting this script at the moment and haven't tried trading it live.

Let the debug process begin.....

Re: Closing a certain number of lots [Re: boatman] #457010
12/19/15 04:31
12/19/15 04:31
Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
F
Finstratech Offline
Junior Member
Finstratech  Offline
Junior Member
F

Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
boatman, could you elaborate on this partial close bit please? This partial closing has been eluding me to this day.

Specifically the bit concerning the price formula at which to partially close. For example:

exitTrade(MyTrade,0,TradeLots/2); // exit half the trade

Where 0 is price now, but how do I make it at a specific price say at ATR(100)*1 and the other half of the trade at ATR(100)*2?

Any help greatly appreciated

Re: Closing a certain number of lots [Re: boatman] #457494
01/19/16 19:34
01/19/16 19:34
Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
F
Finstratech Offline
Junior Member
Finstratech  Offline
Junior Member
F

Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
boatman, did you figure out what was causing the issue?

Re: Closing a certain number of lots [Re: Finstratech] #457628
01/24/16 23:25
01/24/16 23:25
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
This closes x lots:
Code:
exitLong(0,0,x)



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