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,877 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

  #1 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25



Hello Everyone,

I’m TRYING to go live with my strategy with multicharts but I already had problems with sending my orders.
Yesterday My orders were rejected for missing TIF… then I found the solution on MC forum and I made the correct broker lookup setting.
The problem comes TODAY when my strategy tryed to send a limit order on the DAX and it has been canceled, then the strategy tryed again many time and always with the same results then I stopped the automatic trading…

Do you have any Idea on what is the problem

I made all the setup. The symbol settings is ok. I have an order number so the order is sent to the broker and AMP confirmed that on their side there are no problems so it must be the strategy?? But why?? With simulation it works fine and it proceed the order.
Any help would be appreciated.

Just to know. Today and yesterday operation would have been a good gain and I’m so disappointed to lost them ( It coud have been a good start).

Thanks.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Dvdkite,

does this also happen in simulated forwarded testing with the strategy automation enabled? If it does, it's likely a coding problem and without seeing the code that generates the orders it would be hard to tell more.
Debugging the real time behavior could be the next step - check the bar status for the data streams that your code gets computed on and track down if the orders could be cancelled by the bar status being negative for example.

Regards,

ABCTG

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



ABCTG View Post
Dvdkite,

does this also happen in simulated forwarded testing with the strategy automation enabled? If it does, it's likely a coding problem and without seeing the code that generates the orders it would be hard to tell more.
Debugging the real time behavior could be the next step - check the bar status for the data streams that your code gets computed on and track down if the orders could be cancelled by the bar status being negative for example.

Regards,

ABCTG

Hello ABC,

BTW: This is just an example of the entry order code in my strategy (Multicharts):

 
Code
then begin
	EntryMode = 8;
	sellshort("Bear SE 8") 1 contract next bar at oYesterdaysTPOVALow + 3 limit; //stop oYesterdaysTPOVAHigh - 3 limit;
	canPrintEntryprice = true;

end else
and the exit is also very simple, if a condition is met then

 
Code
buytocover("Bear SX8") 1 contract next bar at market;
and I also have IOG enabled.

About the "simulated forwarded testing with the strategy automation enabled" I'm honestly not sure about what this is.

To test it I usually leave the strategy on the chart without the "SA" ( automation disabled ) and it performs trades in real time and during past months they all match the backtest on historical data.

I know that it's hard to tell without see the strategy but what other pieces of part of it should I post here (without post all the strategy logic?)?

Many thanks,

David

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

David,

you can use the strategy automation on the Paper Trading account that is built-in within Multicharts.

I am afraid without seeing the code one could only guess, but you might get more help from the futures.io community if you post full working code (and a workspace using your settings) that can demonstrates the exact behavior and can be used to reproduce the issue. This does not mean revealing your entire logic, as you can replace parts of the code with something else of course, as long as the code exhibits the same behavior.

Regards,

ABCTG

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


ABCTG View Post
David,

you can use the strategy automation on the Paper Trading account that is built-in within Multicharts.

I am afraid without seeing the code one could only guess, but you might get more help from the nexusfi.com community if you post full working code (and a workspace using your settings) that can demonstrates the exact behavior and can be used to reproduce the issue. This does not mean revealing your entire logic, as you can replace parts of the code with something else of course, as long as the code exhibits the same behavior.

Regards,

ABCTG


Hello ABCTG,

Ok I removed the code entry logic and some other parts BUT the case entry that you can see here is the case of this morning and after the code you can see the trade that SHOULD HAVE BEEN DONE:

 
Code
// .................Variable definitions

// Calculate BIAS for the start of the day.. 

if time > 0810 and time < 0911  then begin	
if OpenD(0) > oYesterdaysTPOVAHigh then BIAS = 2;
if OpenD(0) < oYesterdaysTPOVAHigh and OpenD(0) > oYesterdaysTPOVALow then BIAS = 1;
if OpenD(0) < oYesterdaysTPOVALow then BIAS = 0;
	
//print("-----Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"---> day open is ", NumToStr(OpenD(0),2));
				
end; 

if time = Time_CLOSE_SESSION then BIAS = 99; // reset di sicurezza evitiamo di operare e fallare i back test usando bias precedenti


// Fixed Stop loss	
setstoploss( Stoploss * bigpointvalue);

//Time frame of the day where entries are allowed
isTheRightTime = ( time >= Time_MorningStart_at and time <= Time_MorningStop_at) or ( time >= Time_AfternoonStart_at and time <= Time_AfternoonStop_at);
 
 
// INTRADAY changes of BIAS if allowed

