PT and SL Attempts after the end of session

Questions about MultiCharts and user contributed studies.
User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

PT and SL Attempts after the end of session

Postby MAtricks » 29 Jul 2014

I've received a few warnings from my broker about my placing and cancelling orders. The report they sent said that I attempted over 2000 orders in just a few minutes which is completely unlike anything that I actually do.

Digging a little deeper, it looks like the fault falls on me using setstoploss and setprofittarget. Once the session ends, the strategies keep attempting to apply PTs and SLs onto my open position(s). After a random amount of time, this activity stops, but not before placing and rejecting thousands of orders.

Image

These orders should stop being placed the second that the session ends.


MC 8.8.9589 64bit
Rithmic


EDIT:
I just saw that 9.0 beta 2 added an option to turn off the strategy after X amount of rejected orders. Very handy feature. Does this turn SA/AA off?

I'd still like to see the PT and SL orders function correctly...
Attachments
after_session_end_orders.png
(24.93 KiB) Downloaded 614 times

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

Re: PT and SL Attempts after the end of session

Postby Henry MultiСharts » 30 Jul 2014

Hello MAtricks,

Do you use RecalcLastBarAfter in your code?

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: PT and SL Attempts after the end of session

Postby MAtricks » 30 Jul 2014

No sir. Do you suggest that I wrap my PT and SL code with it or the entire piece of executing code?

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

Re: PT and SL Attempts after the end of session

Postby Henry MultiСharts » 30 Jul 2014

No sir. Do you suggest that I wrap my PT and SL code with it or the entire piece of executing code?
No, if you read what it does you would not want to do that :)
Please send me the workspace and code you are using. Do you have it replicated each day?

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: PT and SL Attempts after the end of session

Postby MAtricks » 30 Jul 2014

:D I guess I should have read your link.

The PT and SL code is simple:

Code: Select all

Inputs:
Profit( 0 ),
StopLoss( 0 ) ;

Setstopcontract ;
if Profit > 0 then
setprofittarget( Profit ) ;
if StopLoss > 0 then
setstoploss( StopLoss ) ;
My window & instrument is formatted to the end of the session.
No IOG

Yes, this is an every day thing.

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

Re: PT and SL Attempts after the end of session

Postby Henry MultiСharts » 01 Aug 2014

Digging a little deeper, it looks like the fault falls on me using setstoploss and setprofittarget. Once the session ends, the strategies keep attempting to apply PTs and SLs onto my open position(s). After a random amount of time, this activity stops, but not before placing and rejecting thousands of orders.
MultiCharts will continuously try to apply the PTs and SLs if there is an open position. It will attempt to do that after each order reject.
These orders should stop being placed the second that the session ends.
These orders will stop being placed if they are active at broker (not rejected by the broker).
I just saw that 9.0 beta 2 added an option to turn off the strategy after X amount of rejected orders. Very handy feature. Does this turn SA/AA off?
Yes, it turns off the AT after the specified amount of rejects. In MC 8.8 it can be configured in the registry editor.
In HKEY_CURRENT_USER\Software\TS Support\MultiCharts64\TraderServer create ATRejectsLimit:DWORD Value and set the amount of rejects acceptable for you.


Return to “MultiCharts”