Stock Portfolio Organizer
The ultimate porfolio management solution.
Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Hi Low Trailing Stop for Amibroker (AFL)
Copy & Paste Friendly
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | // STAMP CODE NAME GfxSelectFont ( "Tahoma" , 15, 700 ); GfxSetBkColor ( colorGreen ); GfxSetTextColor ( colorBlack ); GfxTextOut ( "High Low Trailing Stop" , Status ( "pxwidth" )/1.25, Status ( "pxheight" )/50); GraphXSpace =5; //====== Original TT by X ======== //------ Setting ----------------- SetOption ( "InitialEquity" ,1000000); SetTradeDelays ( 0, 0, 0, 0 ); RoundLotSize = 100; BuyPrice = Close ; SellPrice = Close ; SetOption ( "maxopenpositions" ,1); PositionSize=-100; PcntOffset = 0; function Hstop_func() { trailArray[ 0 ] = L [ 0 ]; // initialize for ( i = 1; i < BarCount ; i++ ) { prev = trailArray[ i - 1 ]; if ( C [ i ] >= prev AND C [ i - 1 ] >= prev) // Long Side This Day and Previous Day > Trailing { if ( H [i]> H [i-1]) // Make New High trailArray[ i ] = ( Max (prev, L [i-1]))*(1-PcntOffset/100); else // No New high trailArray[ i ] = prev; } else if ( C [ i ] < prev AND C [ i - 1 ] < prev) // Short Side This Day and Previous Day < Trailing { if ( L [i]< L [i-1]) trailArray[ i ] = ( Min (prev, H [i-1]))*(1+PcntOffset/100); else trailArray[ i ] = prev; } else if ( C [ i ] < prev AND C [ i - 1 ] >= prev) // Short Point { trailArray[ i ] = ( Max ( H [i], H [i-1]))*(1+PcntOffset/100); //C[ i ] - trBull[ i ]; stoploss[i-1]=1; } else //Long Point { trailArray[ i ] = ( L [i])*(1-PcntOffset/100); //C[ i ] + trBear[ i ]; } } return trailArray; } trailArray = Hstop_func(); Buy = Cross ( C ,trailarray); Sell = Cross (trailarray, C ); //====== Ploting ======================================== // ----- Chart Optiion ---------------------------------- _N (Title = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 ) ) )); SetChartOptions (0, chartShowDates ); //------ Channel ---------------------------------------- Plot ( Close , "Price" , IIf ( Close > Open , colorDarkGrey , colorDarkGrey ), styleCandle ); Plot ( trailarray, "Stop Loss" , IIf ( C <trailarray, colorRed , colorBlack ), styleStaircase + styleDots ); // ----- Buy and Sell ----------------------------------- Buy = ExRem ( Buy , Sell ); Sell = ExRem ( Sell , Buy ); PlotShapes ( IIf ( Buy , shapeUpArrow , shapeNone ), colorGreen , 0, L , Offset=-45); PlotShapes ( IIf ( Sell , shapeDownArrow , shapeNone ), colorRed , 0, H , Offset=-45); |