How to detect whether autotrading is enabled?

Questions about MultiCharts and user contributed studies.
brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

How to detect whether autotrading is enabled?

Postby brendanh » 28 Apr 2009

Might be a long shot but here goes. I am writing a program (for my own use only) that will send a warning email whenever Multicharts automation is disabled.

Is there any way of programmatically detecting whether automation is enabled\disabled, such as a registry value, file or TCP port change?

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 01 May 2009

Hi Brendan,

Registry value, file or TCP port can only be used by a file.
What you can do is insert the following line into your Study:

Code: Select all

//-------------
Getappinfo(aiStrategyAuto). It will return 1 if AT is on and 0 if it is off.
//-------------

You can also use a more sophisticated approach. Your strategy will plot Text, an indicator will recognize the drawing, find out what state AT is in and sends an e-mail alert.

Advantage: the solution only involves MC.
Limitation: it will react one bar too late. If you lose connection to the provider, the strategy will not be calculated and the alert will not be sent.

1. Strategy:

Code: Select all

//--------------------------------------------
var: text_id(0);
if text_id <> 0 then Text_Delete(text_id);
text_id=text_new_s(Date,Time_s,High,"AT="+IffString( getappinfo(aiStrategyAuto)=1," On"," Off"));
//---------------------------------------------
2 – Indicator

Code: Select all

//---------------------------------------------
alert(text_getstring(1));
//---------------------------------------------
3 – apply both the strategy and the indicator to the chart
4 – enable Email Alert for the indicator.


P.S. The code is very basic and needs to be fine-tuned.

brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Postby brendanh » 01 May 2009

Thanks Marina,
A good solution, I'm not concerned about losing connection to my data provider because my data provider is TS which I've set up to email me if data stops. The only problem is (as you say) this alert could lag by the length of a bar, and a lot can happen in the space of a bar!

I've done some more work on this and according to my testing, a connection on TCP port 7496 is established when MC-IB autotrading is enabled. So I can monitor that and send an email within a few seconds of disconnection.

PS, a small request, please can you add shortcut keys for the Close Position, and Do Not Close Position buttons in the Auto Trading Warning window that is displayed when you disable autotrading while in a position. Many autotraders automate the interface using macros and scripts, and shortcut keys for buttons and menu options (denoted by an underscored character) make these much more robust, so they are very important. I'm sure those who have difficulty using a mouse will appreciate the easier accessibility too.

Many thanks again.

rondot samuel ws
Posts: 103
Joined: 05 Sep 2007
Has thanked: 8 times
Been thanked: 6 times

Postby rondot samuel ws » 11 May 2010

Hi,

I looking for a solution for check MC and autotrading in Real time along the day.
The idea is to check GetAppInfo() and the positions, check position signal side and broker side etc.

The solution describe below is not good enough because the information is update only at the end of the bar. and with 240 mn bar...

Is it possible to update GetappInfo() at begin of bar for have info at the begin of day for example?

I try differents solutions for obtain information more frequently that end of bar.

// IOG solution ?
IOG = true and send order only if barstatus = 0 : i dont have the same orders in the chart in the previous days.

IOG = true and send order only if barstatus = 1 : i dont have the same orders in the chart in the previous days.

// Chart 1 mn
I put a chart in 1 mn and kept the original chart.
The idea is to calculate signal on the original chart and update info to personal log file in the 1 mn chart.

Unfortunatly, it doesn't work, the signal is not run each mn on the 1 mn chart.

So do you have any idea ?

Thanks

Samuel

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 11 May 2010

Hi,

with the chart, you can have intrabar update, so why not using GetAppInfo on each tic instead of each bar ? :?:

Like that , the length of the bar doesn't mater

rondot samuel ws
Posts: 103
Joined: 05 Sep 2007
Has thanked: 8 times
Been thanked: 6 times

Postby rondot samuel ws » 12 May 2010

Hi

IOG = Intrabar Order

I wrote i my post :

// IOG solution ?
IOG = true and send order only if barstatus = 0 : i dont have the same orders in the chart in the previous days.

IOG = true and send order only if barstatus = 1 : i dont have the same orders in the chart in the previous days.

So it doesn't work, because i don't have the same order. I want order are send only at end of bar. and even if i use barstatus = 0 or 1 then i don't have the same orders than if i don't use IOG

Hi,

with the chart, you can have intrabar update, so why not using GetAppInfo on each tic instead of each bar ? :?:

Like that , the length of the bar doesn't mater

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 12 May 2010

Hi rondot

I think I see your point, and I have the solution :

You want to use the intra bar to use GetAppInfo
but you want to send the order only if a new bar appear . Here is the solution I use :

1/ you turn on the intrabar

2/ add in your strategy :

Variable: IntrabarPersist LastDateTime("");

if LastDateTime<>numtostr(TIME,0) then begin

HERE YOU PUT YOUR ORDER

end
else begin


