1 tick resolution with order out of control "sometimes"

Questions about MultiCharts and user contributed studies.
Xslim
Posts: 15
Joined: 09 Apr 2014
Has thanked: 6 times

1 tick resolution with order out of control "sometimes"

Postby Xslim » 12 Jun 2014

I had traced this issue more than 2 months. The issue is the entry order malfunction sometimes. My code constrains the entry order didn't come with the stop order. But no matter how I setup MC profile or add restriction in program code, the entry order generated come with the stop order filled immediately sometimes. I post the code and Output in PLE below. "+555555+" is the price hit stop and it should generate the stop order, it has 4 times in attached file. It's correct in the 3 preceding except the last one. The last one(bar # 16927) hits the stop price and the parameters(CntUp=2/BarEntry=0/BarExit=0) are correct, but "ChartPosition=-1" didn't been reset to 0 by program. This cause MC placed real entry order at my previous trade experience.
<<The code wants to shortly to duplicate the phenomenon, it decrease the range between entry and stop. But it's same on my larger real case>>
MC version: Multichart64 version 8.8 Release(Build 8967)
System:Windows 64 bit professional
CPU: i7-4770K (I had tried on the other i7-3820QM)
RAM: 32GB
HDD: 256 GB SSD RAID

abbreviation: ChartPosition= Position at chart / BrokerPosition= Position on Broker /BarEntry=BarsSinceEntry(0) or BarsSinceEntry(1)/ BarExit=BarsSinceExit

Code: Select all

//Program Purpose:
// 1.Duplicate the order out of control at stop order filled but MC generate/filled another entry order immediately
// 2.Duplicate the malfunction at "cross over" and "highest"
//Resolution: 1 tick
//Instrumnet: any, but pick a wide range vibration instrument can shortly test time

[IntrabarOrderGeneration = False];
Input:Xprice(0);
var:Stp(0),RecStp(True),TmpStp(0),CntDn(0),CntUp(1),NEntry(""),StartTrade(False),Xprice1(0);
once Xprice1=Xprice;

if getappinfo(aiStrategyAuto)=1 and getappinfo(aiRealTimeCalc)=1 then begin
if StartTrade then begin
// Stp=highest(high,Stp);
if high>=Stp[1] then Stp=high else Stp=Stp[1]; //it always got the wrong value while using function-highest in 1 tick resolution
if RecStp then begin
if low cross under Stp-3*(MinMove/PriceScale) then begin
TmpStp=Stp;
RecStp=False;
CntDn=CntDn+1;
print(DateToString(DateToJulian(Date))," ",TimeToString(ELTimeToDateTime(Time)),"/bar #", maxbarsback+currentbar:8:0,"/ChartPosition:",MarketPosition:1:1,"/BrokerPosition:",MarketPosition_at_Broker:1:1,"/close:",close,"/StartTrade:",StartTrade,"/RecStp:",RecStp,"/Xprice1:",Xprice1,"/Stp:",Stp,"/TmpStp:",TmpStp,"/Entry Order:",NEntry:1:1,"/CntUp:",CntUp:1:1,"/CntDn:",CntDn:1:1,"/BarEntry:",Barssinceentry(0):1:1,"/BarEntry:",Barssinceentry(1):1:1,"/BarExit:",barssinceexit(1):1:1,"+44444+");
end;
end else begin
if high>TmpStp then begin //if using "high cross over TmpStp" then it won't go into to caculate CntUp sometimes. "cross" has issue in 1 tick resolution.
RecStp=True;
CntUp=CntUp+1;
print(DateToString(DateToJulian(Date))," ",TimeToString(ELTimeToDateTime(Time)),"/bar #", maxbarsback+currentbar:8:0,"/ChartPosition:",MarketPosition:1:1,"/BrokerPosition:",MarketPosition_at_Broker:1:1,"/close:",close,"/StartTrade:",StartTrade,"/RecStp:",RecStp,"/Xprice1:",Xprice1,"/Stp:",Stp,"/TmpStp:",TmpStp,"/Entry Order:",NEntry:1:1,"/CntUp:",CntUp:1:1,"/CntDn:",CntDn:1:1,"/BarEntry:",Barssinceentry(0):1:1,"/BarEntry:",Barssinceentry(1):1:1,"/BarExit:",barssinceexit(1):1:1,"+555555+");
end;
end;
// below is key for screen the stop order and next entry, but no matter how you control the next entry oder it generated/filled coming along with the stop order "sometimes"
//11111111111111111111111111111111
// if CntDn=CntUp then begin
// NEntry="S"+NumToStr(CntDn,0);
// sellshort(NEntry) 1 contract next bar at Stp-4(MinMove/PriceScale) limit;
// end;
//11111111111111111111111111111111

//222222222222222222222222222222222222222222222222 //Another method to screen out duplicate order
if CntDn=CntUp and (barssinceexit(1)>10 or totaltrades=0) then begin
NEntry="S"+NumToStr(CntDn,0);
sellshort(NEntry) 1 contract next bar at Stp-2*(MinMove/PriceScale) limit;
print(DateToString(DateToJulian(Date))," ",TimeToString(ELTimeToDateTime(Time)),"/bar #", maxbarsback+currentbar:8:0,"/ChartPosition:",MarketPosition:1:1,"/BrokerPosition:",MarketPosition_at_Broker:1:1,"/close:",close,"/StartTrade:",StartTrade,"/RecStp:",RecStp,"/Xprice1:",Xprice1,"/Stp:",Stp,"/TmpStp:",TmpStp,"/Entry Order:",NEntry:1:1,"/CntUp:",CntUp:1:1,"/CntDn:",CntDn:1:1,"/BarEntry:",Barssinceentry(0):1:1,"/BarEntry:",Barssinceentry(1):1:1,"/BarExit:",barssinceexit(1):1:1,"+3333+");
end;
//222222222222222222222222222222222222222222222222

//333333333333333333333333333333333333333333333333333 //Another method to screen out duplicate order
// if CntDn=CntUp and (PosTradeExitBar(1,0)>10 or totaltrades=0) then begin
// NEntry="S"+NumToStr(CntDn,0);
// sellshort(NEntry) 1 contract next bar at Stp-4(MinMove/PriceScale) limit;
// end;
//333333333333333333333333333333333333333333333333333

end else if high cross over Xprice1 then begin
StartTrade=True;
print(DateToString(DateToJulian(Date))," ",TimeToString(ELTimeToDateTime(Time)),"/bar #", maxbarsback+currentbar:8:0,"/ChartPosition:",MarketPosition:1:1,"/BrokerPosition:",MarketPosition_at_Broker:1:1,"/close:",close,"/StartTrade:",StartTrade,"/RecStp:",RecStp,"/Xprice1:",Xprice1,"/Stp:",Stp,"/TmpStp:",TmpStp,"/Entry Order:",NEntry:1:1,"/CntUp:",CntUp:1:1,"/CntDn:",CntDn:1:1,"/BarEntry:",Barssinceentry(0):1:1,"/BarEntry:",Barssinceentry(1):1:1,"/BarExit:",barssinceexit(1):1:1,"+222+");
end;
buytocover(NEntry+"X") all contract next bar at TmpStp+(MinMove/PriceScale) stop TmpStp+10*(MinMove/PriceScale) limit; //STOP order!!!!
buytocover(NEntry+"O") all contract next bar at TmpStp-25*(MinMove/PriceScale) limit; //Take Profit!!!

if low cross under TmpStp-30*(MinMove/PriceScale) then begin
Xprice1=high+10*(MinMove/PriceScale); //for repeat test
StartTrade=False; CntDn=0; Stp=0; CntUp=1; RecStp=True; NEntry="";
end;
print(DateToString(DateToJulian(Date))," ",TimeToString(ELTimeToDateTime(Time)),"/bar #", maxbarsback+currentbar:8:0,"/ChartPosition:",MarketPosition:1:1,"/BrokerPosition:",MarketPosition_at_Broker:1:1,"/close:",close,"/StartTrade:",StartTrade,"/RecStp:",RecStp,"/Xprice1:",Xprice1,"/Stp:",Stp,"/TmpStp:",TmpStp,"/Entry Order:",NEntry:1:1,"/CntUp:",CntUp:1:1,"/CntDn:",CntDn:1:1,"/BarEntry:",Barssinceentry(0):1:1,"/BarEntry:",Barssinceentry(1):1:1,"/BarExit:",barssinceexit(1):1:1,"+11+");
end;
2014/6/12 06:28:00/bar # 16924/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.15/StartTrade:TRUE/RecStp:FALSE/Xprice1: 106.13/Stp: 106.15/TmpStp: 106.15/Entry Order:S1/CntUp:1.0/CntDn:1.0/BarEntry:63.0/BarEntry:4202.0/BarExit:1739.0+3333+
2014/6/12 06:28:00/bar # 16924/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.15/StartTrade:TRUE/RecStp:FALSE/Xprice1: 106.13/Stp: 106.15/TmpStp: 106.15/Entry Order:S1/CntUp:1.0/CntDn:1.0/BarEntry:63.0/BarEntry:4202.0/BarExit:1739.0+11+
2014/6/12 06:28:00/bar # 16925/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.15/StartTrade:TRUE/RecStp:FALSE/Xprice1: 106.13/Stp: 106.15/TmpStp: 106.15/Entry Order:S1/CntUp:1.0/CntDn:1.0/BarEntry:64.0/BarEntry:4203.0/BarExit:1740.0+3333+
2014/6/12 06:28:00/bar # 16925/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.15/StartTrade:TRUE/RecStp:FALSE/Xprice1: 106.13/Stp: 106.15/TmpStp: 106.15/Entry Order:S1/CntUp:1.0/CntDn:1.0/BarEntry:64.0/BarEntry:4203.0/BarExit:1740.0+11+
2014/6/12 06:28:00/bar # 16926/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.15/StartTrade:TRUE/RecStp:FALSE/Xprice1: 106.13/Stp: 106.15/TmpStp: 106.15/Entry Order:S1/CntUp:1.0/CntDn:1.0/BarEntry:65.0/BarEntry:4204.0/BarExit:1741.0+3333+
2014/6/12 06:28:00/bar # 16926/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.15/StartTrade:TRUE/RecStp:FALSE/Xprice1: 106.13/Stp: 106.15/TmpStp: 106.15/Entry Order:S1/CntUp:1.0/CntDn:1.0/BarEntry:65.0/BarEntry:4204.0/BarExit:1741.0+11+
2014/6/12 06:28:00/bar # 16927/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.16/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:0.0/BarEntry:66.0/BarExit:0.0+555555+
2014/6/12 06:28:00/bar # 16927/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.16/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:0.0/BarEntry:66.0/BarExit:0.0+11+
2014/6/12 06:28:00/bar # 16927/ChartPosition:-1.0/BrokerPosition:-1.0/close: 106.16/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:0.0/BarEntry:66.0/BarExit:0.0+11+
2014/6/12 06:28:00/bar # 16928/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.14/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:1.0/BarEntry:67.0/BarExit:1.0+11+
2014/6/12 06:28:00/bar # 16929/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:2.0/BarEntry:68.0/BarExit:2.0+11+
2014/6/12 06:29:00/bar # 16930/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:3.0/BarEntry:69.0/BarExit:3.0+11+
2014/6/12 06:29:00/bar # 16931/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:4.0/BarEntry:70.0/BarExit:4.0+11+
2014/6/12 06:29:00/bar # 16932/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:5.0/BarEntry:71.0/BarExit:5.0+11+
2014/6/12 06:29:00/bar # 16933/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:6.0/BarEntry:72.0/BarExit:6.0+11+
2014/6/12 06:29:00/bar # 16934/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:7.0/BarEntry:73.0/BarExit:7.0+11+
2014/6/12 06:29:00/bar # 16935/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:8.0/BarEntry:74.0/BarExit:8.0+11+
2014/6/12 06:29:00/bar # 16936/ChartPosition:-1.0/BrokerPosition:0.0/close: 106.15/StartTrade:TRUE/RecStp:TRUE/Xprice1: 106.13/Stp: 106.16/TmpStp: 106.15/Entry Order:S1/CntUp:2.0/CntDn:1.0/BarEntry:9.0/BarEntry:75.0/BarExit:9.0+11+
Attachments
c.zip
Output in PLE
(73.2 KiB) Downloaded 136 times
FeedBackQ3.pla
code
(14.79 KiB) Downloaded 414 times

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

Re: 1 tick resolution with order out of control "sometimes"

Postby Henry MultiСharts » 19 Jun 2014

We are analyzing this case.

Xslim
Posts: 15
Joined: 09 Apr 2014
Has thanked: 6 times

Re: 1 tick resolution with order out of control "sometimes"

Postby Xslim » 11 Aug 2014

Hi Henny:
It had 2 months passed. Would you please let me know this bug had been confirmed yet or not?
It's not only on tick resolution but some kind of chart(like 50 point) has same issue on "barssinceexit(1)" function. There is no way to restrict abnormal trade. Please let me know do you plan fix it or not?

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

Re: 1 tick resolution with order out of control "sometimes"

Postby Henry MultiСharts » 11 Aug 2014

Hello Xslim,

Your last email from July 08 was replied on July 08 (same day).
I will quote the reply for you below:
Hello Sir,

Please disable both options under “recalculate on broker events” in Format->Strategy properties->Auto trading.

Please modify the code the following way:
If marketposition<>0 then begin
buytocover(NEntry+"X") all contract next bar at TmpStp+(MinMove/PriceScale) stop TmpStp+10*(MinMove/PriceScale) limit; //STOP order!!!!
buytocover(NEntry+"O") all contract next bar at TmpStp-25*(MinMove/PriceScale) limit; //Take Profit!!!
end;

Xslim
Posts: 15
Joined: 09 Apr 2014
Has thanked: 6 times

Re: 1 tick resolution with order out of control "sometimes"

Postby Xslim » 11 Aug 2014

Hi Henry:
Did you test it? It didn't work correctly, same as original status. Please ask you engineer to test it, and also for function-"barssinceexit(1)" on tick/50 point resolution chart. It's a bug obviously.

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

Re: 1 tick resolution with order out of control "sometimes"

Postby Henry MultiСharts » 12 Aug 2014

Did you test it? It didn't work correctly, same as original status. Please ask you engineer to test it, and also for function-"barssinceexit(1)" on tick/50 point resolution chart. It's a bug obviously.
We have tested it and it works as intended on our end. The exit order is not generated with the entry order.

Xslim
Posts: 15
Joined: 09 Apr 2014
Has thanked: 6 times

Re: 1 tick resolution with order out of control "sometimes"

Postby Xslim » 13 Aug 2014

Hi Henry:
How it can be? I had test more than 10 times on MC 8.8 and it must had wrong entry every time. Can you tell me what version do you test for?

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

Re: 1 tick resolution with order out of control "sometimes"

Postby Henry MultiСharts » 13 Aug 2014

Hi Henry:
How it can be? I had test more than 10 times on MC 8.8 and it must had wrong entry every time. Can you tell me what version do you test for?
Please email me (support@multicharts.com) the following information:
- specify the exact version and build number of MultiCharts are you running (in MultiCharts go to Help tab-> About);
- workspace you are using;
- in QuoteManager select the symbol you are using, make a right click on it->Export data->Export instrument (with data). Send me the Qmd export file for analysis;
- in PowerLanguage editor->File->Export->export with dependent functions the studies you are using in the workspaces you are providing. Send me the study export file.
- attach detailed problem description and your output log with the issue highlighted.

If the file size is >10 mb please upload it to any file sharing hosting and send me the download link.


Return to “MultiCharts”