NexusFi: Find Your Edge


Home Menu

 





Current contract


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,755 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 montanajtt 
Como, Italy
 
Experience: Advanced
Platform: Tradestation, IB
Broker: Tradestation, IB
Trading: ES
Frequency: Daily
Duration: Minutes
Posts: 184 since Aug 2014
Thanks Given: 302
Thanks Received: 312

Hello,

after a couple of months I'm running the strategy today happened that, I think due to several platform disconnections, the strategy continued to send to market closing orders like if it didn't recognize they already were sent before.
So at the end instead of find myself long 1 contract I was long 3 contracts with only 1 contract to close the position at target. (yes I was not there, it happened during the nigh and I was sleeping)

It's the first time it happens but platform disconected several times and I never had this kind of problem before...maybe is due to the fact I'm using the 9.5...

anyway in order to prevent such thing again I was thinking to use some kind of protection but I need help to code the variable...and even if figure out something I still have some doubt if can work...can you help?

vars : cont(0) ;


cont = currentcontract ....I should assign a value to this var consider I have no overnight positions.

if currentcontracts > 1 then begin
sell (currentcontract - cont) contract this bar at close ;
end;

Thanks for your help!


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Friday Update: Markets Now Pricing Fed Rate HIKES as Sta …
Traders Hideout
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
Kalshi Rockets to $22B, Passes Polymarket in Volume -- B …
Prediction Markets & Event Contracts
Q1 2026 Shatters All Derivatives Volume Records -- CME H …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
22 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
5 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


montanajtt,

you might want to look at the GetPositionQuantity reserved word. This will provide you with the position for a symbol and side (long/short) for the account of choice.
As TS says it might have some issues and is processor intensive, you might want to check the GetPosProvQty function. You can obtain it from the official forums.

Regards,
ABCTG


Follow me on X Reply With Quote
  #4 (permalink)
 montanajtt 
Como, Italy
 
Experience: Advanced
Platform: Tradestation, IB
Broker: Tradestation, IB
Trading: ES
Frequency: Daily
Duration: Minutes
Posts: 184 since Aug 2014
Thanks Given: 302
Thanks Received: 312


ABCTG View Post
montanajtt,

you might want to look at the GetPositionQuantity reserved word. This will provide you with the position for a symbol and side (long/short) for the account of choice.
As TS says it might have some issues and is processor intensive, you might want to check the GetPosProvQty function. You can obtain it from the official forums.

Regards,
ABCTG


Hi ABCTG,

yes defenitely this can be a solution.

Thank you


Started this thread Reply With Quote




Last Updated on August 7, 2014


© 2026 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 - Downloads - Top
no new posts