Australian (ASX) Stock Market Forum

Amibroker System Backtesting

As far as I know the apply stop does not show in the exploration

I think that you will find the ApplyStops only works in BackTest mode hence the difference in Explore results.

Also the backtest results of the published system ( which I cannot replicate ) only has a couple of regular stops on the results when run over the entire XAO and I believe this is why you have the difference in the explore.

I believe that this line is incorrect and maybe the AND's should be OR's

Sell = C < MA( C, 50 ) AND NoStrength AND NoUpTrend;

Sell = C < MA( C, 50 ) OR NoStrength OR NoUpTrend;

This is problem with using someone else's code as it tends to throw up more questions than answers.

In Summary...Your trail stop is not the issue, but you could play with levels as per below to try to mimic the ApplyStop

Code:
StopLevel = 1 -(ts/100);

trailARRAY = Null;
trailstop = 0;
TrailStopSell = 0; // added from @Trav code


for( i = 1; i < BarCount; i++ )
 {
   if( trailstop == 0 AND Buy[ i ] )
    {
       trailstop = High[ i ] * stoplevel [i];  // was "* stoplevel;"
    }
    else Buy[ i ] = 0; // remove excess buy signals
   if( trailstop > 0 AND Low[ i ] < trailstop )  //was "Low"
    {
       TrailStopSell[ i ] = 1; // was "Sell[ i ] = 1;"
       //SellPrice[ i ] = trailstop;
       trailstop = 0;
    }
   if( trailstop > 0 AND TrailStopSell [i] == 0)   //was " if( trailstop > 0 )"
    {   
       trailstop = Max( High[ i ] * stoplevel [i], trailstop );
       trailARRAY[ i ] = trailstop;
    }
}
 
Also I find it easier to trouble shoot these types of issues if you plot the stops

Trail Stop and ApplyStop below

Code:
InTrade = Flip(Ref(Buy,-1),Ref(Sell,-1));
Plot(IIf(InTrade, TrailArray, Null),"Trailing Stop Level", IIf(IndexBuyFilter == 0, colorYellow, colorRed), styleLine, Null, Null, 0, -1, 1);

//Equity (1) works as 0 but additionally updates buy/sell/short/coverarrays so all redundant signals are removed exactly as it is done
//internally by the backtester plus all exits by stops are applied so it is now possible to visualise ApplyStop() stops
Equity( 1 );

bi = Barindex();
fvb = FirstVisiblevalue( bi );
lvb = LastVisiblevalue( bi );
dist = 1.5*ATR(10);
sellorcovertrigger = "Regular,Stop,Profit,Trail,N-bars,Ruin"; // Stop types 1, 2, 3, 4, 5, 6 (list starts at 0)

for( i = fvb; i <= lvb; i++ )
{
    if( Buy[i] )
        PlotText( "Buy\n" + BuyPrice[i], i, BuyPrice[i] - dist[i], colorGreen, -1, 0 );
    if( Sell[i] )
        PlotText( StrExtract(sellorcovertrigger, Sell[i]-1) + "\n" + SellPrice[i], i, SellPrice[i] + dist[i], colorRed, -1, 0 );
   
}
 
Also I find it easier to trouble shoot these types of issues if you plot the stops

Agreed, plotting does assist for clarity. Your code is great. Still trying to work out why the looping stop does not generate as many buys.

I only used the Skates VIX strategy as an example. I will drop back to a simpler buy sell system to see whether that gives me better insight.

My prime objective is an exploration that shows all stops, including trailing stops. Your code in the original post has done this. My problem was that I haven't been able to align the various buys that either alternative generates.

The main problem is that I am all thumbs in Amibroker coding - sometimes I get there, other times I stumble.

Thanks again for you help :)
 
@trav, I see that you (and some other guys) constantly copy codes from other sources without giving reference to original source (yes, in the code).
Stop it! Internet is not a gabbing box to adorn oneself with borrowed plumes. Show some respect for christ sake.
 
@trash code is available within the AmiBroker help files and across numerous sites on the internet and to reference the original source is no way practical, and if you think that these threads are here to adorn oneself with borrowed plumes then you don't know me and basically you can get stuffed.

With post like yours I am sure that people will shy away from the forum with fear from being attacked which I see all to often on the AmiBroker forum. People have to learn somewhere and the majority of us don't come from a programming background so we all try to help each other the best we can, and if this upsets you then get over it.
 
@trav, I see that you (and some other guys) constantly copy codes from other sources without giving reference to original source (yes, in the code).
Stop it! Internet is not a gabbing box to adorn oneself with borrowed plumes. Show some respect for christ sake.

@trash, @trav has created a useful thread here that is very educational. In fact, he has also created other educational Amibroker threads here at ASF. Given that his purpose is to educate and assist others, not to "adorn [himself] with borrowed plumes" why is referencing others even an issue? Who is hurt? Surely there are more important things to be concerned about.

I looked through your post history and it seems that you have been angry at the world for quite some time now. Perhaps you should consider meditation and find some peace within.
 
@trash code is available within the AmiBroker help files and across numerous sites on the internet and to reference the original source is no way practical, and if you think that these threads are here to adorn oneself with borrowed plumes then you don't know me and basically you can get stuffed.

With post like yours I am sure that people will shy away from the forum with fear from being attacked which I see all to often on the AmiBroker forum. People have to learn somewhere and the majority of us don't come from a programming background so we all try to help each other the best we can, and if this upsets you then get over it.

Keep up the great posts @Trav. I find your posts on ASF some of the best and I personally don't care where you get code from. Your intent is honorable and IMHO you only seek to educate people on AB and AFL code.
 
Top