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
Buy ("Buy Limit") ContractsToBuy contracts next bar at (VolWAP - BuyTicksBelowVWAP*MinMove/PriceScale) limit;
if MarketPosition = 0 AND Close < X then
Buy ("Buy at Market") ContractsToBuy contracts next bar at market;
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:
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.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.