if BIAScanChangeIntraday then begin
	
	// Here I change the daily BIAS only if there were not trade and some conditions are met
	
end;	
		     
 	     
 	     
if marketposition = 0 and isTheRightTime and (( positionprofit(1) < 0 and EntriesToday(Date) > 0 ) = false)
then begin

	EntryMode = 0;
	SEprotection = false;
	LEprotection = false;
	canPrintEntryprice = false;
	
	// SOME OTHER ENTRY CASES REMOVED..............
	
	if BIAS = 0 and  // THIS IS YESTERDAY CASE 
	
	// some more code conditions
	
	Price >= oYesterdaysTPOVALow and Price - oYesterdaysTPOVALow <= 10
	then begin
		EntryMode = 8;
		sellshort("Bear SE 8") 1 contract next bar at oYesterdaysTPOVALow + 3 limit; //stop oYesterdaysTPOVAHigh - 3 limit;
		canPrintEntryprice = true;
	
	end;
	
end;
if marketposition = -1 then begin
	
	//if openpositionprofit >= gainProtectionTriggerTicks * bigpointvalue then SEprotection = true;
	if entryprice - Price >= gainProtectionTriggerTicks then SEprotection = true; // con questo guadagna pi che con openprofit.. misteroZ
	 
	switch(EntryMode)
	begin 
		case 8: begin
			 	if canPrintEntryprice then begin 
			 		if printDebug then print("n. ",NumToStr(totaltrades + 1,0)," -----Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"-------> SHORT SE 8 at ", NumToStr(entryprice,2),NewLine);
				 	canPrintEntryprice = false;
				end;

			 	if Price <= oYesterdaysTPOVALow - ( ( oYesterdaysTPOVAHigh - oYesterdaysTPOVALow ) / 2 ) then begin
			 		
			 		buytocover("Bear SX8") 1 contract next bar at market;
			 		EntryMode = 0;
			 		if printDebug then print("  yVAL = ", NumToStr( oYesterdaysTPOVALow ,0 ),newline);
			 		if printDebug then print("------Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"------> BEAR SX8 at ", NumToStr(entryprice,2),
			 		" -- TRADE exit around --> ", NumToStr( price, 2), NewLine); 
			 	end;
			 	
			 	// Alternative exit in case of congestion before an up trend ---> controllando 6 barre non male... pure 4 ... fai test
			 	if H[4] > oYesterdaysTPOVALow and H[3] > oYesterdaysTPOVALow and H[2] > oYesterdaysTPOVALow and H[1] > oYesterdaysTPOVALow and 
			 	      L[4] < oYesterdaysTPOVALow and L[3] < oYesterdaysTPOVALow and L[2] < oYesterdaysTPOVALow and L[1] < oYesterdaysTPOVALow and 
			 	   price < oYesterdaysTPOVALow - 5
			 	then begin
			 		
			 		buytocover("Bear SX8 protect") 1 contract next bar at market;
			 		EntryMode = 0;
			 		if printDebug then print("  yVAL = ", NumToStr( oYesterdaysTPOVALow ,0 ),newline);
			 		if printDebug then print("-----Data ",FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," --Time ",NumToStr(time,0),"-------> FLAT SX4 at ", NumToStr(entryprice,2),
			 		" -- TRADE exit around --> ", NumToStr( price, 2), NewLine);
			 	end;
		 
			 end;
		
	if SEprotection then buytocover("SE Protection") 1 contract next bar at entryprice - minTickOfGain stop;
		
	end;

	if time >= Time_CLOSE_SESSION and time  < 2200  then buytocover("SE CLOSE SESSION") 1 contract next bar at market;

end;
This is the trade that gave me the error in REAL automated trading:



Is it enough the piece of code posted?

As you can see the trade is in the 9:05 bar of 5minutes chart... just 3 tick after that orange level on there should have been a limit short at 12268. I was wondering how much time does an order stay in the market before MC cancel it...
Any idea would be appreciated I really need to have this strategy live after so much work and study ...

Thanks again,

David

Reply With Quote
  #6 (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
I was wondering how much time does an order stay in the market before MC cancel it...
Any idea would be appreciated I really need to have this strategy live after so much work and study ...

Thanks again,

David

Hi Dvdkite, there's no set time amount. Multicharts submits limit orders as long as your conditions are met, and cancels them immediately when your condition is no longer met.

As @ABCTG wrote, the built-in paper trading broker is the way to go -- it will actually use MC's full internal order logic.

We can't tell anything by the order you showed us on the chart. That is the same as a regular backtest that approximates and obscures many real execution issues.

You have debugging statements in your code -- great -- but none of them are in the entry logic section (when marketposition = 0). And that is where I think you need some to solve this. Print out on each bar the if the entry limit should be effective in the market or not. Maybe this will show that you have the conditions but they are false on the next bar, and then set on then following bar, and so on.

Simplify your entry conditions -- see if you can get any limit orders at all to remain in the market under your control.

Lastly, definitely use the "paper trading" broker mode with automation enabled. Verify your strategy thoroughly with it.


Dvdkite View Post
Today and yesterday operation would have been a good gain and I’m so disappointed to lost them ( It coud have been a good start).

IMO you just can't know for real if the strategy would have been profitable yesterday. In fact it might be great news that these orders were cancelled -- What if you had dozens filled in under one minute? Imagine having to scramble with the MC DOM to cancel them all quickly.

As you probably know there is awesome advice on FIO on the process of developing a live strategy. If the strategy performs, you won't care that you waited extra time to deploy it.

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

David,

@ocpb posts is giving you some great advice. Since you are dealing with intrabar order generation keep in mind that the next tick could potentially invalidate your entry conditions again and in turn the strategy engine will cancel the order again. Besides that any of the other points that Henry mentioned here can also lead to orders getting cancelled:
https://www.multicharts.com/discussion/viewtopic.php?t=51981

Regards,

ABCTG

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


ocpb View Post
Hi Dvdkite, there's no set time amount. Multicharts submits limit orders as long as your conditions are met, and cancels them immediately when your condition is no longer met.

Hi ocpb and thanks for your suggestions.
Ok so my entry conditions are based on the OHLC values of the previous 6 bars (from [1] to [6] and those are in the past so they CAN'T change my conditions as the past can't change eheh ) and then in the BAR [0] (so now during the last bar on chart formation) I'm checking if the price is under a level (it's a price calculated at the begininning of the day with some Gann formulas) and if the difference from that level and if the actual price is under 10... in that case I place an order limit simply 3 tick over that level for a short (under for a long).
The part of code that generate the entry is:

 
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
So the *** line is the only line that can change the conditions during EVERY tick because with IOG true the code is recalculated intrabar on every tick. 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?



