NexusFi: Find Your Edge


Home Menu

 





My EL system buys more contracts than needed


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
quaestus
Vilnius, Lithuania
 
Posts: 2 since Jul 2011
Thanks Given: 0
Thanks Received: 0

I have the following code in my trading system which has IntrabarOrderGeneration set to TRUE. The problem is that it occasionally buys 2 contracts or more even if ContractsToBuy is set to true. How is this possible? Is it possible that my orders are delayed and MarketPosition is still equal to 0 on the next tick and I end up sending a duplicate order?

if MarketPosition = 0 AND Close > X then
begin
Buy ("Buy Limit") ContractsToBuy contracts next bar at (VolWAP - BuyTicksBelowVWAP*MinMove/PriceScale) limit;
end;

if MarketPosition = 0 AND Close < X then
begin
Buy ("Buy at Market") ContractsToBuy contracts next bar at market;
end;

Thank you in advance for helping me out with this one


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
CFTC Approves First US Bitcoin Perpetual Futures -- Kals …
Traders Hideout
Fabrication or Framework? Irans Denied MOU Explains the …
Prediction Markets & Event Contracts
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
 
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,580



quaestus View Post
I have the following code in my trading system which has IntrabarOrderGeneration set to TRUE. The problem is that it occasionally buys 2 contracts or more even if ContractsToBuy is set to true. How is this possible? Is it possible that my orders are delayed and MarketPosition is still equal to 0 on the next tick and I end up sending a duplicate order?

if MarketPosition = 0 AND Close > X then
begin
Buy ("Buy Limit") ContractsToBuy contracts next bar at (VolWAP - BuyTicksBelowVWAP*MinMove/PriceScale) limit;
end;

if MarketPosition = 0 AND Close < X then
begin
Buy ("Buy at Market") ContractsToBuy contracts next bar at market;
end;

Thank you in advance for helping me out with this one

I'm a bit confused. I don't use anything like 'ContractsToBuy' in my signals. It isn't a reserved word is it? Just a var you've defined in the strategy, or an input, right? So I am confused on how it could be a boolean (you said "set to true").

In MultiCharts you have the option of imposing a maximum position size, that MC itself will enforce even if your strategy doesn't check on its own.

Personally in my signals I tend to check the CurrentContracts figure (reserved word) so I know what my current position size is before adding to it. As an example, you could do:

condition1 = iff(CurrentContracts < 10, true, false);

This would set condition1 to true if CurrentContracts are less than 10, and false otherwise. Assuming 10 is your max.

Then you could modify the buy condition like so:

if MarketPosition = 0 AND Close > X AND condition1 then

Just as an example.

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 X Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
quaestus
Vilnius, Lithuania
 
Posts: 2 since Jul 2011
Thanks Given: 0
Thanks Received: 0

Thank you very much, Mike. Often when I am stuck with EL, I find help in one of your posts

As regards, ContractsToBuy, it is my mistake in description. ContractsToBuy is an integer in my code. I will try adding the CurrentContracts check.

Anyway, is this a known problem of TS or maybe I simply do not understand this. How is situation when CurrentContracts > 0 and MarketPosition = 0 logically possible?

Thanks


Reply With Quote




Last Updated on November 9, 2011


© 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