Order rejected after close

Questions about MultiCharts and user contributed studies.
Powen
Posts: 3
Joined: 29 May 2019
Has thanked: 3 times

Order rejected after close

Postby Powen » 07 Oct 2019

Hi,

One of my stop out signal keeps sending orders after the market is close, which makes the automated order execution be turned off after 100 times of rejection.

I am sure I set the session time correctly, I even set a 30 seconds buffer before closing time trying to avoid it(as code below).
It seems that this occurs randomly, because it happened on Silver(SI) and Platinum(PL) yesterday, but not on Gold(GC) or WTI(CL).
Where SI and GC are both on COMEX, PL and CL are both on NYMEX.

Any solution?
Thanks.

Code: Select all

[IntrabarOrderGeneration = true];
inputs: StopLossPct( .02 ) ;
vars: EndTime(0), StartTime(0), IsClose(True);

StartTime = SessionStartTime(1,dayofweek(date));
EndTime = SessionEndTime(1,dayofweek(date));

IsClose = IFFLogic(EndTime <= StartTime,
(TimeToSeconds(currenttime_s) + 30 > TimeToSeconds(EndTime *100) and TimeToSeconds(currenttime_s) < TimeToSeconds(StartTime * 100)),
(TimeToSeconds(currenttime_s) + 30 > TimeToSeconds(EndTime *100) or TimeToSeconds(currenttime_s) < TimeToSeconds(StartTime *100)));

setstopcontract ;
if not IsClose then begin
SetStopLoss( EntryPrice * StopLossPct * BigPointValue )
end;
Screen shot of Logs:
https://imgur.com/a/jgy9cax
Image
Last edited by Powen on 07 Oct 2019, edited 1 time in total.

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

Re: Order rejected after close

Postby TJ » 07 Oct 2019


User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Order rejected after close

Postby rrams » 07 Oct 2019

Hi Powen,
You don't want to program any kind of condition for the SetStopLoss command. Just issue the SetStopLoss.

MultiCharts does have a bug in the SessionEndTime and SessionStartTime functions where it will give you the incorrect time if your charts are set to Local time and your PC is set NOT to observe Daylight Saving Time and the exchange is currently observing DST. I wrote my own corrected functions for that since I live in Arizona with no DST.

However, I don't think that is your problem. I think your symbol setting session times are wrong. Watch your chart at session end to make sure it is not receiving any tick data.

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

Re: Order rejected after close

Postby TJ » 08 Oct 2019


Powen
Posts: 3
Joined: 29 May 2019
Has thanked: 3 times

Re: Order rejected after close

Postby Powen » 08 Oct 2019

Thank you both, TJ & rrams.

Just now my ICE Brent signal turned off again because 100 orders had been rejected after close - ICE Brent close at 6:00 AM New York Time.
I'll firstly remove all the conditions of SetStop as TJ instructed then reset all exchange sessions and time zone in QuoteManager.
Hope that can fix the problem.

@TJ
By the way, according to viewtopic.php?t=10811, I have to implement myself if I want to use stop loss or trailing with condition, is that correct?
But Multicharts built-in signals also put conditions on "Global Exits" like below:

Code: Select all

[IntrabarOrderGeneration = false]
inputs: Amount( 1 ), PositionBasis( false ) ;

if PositionBasis then
SetStopPosition
else
SetStopShare ;

if MarketPosition = 1 then
SetDollarTrailing( Amount ) ;

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

Re: Order rejected after close

Postby TJ » 08 Oct 2019


@TJ
By the way, according to viewtopic.php?t=10811, I have to implement myself if I want to use stop loss or trailing with condition, is that correct?
But Multicharts built-in signals also put conditions on "Global Exits" like below:
If you can make the logic work, by all means do it.


Return to “MultiCharts”