Instruction used to stop a trading system. All opened, stop and limit orders are close when the instruction is used.
Stopped strategy with the QUIT instruction cannot be re-launched automatically by code. Only a manual intervention can do it.
Syntax:
1 |
QUIT |
Example1 :
Stop the automated trading program at 22:00 if we are short on market.
1 2 3 |
IF ShortOnMarket AND CurrentHour=22 THEN QUIT ENDIF |
Example2 :
Stop the strategy if the actual profit is losing 200 of the money account.
1 2 3 |
IF StrategyProfit<-200 then QUIT ENDIF |
I have a system using:
IF StrategyProfit > 10 then
QUIT
ENDIF
The 1st instance I ran it, it made profit of: 39.10 and it QUIT
I then restarted the system (note: ProOrder AutoTrading still showing the total profit 39.10) and this time the trade made a Profit of: -0.10 and Total Equity Curve = 39 but it did not QUIT and started again.
Is this a PRT error or an error of my understanding of how StrategyProfit and QUIT should work?
StrategyProfit is calculated with closed orders and is of course reset each time the strategy is stopped manually or automatically.
Thanks Nicolas. I understand know that I should have used StrategyProfit < 999999 // if wanted to stop after the close of the current positions.
So how can you auto-stop a strategy?
With the QUIT keyword, there are 2 examples above.
Hi – Please may I ask a clarification on the second example: IF StrategyProfit<-200 then QUIT.
Scenario 1 – the strategy posts a profit of 1000 with the first trade and then a loss of 300 with a second trade. Will the system quit, at this point?
Scenario 2 – the first trade posts a loss of 300. Will the system quit?
Thanks.
1/ No.
2/ Yes.
StrategyProfit is the sum of profit & loss of the closed trades since the start of the strategy.
Thanks Nicolas. My strategy requires the manual optimizations on a quarterly basis of some indicators and therefore I am forced to stop the old strategy and to start a refreshed version. In doing so, the Strategy Profit is consequently reset to zero –> therefore a simple instruction like this could still work, in order to get a second level of protection in absolute value (on top of any stop loss / trailing that are set for each single trade); If something goes horribly wrong, I know there is an halt instruction (QUIT) that will stop the show.
I am sure more experienced programmers (I just started few months ago) can elaborate further with the quit instruction, like defining self-adjusting calculations.
I did not see many blogs on this instruction, but limiting losses is a fundamental backbone of a profitable strategy. Do you agree?
Indeed the strategyprofit is reset because each time you launch a new strategy, it’s a new strategy with a fresh start, how the system would now that it should keep the old profit in memory and for this specific program?
Yes, impossible to retain the strategy P&L if the program is stopped. The reason why I stop the strategy is because I can’t perform the quarterly optimisation of 5 parameters automatically as I need to do it progressively (1 or 2 at the time) and with many runs before finding the optimal result. It would be complicated to code it, therefore I do it manually and then launching a refreshed strategy. It works…
If CurrentDayOfWeek > 5 then
Quit
Endif
Pourquoi cette instruction ne fonctionne pas ?
Je voudrais arrêter la stratégie lorsque l’on n’est plus en working days
parce que le code n’est pas lu le weekend, les jours 6 et 7.