ocpb View Post
As @ABCTG wrote, the built-in paper trading broker is the way to go -- it will actually use MC's full internal order logic.

Thanks @ABCTG to tell me about this feature. I honestly missed it and it is now live trading with the paper trading broker to check next days entries.


ocpb View Post
You have debugging statements in your code -- great -- but none of them are in the entry logic section (when marketposition = 0). And that is where I think you need some to solve this. Print out on each bar the if the entry limit should be effective in the market or not. Maybe this will show that you have the conditions but they are false on the next bar, and then set on then following bar, and so on.

Simplify your entry conditions -- see if you can get any limit orders at all to remain in the market under your control.

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


ocpb View Post
Lastly, definitely use the "paper trading" broker mode with automation enabled. Verify your strategy thoroughly with it.

As I said above to ABCTG thanks for bringing my attention to this. 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...


ocpb View Post
IMO you just can't know for real if the strategy would have been profitable yesterday. In fact it might be great news that these orders were cancelled -- What if you had dozens filled in under one minute? Imagine having to scramble with the MC DOM to cancel them all quickly.

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.

thanks again

David

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


ABCTG View Post
David,

Since you are dealing with intrabar order generation keep in mind that the next tick could potentially invalidate your entry conditions again and in turn the strategy engine will cancel the order again. Besides that any of the other points that Henry mentioned here can also lead to orders getting cancelled:
https://www.multicharts.com/discussion/viewtopic.php?t=51981

Regards,

ABCTG

Hello ABTG,

about this purpose I'm really trying to investigate if is there any possible case where my conditions are invalidated in the next click. So if you look at my answer to @ocpb above you can see that this piece of code


 
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
has only one line where conditions can change and it is the *** line. Basically when it met all PAST conditions (and they cannot be responsible for a sudden change in conditions) the strategy is going to send the limit order when the price is ABOVE the oYesterdaysTPOVALow Level and the difference between price and the level is below 10 pts.
So when the price goes over the level the strategy is sending an order and as long as I'll be in the "level + 3 limit" condition I can assume that it should have been filled...

Do you think that when the price is breaking the level by going over and below it for some time could cause the change of the triggering conditions? Is there a way to send an order ONCE the conditions are met and then wait for the close of the bar to RECHECK conditions and eventually REVOKE it ?

Thanks

David

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


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

Reply With Quote




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