Strategy is sending orders but they're canceled immediately, why? No broker side problem

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

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

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

buytocover("Bear SX8") 1 contract next bar at market;

Thanks.

1 Like

dvdarts,
this can be caused by the code, but I am afraid without seeing the code one could only guess. You might encourage more help from the community if you post full working code (and a workspace with your settings) that 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,

ABCTradingGroup

1 Like

I agree. Just reveal the entire order execution so we can also ask MC if they see any snags in the code. Thank you for your help and support.

Matt Z
Optimus Futures

Hello ABCTG and Matt,

As I’ve done on futures.io I’m posting here the code without some parts.

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:

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

1 Like

David,

Henry has given you six reasons why the orders could be cancelled and debugging your code’s realtime behavior to find out which of the reasons is the cause here should likely be the next step:

Regards,

ABCTradingGroup

Hello ABCTG,

I saw it now and I will investigate even if it would be not so easy.
Anyway do you see anything wrong in the provided code above? I posted all the entry logic (just without some conditions).

Thanks ,

David

David,

the code you posted can’t be used to reproduce the situation as it’s incomplete, therefore I am afraid I could only guess here. I would suggest examining the full code in regards to the six points Henry posted.

Regards,

ABCTradingGroup