NexusFi: Find Your Edge


Home Menu

 





Strategy is sending orders but they’re canceled immediately, why? No broker side prob


Discussion in MultiCharts

Updated
    1. trending_up 5,872 views
    2. thumb_up 13 thanks given
    3. group 4 followers
    1. forum 26 posts
    2. attach_file 6 attachments




 
Search this Thread

Strategy is sending orders but they’re canceled immediately, why? No broker side prob

  #11 (permalink)
 ocpb 
Hartford CT, USA
 
Experience: Beginner
Platform: None
Trading: ES
Posts: 126 since Jan 2015
Thanks Given: 152
Thanks Received: 125


Dvdkite View Post
So looking at those 2 simple conditions do you think that is there no time for a limit order to be filled before any of those 2 conditions are denied?
I'm carefully examinating all of your suggestions and also the suggestions of Henry multicharts in the MC forum and I'm starting with this.

So what do you think about the code above?
If you look ad the image of the missed trade (posted yesterday) you can see that the short limit order was at 11268 short and the bar where the order should have been executed had a HIGH of 12269,5 and it means 3 tick higher (you cannot see exaclty from the image, I checked now the exact value) so it would have been executed for sure and also I saw that in real time in front of my eyes.
By examinating this behaviour there was enough time to send the order and execute it BEFORE any condition change... or am I missing something?

I think it seems possible, with the close price changing on every tick in IOG mode, for price to sneak above some arbitrary level, trigger a limit to be sent, and then tick back down while your market position is still flat, causing a cancel before the limit order is filled. And for this same thing to easily happen several times in succession...which is what your order history looked like to me.



Dvdkite View Post
About this I have a question: is there a way to let the order LIVE till the end of the bar when the conditions are met for the first time?
I mean.. is there a way to send the order at first time that conditions are met and then DO NOT CANCEL IT before the end of the bar? (Leaving IOG true of course)....
This could potentially solve the issue....

Yes exactly, you can set a boolean variable when your price conditions have been met and the limit is first sent. Use this flag as part of your conditions to keep alive the limit order. Remember to clear it once your market postition is no longer flat, or when your reasons for wanting to enter the market are no longer applicable (such as at the end of the bar, you can check that the BarStatus indicates the closing tick of the bar.)



Dvdkite View Post
Unfortunately (but it is a good thing eh eh ) my strategy usually do an average of 15 operations per month so it would not so quick to see how orders will be processed live on paper trading broker....This morning in front of my eyes I saw another positive operations of the system just 5 minutes before I setted up a new workspace for the paper trading...

I understand that your strategy uses previous days' levels to choose one very specific condition that happens infrequently...
and you want to make sure you have some code that reliably works with how Multicharts requires it.

So in that case, maybe just for the sake of testing it, you might create a version of your strategy with entry conditions that happen more often, like maybe referencing a price level that occurred within the last 30 minutes instead of something fixed on the previous day. And I'd again advise adding more logging to the entry logic section, even for things you *know* will not change.



Dvdkite View Post
Of course I'll never know for SURE. But yesterday and today I was on the screen and I can assure that the limit orders would have been filled because the price goes over my limit order conditions as specified above.
How it is possible to have dozen of orders filled if the order is sent only when market position = 0? Is such an issue possible?

I'm using just 1 contract... not more.

I don't mean to reference your specific code here too closely, I'm only generally trying to emphasize the fact that deploying live strategies is not unlike deploying any production software for the first time. The things that go wrong are often those that you'd least expect. From many people's experiences, at least that I've read here, strategy development has it's own psychology, and patience to get things right is a big element of people's success.

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
 
  #12 (permalink)
 ocpb 
Hartford CT, USA
 
Experience: Beginner
Platform: None
Trading: ES
Posts: 126 since Jan 2015
Thanks Given: 152
Thanks Received: 125


Dvdkite View Post
Shall I also modify the symbol mapping of the #XG iqfeed ( DAX ) to use the paper broker for execution?

Because I alredy use #XG iq feed for chart data and DDM19 CQG for order routing.... and I need that for the real money live strategy test...

You might have to map that to a real symbol like DDM19 to work correctly, I've seen that recommended with other continuous contract scenarios. But if so, I'm just guessing that there would not be any conflict with your live tests.

Reply With Quote
Thanked by:
  #13 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


David,

the Paper Trading Account will use its own symbol mapping, there shouldn't be any conflicts in two different accounts.

Regards,

ABCTG


Dvdkite View Post
Just a quick question about paper trading.

Shall I also modify the symbol mapping of the #XG iqfeed ( DAX ) to use the paper broker for execution?

Because I alredy use #XG iq feed for chart data and DDM19 CQG for order routing.... and I need that for the real money live strategy test...

Thanks,

David


Follow me on Twitter Reply With Quote
Thanked by:
  #14 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


ABCTG View Post
David,

the Paper Trading Account will use its own symbol mapping, there shouldn't be any conflicts in two different accounts.

Regards,

ABCTG

Hello ABCTG,

today I just opened my computer and I've found an unexecuted trade in the paper trading workspace (I left the strategy running with automation with the paper broker). As you can see the strategy has tried to send the order a lot of times...

I had similar problem with CQG (this problem was the first one, before the cancelation problem related to this theread) and I solved it by setting the lookup account in the strategy properties tab and after that it is correctly showing "DAY" under the TIF column.
The paper trading orders are showing GTC under the TIF column... could that be the case?



Thanks

David

Reply With Quote
  #15 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


