Exit open positions based on time - futures io
futures io futures trading



Exit open positions based on time


Discussion in EasyLanguage Programming

Updated by alantilson
      Top Posters
    1. looks_one Big Mike with 3 posts (3 thanks)
    2. looks_two guppy with 2 posts (0 thanks)
    3. looks_3 TRADERRON with 1 posts (0 thanks)
    4. looks_4 alantilson with 1 posts (0 thanks)
    1. trending_up 9,287 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 6 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,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
 

Exit open positions based on time

(login for full post details)
  #1 (permalink)
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
 
Posts: 52 since Aug 2011
Thanks: 11 given, 8 received

in the following easylanguage code why doesnt this seem to exit all open positions?

if time > 1255 then
begin
sell 1 contracts next bar at market;
buytocover 1 contracts next bar at market;
end;

Reply With Quote

Can you help answer these questions
from other members on futures io?
Setting up an alert on a Gartley study
Traders Hideout
Scan by comparing SMAs within 5 mins
ThinkOrSwim
Is your daily return predetermined?
Psychology and Money Management
Cumulative Bid/Ask Chart resets after 2Billion
MultiCharts
Thinkorswim poor order execution?
Brokers
 
 
(login for full post details)
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 48,913 since Jun 2009
Thanks: 31,587 given, 94,552 received

 
Thread Moved


Moved to EasyLanguage Programming

Thread also renamed from "Easylanguage code" to "Exit open positions based on time". Please help keep futures.io (formerly BMT) organized by using descriptive thread titles.



When creating a new thread, note which subforum you are in. Here is a short list of suggestions:

- Topic: Anything to do with an Elite indicator -> Subforum: The Elite Circle
- Topic: Looking for an existing indicator, or how-to use an indicator -> Subforum: (the platform)
- Topic: Programmer needing help with non-Elite indicator -> Subforum: (the platform) - Programming
- Topic: Want an indicator created/modified -> Reply to "Want indicator created free" in Elite Circle
- Topic: Vendors (trading rooms, commercial indicators) -> Subforum: Vendors/Product Reviews
- Topic: Discussion of Forex or Currency trading -> Subforum: Forex and Currency Trading
- Topic: Journals of your trading -> Subforum: Trading Journals or Elite Trading Journals
- Topic: General trading related discussions -> Subforum: Traders Hideout
- Topic: Discussion of a trading method -> Subforum: Traders Hideout
- Topic: Automated Trading -> Subforum: Elite Automated Trading

Last, any Elite Member may create more or less any of these topics in The Elite Circle at your own discretion (your support is appreciated).

This is just a short general list and doesn't cover everything. If you are unsure where to create your new thread, just create it in Traders Hideout and a moderator will move it if necessary.

-- Big Mike Trading


We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 48,913 since Jun 2009
Thanks: 31,587 given, 94,552 received



guppy View Post
in the following easylanguage code why doesnt this seem to exit all open positions?

if time > 1255 then
begin
sell 1 contracts next bar at market;
buytocover 1 contracts next bar at market;
end;


Try something like

 
Code
if MarketPosition <> 0 and time > 1255 then begin

  if MarketPosition = 1 then Sell All Contracts Next Bar At Market;
  if MarketPosition = -1 then Buytocover All Contracts Next Bar At Market;

end;
You need to also be sure you've added code to your signal to prevent new entries from triggering after this time.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
The following 2 users say Thank You to Big Mike for this post:
 
(login for full post details)
  #4 (permalink)
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
 
Posts: 52 since Aug 2011
Thanks: 11 given, 8 received

Thanks BigMike. Was there something flawed in my original code though?

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Site Administrator
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 48,913 since Jun 2009
Thanks: 31,587 given, 94,552 received


guppy View Post
Thanks BigMike. Was there something flawed in my original code though?

Your original code does not take into consideration what I posted/stated.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #6 (permalink)
west palm beach
 
Experience: None
Platform: TRADESTATION
Trading: EMINI ES
 
Posts: 1 since Mar 2017
Thanks: 6 given, 0 received

My first post.....this old thread helped with my venture into writing code....thx.

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Asheville NC
 
 
Posts: 1 since Mar 2018
Thanks: 0 given, 0 received

Is your issue that you are trying to close multiple contracts? You should be able to just eliminate the "1 contracts" bit from each line in your code. This is assuming that sell won't sellshort and buytocover won't buy, which is my understanding.
Alan

if time > 1255 then
begin
sell next bar at market;
buytocover next bar at market;
end;

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Exit open positions based on time


March 25, 2018


Upcoming Webinars and Events
 

Introducing Edge Pools: Prop Pricing Model w/Edge Clear

Jul 9
 

Every journal equals ten meals for the hungry

Now
     



Copyright © 2020 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