Stop Strategy for the day Once Max Loss is Hit

Questions about MultiCharts and user contributed studies.
flipflopper
Posts: 261
Joined: 28 Feb 2008
Has thanked: 2 times
Been thanked: 1 time

Stop Strategy for the day Once Max Loss is Hit

Postby flipflopper » 20 Jan 2010

What function will make the strategy stop functioning for the rest of the day?

If maxiddrawdown < -1000 then
Close all positions
exit strategy for the day

glen demarco
Posts: 35
Joined: 16 Nov 2009
Contact:

Postby glen demarco » 20 Jan 2010

One simple approach is to simply code into your strategy a test of Maxintradraw down and then the value is less then -1000 exit the script.

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

Postby flipflopper » 20 Jan 2010

Exactly!!!

The question being what is the syntax to exit the script?

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Postby Anastassia » 21 Jan 2010

What function will make the strategy stop functioning for the rest of the day?
Dear Flipflopper

The following code will make your strategy stop functioning for the rest of the day:

Code: Select all

var: stop_trading_for_day(false);

if date <> date[1] then
stop_trading_for_day = false;

If maxiddrawdown < -1000 then
begin
stop_trading_for_day = true;
sell all contract next bar market;
buytocover all contract next bar market;
end;


if stop_trading_for_day = false then
begin
// your script
end;

atsui
Posts: 25
Joined: 03 Aug 2011
Has thanked: 5 times
Been thanked: 4 times

Re: Stop Strategy for the day Once Max Loss is Hit

Postby atsui » 15 Feb 2012

Does the keyword Maxiddrawdown refer to the drawdown of a. the account, b. the particular strategy, or c. the particular instrument? Because I apply one strategy to different instruments and I'd like to know in actual trading if the maximum drawdown is aggregated across all strategies and all instruments.

Thanks for your help in advance.

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

Re: Stop Strategy for the day Once Max Loss is Hit

Postby Henry MultiСharts » 15 Feb 2012

Maxiddrawdown returns drawdown for the current strategy applied to the chart.

Joogen
Posts: 9
Joined: 27 May 2009

Re: Stop Strategy for the day Once Max Loss is Hit

Postby Joogen » 19 Apr 2012

Does the code above really stop trading only for the day? If I apply it to my intraday strategy based on 1min bars the strategy stops trading after some days once the DD level (same as in Performance Report) is hit and never restarts again...

Anybody knows how to modify the code in a way that there is a max DD defined for every single day (equal to zero at the beginning of the day - trading until max DD is hitted - set to 0 at beginning of next day)?

Thanks

Erik Pepping
Posts: 72
Joined: 25 Aug 2007
Been thanked: 5 times

Re: Stop Strategy for the day Once Max Loss is Hit

Postby Erik Pepping » 23 Apr 2012

I always use the profit for the day calculation. Often to stop trading after a certain profit for the days has been reached.

Code: Select all

variables: NetProf(0), Target (0);

if DATE <> DATE[1] THEN
BEGIN
NetProf = NetProf + NetProfit - NetProf[1];
end;

Target = Netprofit - NetProf;
if marketposition=0 and time < 2100 and Target <= DailyProfit then

...etc

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

Re: Stop Strategy for the day Once Max Loss is Hit

Postby Henry MultiСharts » 24 Apr 2012

Does the code above really stop trading only for the day? If I apply it to my intraday strategy based on 1min bars the strategy stops trading after some days once the DD level (same as in Performance Report) is hit and never restarts again...

Anybody knows how to modify the code in a way that there is a max DD defined for every single day (equal to zero at the beginning of the day - trading until max DD is hitted - set to 0 at beginning of next day)?

Thanks
MaxIDDrawDown returns a negative numerical value, indicating the largest decline in equity during the entire trading period. The only way to reset the value is to restart the auto trading on the next day.
Please check the solution provided by Erik Pepping.


Return to “MultiCharts”