Strategy is sending orders but they’re canceled immediately, why? No broker side problem  [SOLVED]

Questions about MultiCharts and user contributed studies.
dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

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

Postby dvdkite » 24 Apr 2019

Hello Everyone,

Image

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 could be 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):

Code: Select all

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: Select all

buytocover("Bear SX8") 1 contract next bar at market;
Strategy has IOG enabled.

Thanks.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

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

Postby Henry MultiСharts » 24 Apr 2019

Hello dvdkite,

The orders are kept at the broker while they are generated by the strategy. That means the conditions for order generation should be met in your code on each tick (IOG=ON) calculation while you need to keep your orders active.

The order can be cancelled due to the following reasons:
1) the script has stopped generating the order;
2) a different set of orders was generated on a new calculation (ex. on one calculation, there were 2 stops, on the next one - only 1 stop, all orders are cancelled and 1 stop is resubmitted);
3) a market order was generated by the code (requires to cancel all active price orders to send it);
4) order volume was modified;
5) one of the options from the Auto Trading tab triggered:
http://www.multicharts.com/trading-soft ... to_Trading
6) one of the other orders from this OCO group was cancelled.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

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

Postby dvdkite » 24 Apr 2019

Hello Henry,

As I've done on futures.io I'm posting here the code without some parts.
I will carefully check your list even if it would not be so easy for me to find out some of your point ( I really don't know how to verify 1,2,3 and 4 ). Anyway do you see in the code below any wrong piece of code at a first look?

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: Select all

// .................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:
SholdHaveBeenDoneTRADE.JPG
(149.88 KiB) Downloaded 409 times
Image



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
Last edited by dvdkite on 24 Apr 2019, edited 2 times in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Strategy is sending orders but they’re canceled immediately, why? No broker side problem  [SOLVED]

Postby TJ » 24 Apr 2019

See post #1 & post #2
viewtopic.php?t=11713


ps. your image is not showing. You need to upload the picture to this site.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

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

Postby dvdkite » 24 Apr 2019

See post #1 & post #2
viewtopic.php?t=11713


ps. your image is not showing. You need to upload the picture to this site.

Hi Tj,

I modified the post and now you can see the code.
But the only button that I see to post the image is a small image icon and it only provide the img tags for the image url ( I don't see an option to upload an image here ).
Anyway the alternative link of the image is https://futures.io/attachments/265243

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

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

Postby TJ » 24 Apr 2019

. . .

But the only button that I see to post the image is a small image icon and it only provide the img tags for the image url ( I don't see an option to upload an image here ).
Anyway the alternative link of the image is https://futures.io/attachments/265243
Not everyone can see the picture at the remote site.
You need to download the picture from futures.io and upload it here.

The "Attachment" button is below the "Submit" button.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

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

Postby dvdkite » 24 Apr 2019

. . .

But the only button that I see to post the image is a small image icon and it only provide the img tags for the image url ( I don't see an option to upload an image here ).
Anyway the alternative link of the image is https://futures.io/attachments/265243
Not everyone can see the picture at the remote site.
You need to download the picture from futures.io and upload it here.

The "Attachment" button is below the "Submit" button.
Should be visible now. I uploaded it here and I can see it in the post.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

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

Postby dvdkite » 25 Apr 2019

Hello Henry,

today and yesteday I started to check all your points .
Hello dvdkite,

The orders are kept at the broker while they are generated by the strategy. That means the conditions for order generation should be met in your code on each tick (IOG=ON) calculation while you need to keep your orders active.

The order can be cancelled due to the following reasons:
1) the script has stopped generating the order;
The script were generating almost an order every second. The stategy were sending orders, then orders were immediately canceled and then resent and recanceled and.... I stopped the Automated Trading after 10 orders canceled in a row.
So I suppose that the script hasn't stopped to generate orders , the script kept generating them once after the other.
2) a different set of orders was generated on a new calculation (ex. on one calculation, there were 2 stops, on the next one - only 1 stop, all orders are cancelled and 1 stop is resubmitted);
My strategy has only 1 contract size for entries and the MC stop loss

Code: Select all

// Fixed Stop loss
setstoploss( Stoploss * bigpointvalue);
so I don't understand what do you mean with "different set of orders". I was supposing that when an order is filled then it immediately send the Stop order ( not OCO because I don't send any target order, exits has their own conditions before sent the exit order)
3) a market order was generated by the code (requires to cancel all active price orders to send it);
The strategy was live and there were no market orders sent to the broker. Also I don't have ENTRY market orders in my strategy, only EXIT market orders. And of course I don't have activated any options that convert limit to market orders.
4) order volume was modified;
Everywhere in my strategy the volume is 1 contract.
5) one of the options from the Auto Trading tab triggered:
http://www.multicharts.com/trading-soft ... to_Trading

