How much is a good Stoploss system method worth?

Discussion in 'Risk Management' started by themickey, Oct 18, 2019.

  1. themickey

    themickey

    Who said anything about it not having logic?
    I agree with you however but not about several losers, too much work and fees.
    Thanks for post.
     
    #51     Oct 21, 2019
  2. themickey

    themickey

    Writing/coding a trendline is complex, they also make sense after the fact in hindsight. So you code up a trendline in Amibroker for example, can you transfer that to Supercharts or any other charting program? NO! Can you code it simply into Excel? NO!
    Some may wish to code up a % trailing stop and use that as a trendline, well same thing applies, it's complex and for the most part unpractical.

    CODING FOR TRENDLINE IN AB
    //////////////chart & back ground color////////////////////
    SetChartBkGradientFill( colorBlack, colorBlack, colorBlack );
    //Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
    Plot( Close, "C", colorWhite, styleCandle );
    separator = Day() != Ref( Day(), -1 );
    Plot( separator, "", colorPink, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 5 );
    starttime = 091500;
    endtime = 151500;
    separator = Day() != Ref( Day(), -1 );
    insession = timenum() >= starttime && timenum() <= 151000;
    endsession = timenum() >= endtime;
    endsession = ( endsession - Ref( endsession, -1 ) ) == 1 ;//OR Ref( separator, 1 );
    startsession = timenum() >= starttime;
    startsession = ( startsession - Ref( startsession, -1 ) ) == 1;
    timelmits = insession && !endsession;
    Plot( endsession, "", colorWhite, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 1 );
    Plot( startsession, "", colorViolet, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 1 );
    //GraphXSpace = 85;

    _SECTION_BEGIN("Long R/S");
    farback = Param("How Far back to go", 100, 50, 5000, 10);
    nBars = Param("Number of bars", 12, 5, 40);
    aHPivs = H - H;
    aLPivs = L - L;
    aHPivHighs = H - H;
    aLPivLows = L - L;
    aHPivIdxs = H - H;
    aLPivIdxs = L - L;
    nHPivs = 0;
    nLPivs = 0;
    lastHPIdx = 0;
    lastLPIdx = 0;
    lastHPH = 0;
    lastLPL = 0;
    curPivBarIdx = 0;
    aHHVBars = HHVBars(H, nBars);
    aLLVBars = LLVBars(L, nBars);
    aHHV = HHV(H, nBars);
    aLLV = LLV(L, nBars);
    aVisBars = Status("barvisible");
    nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
    _TRACE("Last visible bar: " + nLastVisBar);
    curBar = (BarCount - 1);
    curTrend = "";
    if (aLLVBars[curBar] < aHHVBars[curBar])
    {
    curTrend = "D";
    }

    else
    {
    curTrend = "U";
    }

    for (i = 0; i < farback; i++)
    {
    curBar = (BarCount - 1) - i;
    if (aLLVBars[curBar] < aHHVBars[curBar])
    {
    if (curTrend == "U")
    {
    curTrend = "D";
    curPivBarIdx = curBar - aLLVBars[curBar];
    aLPivs[curPivBarIdx] = 1;
    aLPivLows[nLPivs] = L[curPivBarIdx];
    aLPivIdxs[nLPivs] = curPivBarIdx;
    nLPivs++;
    }
    }
    else
    {
    if (curTrend == "D")
    {
    curTrend = "U";
    curPivBarIdx = curBar - aHHVBars[curBar];
    aHPivs[curPivBarIdx] = 1;
    aHPivHighs[nHPivs] = H[curPivBarIdx];
    aHPivIdxs[nHPivs] = curPivBarIdx;
    nHPivs++;
    }
    }
    }

    curBar = (BarCount - 1);
    candIdx = 0;
    candPrc = 0;
    lastLPIdx = aLPivIdxs[0];
    lastLPL = aLPivLows[0];
    lastHPIdx = aHPivIdxs[0];
    lastHPH = aHPivHighs[0];
    if (lastLPIdx > lastHPIdx)
    {
    candIdx = curBar - aHHVBars[curBar];
    candPrc = aHHV[curBar];
    if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar)
    {
    aHPivs[candIdx] = 1;
    for (j = 0; j < nHPivs; j++)
    {
    aHPivHighs[nHPivs - j] = aHPivHighs[nHPivs - (j + 1)];
    aHPivIdxs[nHPivs - j] = aHPivIdxs[nHPivs - (j + 1)];
    }
    aHPivHighs[0] = candPrc;
    aHPivIdxs[0] = candIdx;
    nHPivs++;
    }
    }

    else
    {
    candIdx = curBar - aLLVBars[curBar];
    candPrc = aLLV[curBar];
    if (lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar)
    {
    aLPivs[candIdx] = 1;
    for (j = 0; j < nLPivs; j++)
    {
    aLPivLows[nLPivs - j] = aLPivLows[nLPivs - (j + 1)];
    aLPivIdxs[nLPivs - j] = aLPivIdxs[nLPivs - (j + 1)];
    }
    aLPivLows[0] = candPrc;
    aLPivIdxs[0] = candIdx;
    nLPivs++;
    }
    }

    for (k = 0; k < nHPivs; k++)
    {
    _TRACE("High pivot no. " + k + " at barindex: " + aHPivIdxs[k] + ", " + WriteVal(ValueWhen(BarIndex() == aHPivIdxs[k], DateTime(), 1), formatDateTime) + ", " + aHPivHighs[k]);
    }

    a1 = ahpivs == 1;
    a2 = alpivs == 1;

    Para = ParamToggle("Plot Parallel Lines","Off,On");
    ColorS= ParamColor("Support",colorLime);
    ColorR= ParamColor("Resistance",colorRed);
    x = Cum(1);
    s1 = L;
    s11 = H;
    pS = a2 == 1;

    endt = LastValue(ValueWhen(ps,x,1));
    startt = LastValue(ValueWhen(ps,x,2));
    ends = LastValue(ValueWhen(ps,S1,1));
    starts = LastValue(ValueWhen(ps,S1,2));
    dtS = endt - startt;
    aS = (endS - startS) / dtS;
    bS = endS;
    trendlineS = aS *(x - endt) + bS;
    g3 = IIf(x > startt - 10, trendlineS, Null);
    Plot(g3, "", colors, styleLine+styleDashed+styleNoRescale+styleNoLabel);
    pR = a1 == 1;
    endt1 = LastValue(ValueWhen(pr,x,1));
    startt1 = LastValue(ValueWhen(pr,x,2));
    endr = LastValue(ValueWhen(pr,S11,1));
    startr = LastValue(ValueWhen(pr,S11,2));
    dtR = endt1 - startt1;
    aR = (endR - startR) / dtR;
    bR = endR;
    trendlineR = aR *(x - endt1) + bR;
    g4 = IIf(x > startT1 - 10, trendlineR, Null);
    Plot(g4, "", colorr, styleLine+styleDashed+styleNoRescale+styleNoLabel);

    _SECTION_END();
    https://forum.amibroker.com/t/trendline-code-customization/8949
     
    #52     Oct 21, 2019
    ironchef likes this.
  3. easymon1

    easymon1

    gesundheit!
     
    #53     Oct 21, 2019
  4. jbax

    jbax

    I use a large combination of factors to determine when to exit. On backtests whenever I use a single method (e.g. Chandelier Exit, Parabolic SAR, Donchian Channels) it doesn't give great results. Stop losses at a fixed price/rate/ATR multiplier also seem to yield worse outcomes if it's not conditional to some other state (e.g. lost 1% already, it's not picking up, and didn't get another buy signal from a bunch of indicators in that last x minutes).

    A lot depends on whether the trade is a winner or a loser as well, and for how long it's been running.

    It's simpler to use crossovers to state whether it's an uptrend or downtrend. There is also this "Instantaneous Trendline" indicator which can give you a hint. You can use that in combination with ADX to try to have a notion of where in the trend you are (as in: the start, middle or end of trend)

    Hope this helps
     
    #54     Dec 3, 2019
  5. ironchef

    ironchef

    What language is that?

    I only know VBA, is there a translator for that?
     
    #55     Dec 19, 2019
  6. Handle123

    Handle123

    Nothing is perfect, so you develop multiple methods with each seeking different outcomes, scalping is 90/10 scalp/runner, hourly 1st target for 3 digit outcomes, daily shoots for 1st targets of 4 digits, long term 1st targets 5 digits. Time allows for bigger profits cause they happen less. I believe the toughest is acceptance of what you end up, it never be the best, someone else smarter with find anything better, but since I concentrate on having very low drawdowns, upside becomes less important. So instead of keeping 50% of account on sidelines to handle losses, I can utilize 85% with 15% in reserve. As you age, you have to come to realization it is easier to accept and in long range, so long as equity curve keeps going up, accept.
     
    #56     Dec 19, 2019
  7. themickey

    themickey

    It's called AFL (Amibroker formula language).
    I know of no direct translator, but I would imagine many good coders could look at it and suss most of it out.
    That particular code I just copied from internet, it's not something I use.
    The general opinion seems to be, AFL is not an easy language to understand and that too is my experience, I think the software is great but understanding the coding difficult.
    Even if you go online looking for answers, many of the AFL crowd be making comments; "work it out yourself, that's the only way you'll learn".
     
    #57     Dec 19, 2019
  8. themickey

    themickey

    And 'equity curve keeps going up' is the result of two predominant things, good entries and good exits.
    The former I'm ok on, the latter not so good previously. The biggest risk period seems to be entries, because if you get it wrong there you go into an immediate loss.
    Entries is most vulnerable due to mindset you have it right, when in fact you have it wrong.
     
    #58     Dec 19, 2019
  9. pstrusi

    pstrusi

    I've often seen, backtesting several models, that it's always more profitable a Strategy or Model that always has a position than others that includes Flat positions. Intuitively, it seems a Flat position might be better as a defense mechanism, but the statistic evidence shows otherwise.
     
    #59     Dec 19, 2019
  10. themickey

    themickey

    Is this for long & short trading?
     
    #60     Dec 19, 2019