NexusFi: Find Your Edge


Home Menu

 





Exit open positions based on time


Discussion in EasyLanguage Programming

Updated
      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 11,839 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Exit open positions based on time

  #1 (permalink)
 guppy 
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
Posts: 52 since Aug 2011
Thanks Given: 11
Thanks Received: 8

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;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,207
Thanks Received: 101,599

 
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 the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,207
Thanks Received: 101,599



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 the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 guppy 
Los Angeles, CA
 
Experience: Advanced
Platform: Tradestation
Broker: Tradestation
Trading: ES,HG,GC,YM,Nq,RB,NG
Posts: 52 since Aug 2011
Thanks Given: 11
Thanks Received: 8

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

Started this thread Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,207
Thanks Received: 101,599


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 the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 TRADERRON 
west palm beach
 
Experience: Intermediate
Platform: Jigsaw Daytradr
Trading: nq, mnq, es, mes, cl
Posts: 4 since Mar 2017
Thanks Given: 8
Thanks Received: 20

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

Reply With Quote
  #7 (permalink)
alantilson
Asheville NC
 
Posts: 1 since Mar 2018
Thanks Given: 0
Thanks Received: 0

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




Last Updated on March 25, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts