How to gradually close a position? - futures io
futures io futures trading



How to gradually close a position?


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one irriss with 8 posts (1 thanks)
    2. looks_two ABCTG with 6 posts (1 thanks)
    3. looks_3 dimitri with 3 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 6,394 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 17 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to gradually close a position?

(login for full post details)
  #1 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

Hi guys,

After couple years of searching I am completely confused. Does Easy Language allow to close a position gradually?

Let say I sold 15 contracts using the comand

sellshort 15 contracts this bar on close;

Now I want gradually close this position.

Unfortunately, seems that can can partially close position only one time!

After I do

buytocover 3 contracts this bar on close;

and 12 contracts still open, all further buytocover requests are ignored.

There is note regarding this in the documentation:

Exit orders do not pyramid. Once the exit criteria are met and the exit order filled, the order is ignored for that position
until the position is modified (that is, more shares/ contracts are sold or a new short position is established).


But what to do if I dont want to increase the position?

Thanks

Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(152 thanks from 29 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(110 thanks from 31 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 15 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received


What platform are you using? Multicharts, Tradestation or something else?

Regards,
ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #4 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

It should not really matter.

I am using OEC

Reply With Quote
 
(login for full post details)
  #5 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

There is a difference in the platforms and you can use different code between TS and MC for example. For OEC I don't know, but if you post your code (not only the two lines from the first post) you are using for the exits I can give it a try.

I posted an example here that might help you.
Regards,
ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #6 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

Thanks ABCTG,

In your example there are two different closing signals. That's why they work.

This is the surrogate example. Hope the idea is clear. You may need to adjust it or find appropriate instrument. It executes only one exit, instead of three.

 
Code
                            
vars:     i(0), 

        
p(0);

if(
i=0then
begin
    buy 15 contracts this bar on close
;
    
CurrentAsk;
    
i+0.1;
end
else
begin
    
if(CurrentAsk>p-ithen
    begin
        sell 5 contracts total this bar on close
;
        
i+0.1;
    
end;
end 

Reply With Quote
 
(login for full post details)
  #7 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

irriss,

I don't think you can avoid using more than one exit in your situation. This would concur with what you posted from the documentation. What is the problem with having several exit orders and making sure they get executed when you want?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #8 (permalink)
Athens - Greece
 
Experience: Intermediate
Platform: Metastock
 
Posts: 76 since Jul 2010
Thanks: 202 given, 36 received

Hi, i have seen from a friend of mine this logic ... it is for MT4 ... and it was using a composite logic, with simultaneous moving of Stop Loss levels ... over the partial close ... the site is : Algorithmic Experts | Home
Hope it helps ...
Best Regards - Dimitri

Reply With Quote
 
(login for full post details)
  #9 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

I tried that. The problem that the signal name cannot be dynamic.

I can do like

Sellshort ("sig1") 5 contracts this bar on close
Sellshort ("sig2") 5 contracts this bar on close
Sellshort ("sig3") 5 contracts this bar on close


but I cannot generate signal name from a variable.

In my case it has to be dynamic. I dont know how many exit signal I will need at runtime.

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received



dimitri View Post
Hi, i have seen from a friend of mine this logic ... it is for MT4 ... and it was using a composite logic, with simultaneous moving of Stop Loss levels ... over the partial close ... the site is : link Algorithmic Experts | Home[/url]
Hope it helps ...
Best Regards - Dimitri

Yeah, in MT4 it is possible. You need to play with individual orders and it is very flexible.

Thanks

Reply With Quote
The following user says Thank You to irriss for this post:
 
(login for full post details)
  #11 (permalink)
Athens - Greece
 
Experience: Intermediate
Platform: Metastock
 
Posts: 76 since Jul 2010
Thanks: 202 given, 36 received

Hi, again ... what i have seen working has 4 levels of partial position close .... and possibility to move for each level ... the stop loss ...
Thanks
Dimitri

Reply With Quote
 
(login for full post details)
  #12 (permalink)
Athens - Greece
 
Experience: Intermediate
Platform: Metastock
 
Posts: 76 since Jul 2010
Thanks: 202 given, 36 received


irriss View Post
Yeah, in MT4 it is possible. You need to play with individual orders and it is very flexible.

Thanks

You can try with them if they can do it for you ... according your specifications ...
just a thinking -- Thanks
Dimitri

Reply With Quote
 
(login for full post details)
  #13 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

I am afraid but that won't work with Easylanguage.


irriss View Post
I tried that. The problem that the signal name cannot be dynamic.

I can do like

Sellshort ("sig1") 5 contracts this bar on close
Sellshort ("sig2") 5 contracts this bar on close
Sellshort ("sig3") 5 contracts this bar on close


but I cannot generate signal name from a variable.

In my case it has to be dynamic. I dont know how many exit signal I will need at runtime.


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #14 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

Actually I found very strange thing.

If you execute my example.

 
Code
                            
vars:   i(0), 

        
p(0);

if(
i=0then
begin
    buy 15 contracts this bar on close
;
    
CurrentAsk;
    
i+0.1;
end
else
begin
    
if(CurrentAsk>p-ithen
    begin
        sell 5 contracts this bar on close
;
        
i+0.1;
    
end;
end 
It will close the position partially and some part of the position remains open. (this is correct)





However, if you add keyword total it will do exactly as I want - perform multiple exit.

sell 5 contracts total this bar on close;

But, at the end there is an open position! Could you run it on your platform and confirm whether it is bug in OEC or unclear logic of EL?




Reply With Quote
 
(login for full post details)
  #15 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

In Multicharts your code with total added to the exit only exits 5 contracts once.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #16 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

Thanks, ABCTG!

So there is no difference with or without total keyword?

Reply With Quote
 
(login for full post details)
  #17 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Yes, at least in MC there is none.


irriss View Post
Thanks, ABCTG!

So there is no difference with or without total keyword?


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #18 (permalink)
Singapore
 
 
Posts: 8 since Dec 2013
Thanks: 1 given, 1 received

Yes, I checked myself also in MC.

It is a bug (or unexpected behavior) in OEC.

Thanks for your great help, ABCTG!

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > How to gradually close a position?


Last Updated on December 5, 2013


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Identifying Setups & Targets Using Profile Charts w/Trevor & Tradovate

Feb 25
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts