NexusFi: Find Your Edge


Home Menu

 





My EL system buys more contracts than needed


Discussion in EasyLanguage Programming

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




 
Search this Thread

My EL system buys more contracts than needed

  #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?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
16 thanks
My NQ Trading Journal
14 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #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,212
Thanks Received: 101,599



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 Twitter 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


© 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