Negative Equity Loss Limiter – HELP PLEASE

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #29901 quote
    GraHal
    Participant
    Master

    Following much discussion on the Thread below I’m trying to code into a Bot a ‘Daily Loss Limiter’ that limits starting equity to a loss of > £100 (or whatever) per day.

    https://www.prorealcode.com/topic/bad-beginings/

    I’ve got so far (see below) but when – next day – the Bot executes another trade Strategyprofit is still – £100 and so the Bot immediately exits (see attached).

    I need to increment the ‘negative equity’ by £100 each day. I’ve tried loads after researching the site, I’ve tried a count and a loop, but can’t get it to run as needed. Please can somebody help?

    (Mods, I cannot see the Insert PRT Code button, I’ve tried everything that has worked in the past (clear history, cookies etc, log out back in again) and also I did same on Firefox, Chrome and Edge … still cant see Insert PRT Code, even reduced my monitor resolution … so apologies for unformatted code.) 

    Below are the snippets that deal with my ‘negative equity loss limiter’.

    If Strategyprofit < -100 then
    Exitshort at market
    Sell at Market
    savedate = date
    Endif

    IF condition and Bullish0 and c1 and date <> savedate THEN
    BUY PositionSize CONTRACTS AT MARKET
    a=1
    ENDIF  

    If Strategyprofit < -100 then
    Exitshort at market
    Sell at Market
    savedate = date
    Endif
    
    IF condition and Bullish0 and c1 and date <> savedate THEN
    BUY PositionSize CONTRACTS AT MARKET
    a=1
    ENDIF  

    Thank You in Anticipation
    GraHal

    #29906 quote
    GraHal
    Participant
    Master

    My first line above should read … limits starting equity to a loss of <= £100 (or whatever) per day.

    If you want the full Bot code (to check out your ideas to help me) then it’s on the link below.

    I didn’t want to paste it on this Thread as the Insert PRT Code is not available to me (again!?)

    https://www.prorealcode.com/prorealtime-trading-strategies/ichimoku-exits-cloud/

    I decided after reading below that ichimoku based Bots might be worth spending some time on.

    http://www.babypips.com/school/elementary/common-chart-indicators/what-is-the-most-profitable-indicator.html

    GraHal

    #29925 quote
    AutoStrategist
    Participant
    Veteran

    Isn’t it something like this? You can change StartTime depending on what timeframe you are using:

    StartTime = 073000
    if time = StartTime then
    StartofDayProfit = STRATEGYPROFIT
    endif
    OkToTrade = (STRATEGYPROFIT > StartofDayProfit - 100)
    GraHal thanked this post
    #29946 quote
    GraHal
    Participant
    Master

    Thank you AutoS … above looks like it should work and I did try many variations of your theme. Most ended up with Trades open and exit in very short period in same bar with loss of £4 and equity curve continuing downwards for whole test period after an initial loss.

    It got me thinking / learning for another scenario so your time helping me was not wasted.

    ‘Necessity is the mother of invention’  so I came up with below, simple, effective. Attached results without and with loss limiter … not exactly wow!, but could be more significant on another Bot.

    I feel happier now going Live with a Loss Limiter. I may miss trades that ‘lose then win’, but overall knowing below zero / negative equity has some protection is comforting.

    (If profit is above 350, the loss limiter below does not trigger … for any rookie coders reading this)

    If STRATEGYPROFIT < 350 AND POSITIONPERF < - 0.002 then
    Exitshort at Market
    Sell at Market
    Endif

    GraHal

    #30029 quote
    AutoStrategist
    Participant
    Veteran

    Hmm not the sort of equity curve I would be looking for

    Stuart thanked this post
    #30030 quote
    GraHal
    Participant
    Master

    No nor me! ha

    I’m not ‘promoting’ the Bot, I got it from the Library, it was on my Platform cos I’ve been checking out Ichimoku based Bots.

    The  curve had 2 periods where the equity went negative / below zero so it suited my purpose re testing out my ‘loss limiter’.

    #30252 quote
    Derek
    Participant
    Veteran

    Hello Grahal,

    you have got to help me out because I still don’t get it:

    Every system has drawdowns and they can occur at any time. To me this means every system going live needs to be funded with at least enough money to sustain the maximum historical drawdown. Hence most systems run by small traders are underfunded.

    Or, do you want to pretend the system from trading after a certain amount of losses? In this case the overall win-loss ratio will drop because losers will remain losers and a few winners will be removed since they are needed to confirm the current profitable status of the system. This way the edge will be lowered and it is already hard to sustain an edge.

    #30260 quote
    GraHal
    Participant
    Master

    Hi Derek

    Seems a few don’t get it, but no problem. Unless I’m kidding myself??

    It’s like when manual trading after  a few losses, I get cautious until I’ve made my losses back.

    To me the most important thing surely is protection of starting capital? Systems start and they may or may not start with a losing trade or two or three. So if the losing trades take my starting equity below a predefined level (say £15) then the Loss Limiter triggers and exits the losing trade if loss is less than  minus / – 0.04% (before, maybe, becoming an even bigger loss).

    If  STRATEGYPROFIT <= 15 AND POSITIONPERF < - 0.0004 then
    Sell at Market
    Exitshort at Market
    Endif

    You’re right, the Loss limiter may kill a few trades that may have become winners, but so what? My starting equity is protected and I live to fight another day?

    All I need is for the System to start on a winner or two and profit exceed £15 and the Loss Limter may never trigger again (unless equity falls below £15 at a later date).

    I’m quite happy if you want to come back on it.

    GraHal

    #30409 quote
    Derek
    Participant
    Veteran

    First off all: Thank you for explaining it again (and again and…).

    The way I understand it now is that the loss-limiter is an attempt to manage the risk of a system going broke right after the “go-live”.

    But where do we go from there?

    A) wait for a better period and restart the system: But there cannot be a guarantee that it will keep on working now. This is why I think the max DD of the tests before the launch is so important. It tells us what to expect before we should switch the system off. I would prefer a scaling down of the position size over a size of zero.

    B) reject the system: If this happens too often it might mean that the previous testing process is flawed and should be examined.

    I know the following feeling quite well: “If this system starts out well, I will stick to it!”. But it is an essential contradiction to the statistical expectancy value of a system, which is more like: Play this game a thousand times and there will be a 65% chance of going away with 20% profits.

    At least that’s why I have not researched direct trading of the equity curve and prefer to focus on position sizing.

    Hope this was understandable.

    Greetings!

    #30412 quote
    GraHal
    Participant
    Master

    Yep @Derek understandable and you say … The way I understand it now is … is correct, but the System isn’t closed / rejected just the losing Trade is exited and the System continues to the next Trade.

    If I had the time / dedication to do extensive checks on a System using Walk Forward and Monte Carlo analysis etc then I likely would place more value on the statistical expectancy value of a system.  As it is I use Backtest results as a weathervane / guide, but try to dodge the storms! 🙂

    I’m pleased to say the ‘Negative Equity Limiter’ worked for me today, see  https://www.prorealcode.com/topic/does-this-system-have-an-edge-or-is-it-just-the-last-year/page/2/#post-30404.

    Regards
    GraHal

    #30413 quote
    Derek
    Participant
    Veteran

    In this case maybe this will also work:

    If strategyprofit <X then

    Set stop loss 100

    Else

    Set stop loss 500

    Endif

    #30414 quote
    Derek
    Participant
    Veteran

    Please disregard my post above.

    Thank you.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Negative Equity Loss Limiter – HELP PLEASE


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Derek
8 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/26/2017
Status: Active
Attachments: No files
Logo Logo
Loading...