Hi I allow multiple entry for my signal. let say i buy this bar at close 4 times at 4 different timing and now my net position is 4.
If I has a code saying sell this bar at close, then it will sell all 4. How do I sell 1 by 1 instead of all 4?
how to exit only one contract for multiple contracts setting [SOLVED]
-
- Posts: 83
- Joined: 18 Mar 2013
- Has thanked: 11 times
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: how to exit only one contract for multiple contracts set
Hi I allow multiple entry for my signal. let say i buy this bar at close 4 times at 4 different timing and now my net position is 4.
If I has a code saying sell this bar at close, then it will sell all 4. How do I sell 1 by 1 instead of all 4?
SELL 1 Contract next bar at market;
-
- Posts: 83
- Joined: 18 Mar 2013
- Has thanked: 11 times
Re: how to exit only one contract for multiple contracts set
Thanks but it don't really work.
I have your code and it don't work
The output is this.
My desired output is at the 1325 bar, instead of cover 3, it should just cover 1 only
I have your code and it don't work
Code: Select all
if (Random(10)>9.9) then begin
if (marketposition>=0) then
buy 1 Contract next bar at market
else if (marketposition<0) then
buy to cover 1 Contract next bar at market;
end;
if (Random(10)<0.1) then begin
if (marketposition>0) then
sell 1 Contract next bar at market
else if (marketposition<=0) then
sellshort 1 Contract next bar at market;
end;
My desired output is at the 1325 bar, instead of cover 3, it should just cover 1 only
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: how to exit only one contract for multiple contracts set
Is this all your code?Thanks but it don't really work.
I have your code and it don't work
::
-
- Posts: 83
- Joined: 18 Mar 2013
- Has thanked: 11 times
Re: how to exit only one contract for multiple contracts set
yes you can try it on your side. and I think you will get the same result.Is this all your code?Thanks but it don't really work.
I have your code and it don't work
::
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: how to exit only one contract for multiple contracts set [SOLVED]
Hi I allow multiple entry for my signal. let say i buy this bar at close 4 times at 4 different timing and now my net position is 4.
If I has a code saying sell this bar at close, then it will sell all 4. How do I sell 1 by 1 instead of all 4?
That's true, adding the number to an order doesn't sell a position 1 by 1. However, you can use the Total keyword for that.yes you can try it on your side. and I think you will get the same result.Is this all your code?Thanks but it don't really work.
I have your code and it don't work
::
For example:
Code: Select all
if (Random(10)>9.9) then begin
if (marketposition>=0) then
buy 1 Contract next bar at market
else if (marketposition<0) then
buy to cover 1 Contract total next bar at market;
end;
if (Random(10)<0.1) then begin
if (marketposition>0) then
sell 1 Contract total next bar at market
else if (marketposition<=0) then
sellshort 1 Contract next bar at market;
end;
Now each sell order closes the oldest long contract (first in, first out). If you want more control over your orders, you can use from entry to specify which entry order should be closed by an order.
- Attachments
-
- scr.09-03-2016 09.52.15.png
- (8.76 KiB) Downloaded 781 times