HERE YOU USE GetAppInfo

END;

LastDateTime=numtostr(TIME,0);

Like that only GetAppInfo will be called during the intrabar :wink:

I hope this will help you

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 12 May 2010

Hi

flipflopper, what do you mean ?

flipflopper
Posts: 261
Joined: 28 Feb 2008
Has thanked: 2 times
Been thanked: 1 time

Postby flipflopper » 12 May 2010

Hi

flipflopper, what do you mean ?
http://forum.tssupport.com/viewtopic.php?t=7405

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 12 May 2010

Hi,


From time to time I may loose Autotrader connection with IB. usually this happen after midnight, I agree this is a problem.

From time to time, some order are a sell instead of a buy and vis versa, this is as well a problem .

But, MC is improving constantly and I know that TSSupport are working on those 2 bugs actually.

I am sure TSSupport will get rid of those 2 bug soon. :wink:

Emmanuel

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

Postby TJ » 12 May 2010

Hi,


From time to time I may loose Autotrader connection with IB. usually this happen after midnight, I agree this is a problem.

From time to time, some order are a sell instead of a buy and vis versa, this is as well a problem .

But, MC is improving constantly and I know that TSSupport are working on those 2 bugs actually.

I am sure TSSupport will get rid of those 2 bug soon. :wink:

Emmanuel
I am not sure if that is a MultiCharts problem...
GIGO... MC can only do what you have programmed it to do.


ps. with the way I trade... that's not a bad idea, I might make some money with such a feature. LOL

;-)>

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 12 May 2010

Hi Tj,

I know this may seem strange, it may sell instead of buying and vis versa

In Multichart, the program work always fine : a buy in powerlanguage is a buy on the chart, and a sell is always a sell on the chart.

But unfortunatly, sometime a communication problem appear between Multichart and IB, Multichart buy , and a sell appear on the broker interface.

This is rare.

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

Postby TJ » 12 May 2010

Hi Tj,

I know this may seem strange, it may sell instead of buying and vis versa

In Multichart, the program work always fine : a buy in powerlanguage is a buy on the chart, and a sell is always a sell on the chart.

But unfortunatly, sometime a communication problem appear between Multichart and IB, Multichart buy , and a sell appear on the broker interface.

This is rare.
You can always trace your orders in MC and match them with the log in TWS.
Nothing can go astray without an audit trail.

This is a serious allegation.
If there is a problem as you claimed,
I don't think MultiCharts will take it lightly;
you should forward the logs to Tech Support
and I am sure an expert would be happy to match them for you.

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 12 May 2010

Hi Tj

Thank you for you advice, I will keep a copy of the log next time :)

Emmanuel

rondot samuel ws
Posts: 103
Joined: 05 Sep 2007
Has thanked: 8 times
Been thanked: 6 times

Postby rondot samuel ws » 14 May 2010

Hi Emmanuel,

Many thanks for your help.

unfortunatly, i don't obtain the same result in near old order with your code and OIG = true.

Have a good day
Hi rondot

I think I see your point, and I have the solution :

You want to use the intra bar to use GetAppInfo
but you want to send the order only if a new bar appear . Here is the solution I use :

1/ you turn on the intrabar

2/ add in your strategy :

Variable: IntrabarPersist LastDateTime("");

if LastDateTime<>numtostr(TIME,0) then begin

HERE YOU PUT YOUR ORDER

end
else begin


HERE YOU USE GetAppInfo

END;

LastDateTime=numtostr(TIME,0);

Like that only GetAppInfo will be called during the intrabar :wink:

I hope this will help you

Emmanuel
Posts: 355
Joined: 21 May 2009
Has thanked: 109 times
Been thanked: 28 times

Postby Emmanuel » 14 May 2010

Hi rondot,

Can you tell me what is missing ?

It should work,

rondot samuel ws
Posts: 103
Joined: 05 Sep 2007
Has thanked: 8 times
Been thanked: 6 times

Postby rondot samuel ws » 16 May 2010

Thanks for your reply.

please find attach 2 copy screens

only 1 trade with iog=true
Attachments
MC-AllTrades.jpg
Signal with all trades. No intrabar
(147.36 KiB) Downloaded 2098 times
MC-IntrabaOrder.jpg
Signal with intrabarorder true. only 1 trade
(145.99 KiB) Downloaded 2110 times

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

Postby TJ » 16 May 2010

Thanks for your reply.

please find attach 2 copy screens

only 1 trade with iog=true
is this a back test? or live trade?

rondot samuel ws
Posts: 103
Joined: 05 Sep 2007
Has thanked: 8 times
Been thanked: 6 times

Postby rondot samuel ws » 17 May 2010

Thanks for your reply.

please find attach 2 copy screens

only 1 trade with iog=true
is this a back test? or live trade?
I install the signal with autotrading Async few days ago. So it's "simulated signal" for the first one, but last of them was live trade.


Return to “MultiCharts”