"EntriesToday" failing me if I enable/re-enable auto trading

Questions about MultiCharts and user contributed studies.
jese514
Posts: 16
Joined: 11 Apr 2014
Has thanked: 2 times
Been thanked: 3 times

"EntriesToday" failing me if I enable/re-enable auto trading

Postby jese514 » 02 Jul 2014

I use the EntriesToday function to limit the number of trades to 1. So, the code only places a trade "if EntriesToday(Date) = 0".

This works fine in backtesting, but for live auto-trading it messes up if auto-trading is disabled and then re-enabled. So it will do only 1 trade, but then if I disable and then re-enable auto-trading, (without changing anything else) it will do another trade that same day. It seems that the memory of trades occurring does not carry over.

Any suggestions as to how I can fix this?

If I look in the Order and Position Tracker, I see that MC keeps a record of the number of entries. So ideally I would have a function that checks the number of entries in that list, rather than just checking those in memory, which get lost as soon as auto-trading is disabled.

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

Re: "EntriesToday" failing me if I enable/re-enable auto tra

Postby Henry MultiСharts » 02 Jul 2014

Hello jese514,

Do you use SA or AA auto trading mode?

jese514
Posts: 16
Joined: 11 Apr 2014
Has thanked: 2 times
Been thanked: 3 times

Re: "EntriesToday" failing me if I enable/re-enable auto tra

Postby jese514 » 02 Jul 2014

Hi, I was using SA, which is the default. I just tried AA mode and it fixed this. So thank you!

But I'm a bit confused; is it not the point of "synchronous" mode to sync the chart with the broker history?

Thanks again.

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

Re: "EntriesToday" failing me if I enable/re-enable auto tra

Postby Henry MultiСharts » 03 Jul 2014

Hi, I was using SA, which is the default. I just tried AA mode and it fixed this. So thank you!
But I'm a bit confused; is it not the point of "synchronous" mode to sync the chart with the broker history?
Thanks again.
jese514, if you have an open position at the broker and you want your strategy to continue trading this position in SA mode - you need to specify the position manually for the strategy next time you turn on the auto trading.
Please do the following:
Go to Format-> Strategy properties-> Auto trading-> Assign the initial market position at the broker setting->Show the assign the initial market position at the broker dialogue-> Show always-> Ok.

When you start the auto trading - a dialogue window will appear where you can set the position for the strategy. This is how you can synchronize your broker and strategy positions.

For more information about the auto trading modes please refer to the following page.


Return to “MultiCharts”