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
Stop Strategy for the day Once Max Loss is Hit
-
- Posts: 261
- Joined: 28 Feb 2008
- Has thanked: 2 times
- Been thanked: 1 time
-
- Posts: 35
- Joined: 16 Nov 2009
- Contact:
-
- Posts: 261
- Joined: 28 Feb 2008
- Has thanked: 2 times
- Been thanked: 1 time
- Anastassia
- Posts: 179
- Joined: 18 Jan 2010
- Been thanked: 4 times
Dear FlipflopperWhat function will make the strategy stop functioning for the rest of the day?
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;
Re: Stop Strategy for the day Once Max Loss is Hit
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.
Thanks for your help in advance.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Stop Strategy for the day Once Max Loss is Hit
Maxiddrawdown returns drawdown for the current strategy applied to the chart.
Re: Stop Strategy for the day Once Max Loss is Hit
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
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
-
- Posts: 74
- Joined: 25 Aug 2007
- Been thanked: 6 times
Re: Stop Strategy for the day Once Max Loss is Hit
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
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Stop Strategy for the day Once Max Loss is Hit
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.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
Please check the solution provided by Erik Pepping.