This is my TAB and I cannot see any options active that could invalidate my order
StrategyPropertiesAutomatedTradingTAB1.JPG
(71.76 KiB) Downloaded 394 times
StrategyPropertiesAutomatedTradingTAB2.JPG
(54.44 KiB) Downloaded 394 times
Shall I enable the " Convert unexacuted entry orders to market orders after" maybe 3 seconds? I could be a solution but it would be a modification of my system behavious. I would prefer to keep the limit order if possible.

Interesting question ( keeping in mind that I have IOG ON ):
Is there a way to SEND the entry limit order when the strategy conditions are met and KEEP IT ALIVE till the end of the bar? I mean even if just the tick after the order generations the triggering conditions are changed?
6) one of the other orders from this OCO group was cancelled.
This strategy does not use OCO as specified in (2).


In addition to this, as suggested from ABCTG I have setted up a workspace with the same strategy applied to the paper trading broker to check how orders will work there. Unfortunately the strategy usually perform 15 operations per months on average... so I'll have to wait until the net order to see what is happening there.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

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

Postby Henry MultiСharts » 25 Apr 2019

Interesting question ( keeping in mind that I have IOG ON ):
Is there a way to SEND the entry limit order when the strategy conditions are met and KEEP IT ALIVE till the end of the bar? I mean even if just the tick after the order generations the triggering conditions are changed?
David, there is no way to do that. The conditions for the order generation should be met in your code on each tick while you need to keep your order active. If conditions are valid on one tick, then invalid on the next one, then are valid again, then the order will be placed, then cancelled, then placed again, and so on.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

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

Postby dvdkite » 29 Apr 2019

Interesting question ( keeping in mind that I have IOG ON ):
Is there a way to SEND the entry limit order when the strategy conditions are met and KEEP IT ALIVE till the end of the bar? I mean even if just the tick after the order generations the triggering conditions are changed?
David, there is no way to do that. The conditions for the order generation should be met in your code on each tick while you need to keep your order active. If conditions are valid on one tick, then invalid on the next one, then are valid again, then the order will be placed, then cancelled, then placed again, and so on.
Hello Henry,

I think I've found a way in my code to keep the order alive for the correct amount of time. Hope it will work!

Thanks

User avatar
Mark Brown
Posts: 181
Joined: 29 Nov 2016
Has thanked: 111 times
Been thanked: 17 times

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

Postby Mark Brown » 19 Nov 2022

tell you what MC should settle this auto trading back and forth by just posting some simple non profitable trading system that will execute the same as an indicator will plot.

using kase range bar "any size" with update set to 1 tick show me a system that will

enter on the close of current bar and get out on a bracket order.

using mc + cqg + amp - once you flip a system live it will enter on the next bar open and brackets are useless.

anyone? lol no never going to happen

mc needs to stop advertising auto trading as a feature cause it's false until someone proves it to me.

mark - owner of 3 mc licenses.

User avatar
syswizard
Posts: 295
Joined: 15 Dec 2012
Has thanked: 16 times
Been thanked: 28 times

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

Postby syswizard » 27 Nov 2022


Hello Henry,

I think I've found a way in my code to keep the order alive for the correct amount of time. Hope it will work!

Thanks
Can you share this technique ?


Return to “MultiCharts”