ocpb View Post
I think it seems possible, with the close price changing on every tick in IOG mode, for price to sneak above some arbitrary level, trigger a limit to be sent, and then tick back down while your market position is still flat, causing a cancel before the limit order is filled. And for this same thing to easily happen several times in succession...which is what your order history looked like to me.

Yes exactly, you can set a boolean variable when your price conditions have been met and the limit is first sent. Use this flag as part of your conditions to keep alive the limit order. Remember to clear it once your market postition is no longer flat, or when your reasons for wanting to enter the market are no longer applicable (such as at the end of the bar, you can check that the BarStatus indicates the closing tick of the bar.)

Ok yesterday I was examinating how to perform this. Of course a boolean would be a solution but before try that I was thinking about a simpler solution and I would like to know your thoughts. This is the piece of code of interest


 
Code
if 
     // HERE there are some simply logic ( example H[5] > level.... ) calculated on the 6 previous bars OHLC values
     // and those are IN THE PAST so they CAN'T CHANGE -----> So they cannot be responsibile of a sudden change in
     // conditions....

and Price >= oYesterdaysTPOVALow and Price - oYesterdaysTPOVALow <= 10   // ***
	then begin
		EntryMode = 8;   // I have different entry cases... this is just the one I'm talking about here
		sellshort("Bear SE 8") 1 contract next bar at oYesterdaysTPOVALow + 3 limit;
		canPrintEntryprice = true;
	
	end else
As you said the fluctuation over and below oYesterdaysTPOVALow could be caused just by this piece of code

 
Code
 Price >= oYesterdaysTPOVALow
because price (of the current bar = price[0] ) can go over/under many times before the 5 minutes bar end. So in order to have the order placed the first time that the price goes over the level I can simply take as reference the HIGH value of the bar instead of the PRICE .... by this way the first time that the price will go OVER the level then the following comparison

 
Code
 H >= oYesterdaysTPOVALow
will be TRUE during ALL the actual Bar (because H could be higher but now lower then the max value reached inside the bar) and it should keep the order LIVE without cancel it (of course till Price - oYesterdaysTPOVALow <= 10 but there's enough space of time to execute the trade.. and probably Price - oYesterdaysTPOVALow <= 10 would be useless as it will never be false before the order has been filled).

I just quick tried a backtest from december till today and entries and results are the same ( the total difference in 65 trade is 37$ so nothing) so it didn't modified the strategy behaviour.

So could it be a simpler ed effective solution rather than implement a boolean control?

Thanks again in advance for every further reply :-D

David

Reply With Quote
  #16 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

David,

the cancellations are coming from the code as you elaborated in your next post and not from the Time in Force setting.

Regards,

ABCTG


Dvdkite View Post
Hello ABCTG,

today I just opened my computer and I've found an unexecuted trade in the paper trading workspace (I left the strategy running with automation with the paper broker). As you can see the strategy has tried to send the order a lot of times...

I had similar problem with CQG (this problem was the first one, before the cancelation problem related to this theread) and I solved it by setting the lookup account in the strategy properties tab and after that it is correctly showing "DAY" under the TIF column.
The paper trading orders are showing GTC under the TIF column... could that be the case?



Thanks

David


Follow me on Twitter Reply With Quote
Thanked by:
  #17 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


ABCTG View Post
David,

the cancellations are coming from the code as you elaborated in your next post and not from the Time in Force setting.

Regards,

ABCTG



Hello Abctg,

this time they are not cancelation but rejections.
And this print comes from YESTERDAY afternoon paper trading and the modifications that I've done has bern done TODAYMorning only.

The First time I got something REJECTED was for tr TIF that's why I'm asking what is GTC.

About my other post where I put HIGH value insted of Price value do you think it's a good solution to avoid the order cancelatin?

Thanks

David

Reply With Quote
  #18 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

David,

I did not see that on the image. The rejections are usually not caused by the code and you should be able to find an explanation on the logs or alert tab.

Regards,

ABCTG


Dvdkite View Post
Hello Abctg,

this time they are not cancelation but rejections.
And this print comes from YESTERDAY afternoon paper trading and the modifications that I've done has bern done TODAYMorning only.

The First time I got something REJECTED was for tr TIF that's why I'm asking what is GTC.

About my other post where I put HIGH value insted of Price value do you think it's a good solution to avoid the order cancelatin?

Thanks

David


Follow me on Twitter Reply With Quote
Thanked by:
  #19 (permalink)
 ocpb 
Hartford CT, USA
 
Experience: Beginner
Platform: None
Trading: ES
Posts: 126 since Jan 2015
Thanks Given: 152
Thanks Received: 125


Dvdkite View Post

 
Code
 H >= oYesterdaysTPOVALow
So could it be a simpler ed effective solution rather than implement a boolean control?

Nice idea, definitely simpler and that is always a good thing.

What I'd recommended is just an idea to possibly generalize things. It could be a re-usable if you were planning on writing other very different strategies that use limit orders to enter.

Reply With Quote
Thanked by:
  #20 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


David,

is using High for Price really a fix and more important doing what you want your code to do or will this just reduce the cancellations while still allowing orders getting cancelled? From the code snippet you will probably still have situations where an order gets triggered and cancelled on the next tick (or before getting filled) as the high moves higher. The order would then not get re-issued again for that bar as the bar's high can only move higher.
If you want the order to remain uncancelled a flag would be the way to go.
 
Code
Price >= oYesterdaysTPOVALow and Price - oYesterdaysTPOVALow <= 10
Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on May 2, 2019


© 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