DEAR SIR HOWARD,
i am very much pleased to hear from expert like you. sir, i have read your both books & i want to congratulate you for porviding such a informative books on trading system & amibroker. once again i feel exteremly delighted to communicate with the expert in subject. sir, i am 100 % agreed on what you said about scalin-in & scaling-out. but as you have rightly pointed to test the alternative i want the coading help from experts like you in the forum. sir, i have also found that if we use bearkout trading strategy for n numer of security at time( ie multiple positions),the probability of win is around 30-40 % average. To be profitable in such situation only alternate is to increase reward to risk ratio. for that if we use the strategy i sugessted we can improve system performance to considerable extent. To clarify my point i would like to give one simple example. Say we have entered in 10 script with 1/4 of position in each. out of 10, 6 trades turn out to be loosser on a/c of stop loss hit. if we scalil-in to the profitable trades such that ultimate position values for profitable trades far exceeds looses.i think i have cleared my idea. to test above logic i want some help in coading. request all seniour help. thank you again bandy sir. asit. To: [email protected] From: [email protected] Date: Wed, 2 Dec 2009 04:32:03 -0700 Subject: Re: [amibroker] Re: "smart" trail stop Greetings -- As a way of testing whether scaling-in works for your trading system, you might code up two separate trading systems. The first takes a position at your first signal. The second takes a position when you already have your first signal and then receive your scale-in signal. Comparing the results of the two will give an indication of whether your system should take its full position immediately, or takes its full position at the scale-in signal, or use the scale-in method. For most systems, the best results come from taking a full position at one of the two signals, rather than scale-in using both signals. The same thing applies to scaling-out. For most systems, the best results come from a complete exit at a sell signal. But test to learn how your system acts. Thanks, Howard On Tue, Dec 1, 2009 at 9:11 PM, asitasu <[email protected]> wrote: hi mark, exellent job by throwing light on risk/trade management. i have few sugessions to make about different way of putting smart stop. and different way to manage trade to lock & increase profit potential. i am not good at writting afl so if you can incorporate following strategy in the afl & give your opinion i would be highly oblige. it would be great for rest of our trader community to understang different way of managing trade. my system(for one position only) : buy as per your or any rule. hear initial position = 1/4 th of max permissable position as per money management rule(whichever we follow) say for simplysity 100 shares(ie fix position sizeing method) initial position = 25, scale-in 1/4 position as soon as traling stop initiated. scale-in remaining position at buyprice + 4*ATR sell & trade management as follow 1) put initial stop loss at time of entry to low of privious 3 bar lowest low minus filter(this is fix stop). 2) as soon as trade moves to 2*ATR in favour of trade( current price > buyprice+2*ATR. cancell above stop & follow trailing stop. trailing stop = low < ideal bar low. ideal bar = bar which close at lower than priviou 3 bar low. 3) after current price > buyprice + 6*ATR. change trailing stop = low < privious bar low - filter in my opinion this system will produce optimum return on risk. kindly favour me in coading above mehod. asit. --- In [email protected], "de_techneut" <twistedcha...@...> wrote: > > Hi Mark, > > thanks for sharing this code. > this will definitely help me in my further study of the market. > > I am just starting in Amibroker so i'm not yet an accomplished programmer. (i > doubt i ever will be) > > I know it's probably an open door but here it is anyway: > a good stoploss is indeed essential to all trading systems. > what is equally important, imo, is a good profit target mechanism as a way to > get out of a trade. > > I find the classic pivots to do a marvelous job at that. > I usually calculate pivots depending on the time frame i'm trading, (around > 30 to 60 bars) i.e. 1 hour pivots for a minute chart or weekly pivots for a > hourly chart. > > hope this helps you in some way. > > Thanks for sharing, > > Marc. > > > > --- In [email protected], "r22mark" <mtf_79@> wrote: > > > > Hi. > > > > Money / risk management is an area of interest to me. I have tried to > > create a "smart" trailing stop, one that adjusts itself. There is also some > > stuff that people may not have encountered - Fixed Fractional Position > > Sizing with margin (to mimic CFD's) , various buy "filters", PositionScore, > > and the Graph / indicator plot code is handy for displaying trade arrows, > > and trade prices. Hope there is something of use for you. This is NOT a > > ready to trade system - you will likely find results are poor. It IS an > > example of what can be done other than a basic trail stop. This is an > > ongoing project. Plot it or drag it onto a chart to view / adjust the > > parameters. > > > > The risk management side has: > > - initial stop set at 20%. > > - after 5 days stop raised /risk reduced by 50% > > - stop moved to break even after 10 days > > - after 15 days stop raised / risk reduced by 50% > > - at any time you have 3 lower lows, risk is reduced by 25%, every time. > > - these can all adjusted via parameters. > > > > Again this is a code in progress, I use Plot() to verify what is happening > > at each bar. If you want to check my work, uncomment them. Let me know if > > you find any errors. > > > > So people. Comments? Ideas? Feedback? I haven't heard of anyone doing > > "smart" trail stops. Or am I am just wasting my time? > > > > Mark > > > > > > SetTradeDelays (0,0,0,0); > > SetOption("InitialEquity", 100000); > > SetOption("AccountMargin", 10); // only put up 10% funds, buying power x 10 > > SetOption("CommissionMode", 1); > > SetOption("CommissionAmount", 0.10); // .1% commission per entry / exit > > SetOption("MaxOpenPositions", 12); > > SetOption("AllowSameBarExit", True); > > > > // FIXED FRACTIONAL POSITION SIZING > > CapRisk = Param("CapitalRisk", 2, 1,5,0.5); // capital risk % > > MaxCap = 10; // max capital % in one trade (10% capital = 2% stop) > > StopPct = Param("StopPct", 20, 1,25,1)/100; // stop % - initial risk > > FFRisk = Min(CapRisk/(StopPct*BuyPrice)*BuyPrice/10, MaxCap); > > "FF risk = " +WriteVal(ffrisk, 1.2); > > SetPositionSize(FFRisk * 10, spsPercentOfEquity); > > > > > > // POS SCORE - BANG FOR BUCK ($10,000) > > B4B = 10000/Ref(C,-1)*Ref(ATR(200),-1)/100; > > "10k BFB = " +WriteVal(B4B, 1.2); > > PositionScore = B4B; > > > > > > // INDEX TREND FILTER - 2 x moving averages > > SetForeign("$DJ"); // change to whatever index is of interest > > IFa = Param("IF FMA", 30,0,100,5); IFb = Param("IF SMA", 100,0,300,5); > > IFx = EMA(C,IFa); IFy = MA(C,IFb); IndexFilter = IFx > IFy; > > //Plot(IFx, "IF FMA", colorBlue, styleLine); Plot(IFy, "IF SMA", > > colorOrange, styleLine); > > //PlotForeign("XAO", "All Ords", colorBlack, styleLine); > > //Plot(IndexFilter,"Index Filter", colorBlack, styleLine); > > RestorePriceArrays(); > > > > > > // TREND FILTER - 2 x moving averages > > j = Param("FMA", 30,0,50,5); k = Param("SMA", 100,0,100,5); > > FMA = EMA(C,j); SMA = EMA(C,k); TF = FMA > SMA; > > //Plot(FMA, "FMA", colorBlue, styleLine); Plot(SMA, "SMA", colorOrange, > > styleLine); > > > > > > // VOL FILTER - MONEY FLOW > $1 MILLION > > VF = EMA(V*C,21) > 1000000; > > Filter = VF; AddColumn(VF, "volFilter"); AddColumn(EMA(V*C,21), "V*C", > > 1.2); // leaves approx 225 from ASX 300 > > > > BDC1 = Param("#buydays", 20, 5,50,5); > > BDC2 = Param("#buydays2", 70, 5,100,5); > > Cond1 = H > Ref(HHV(H,BDC1),-1) + 0.01; > > Cond2 = H > Ref(HHV(H,BDC2),-1) + 0.01; > > Buy = Cond1 AND Cond2 AND IndexFilter AND VF AND TF; > > BuyPrice = Max(O, Ref(HHV(H,BDC1),-1) + 0.01); > > > > Sell = 0; > > > > // REDUCE RISK - RAISE STOP X 2, RAISE TO BREAKEVEN, TIGHTEN AFTER 3 DOWN > > DAYS > > MSD = Param("#DaysB4MoveStop1", 5, 0,50,1) -1; // needs -1 to calculate > > correctly > > RSP = (100-Param("%raiseStop1By", 50, 0, 100, 5)) / 100; > > MSD2 = Param("#DaysB4MoveStop2", 15, 0,50,1) -1; > > RSP2 = (100-Param("%raiseStop2By", 50, 0, 100, 5)) / 100; > > MSBE = Param("#DaysB4MoveStopBE", 10, 0,50,1) -1; > > TSDM = 1 + Param("%raiseStop3DownDays", 25, 0,100,5) / 100 * StopPct; > > WriteVal(tsdm); > > IS = BuyPrice - (BuyPrice*StopPct); > > NS = Ref(C,-1) - (Ref(C,-1)*StopPct); // initial stop > > NS2 = Ref(C,-1) - (Ref(C,-1)*StopPct*RSP); // reduce risk > > NS3 = Ref(C,-1) - (Ref(C,-1)*StopPct*RSP*RSP2); // reduce risk again > > > > > > TS = 0; OpenPos = 0; j = 0; BES = Null; TSD = 0; LowDown = 0; > > TSa = Null; Spa = Null; ja = Null; nsa = Null; ns2a = Null; > > bpa = Null; besa = Null; ns3a = Null; TSDa = Null; Checka = Null; > > > > for(i=1; i<BarCount; i++) > > { > > if(Buy[i] AND OpenPos == 0 AND TS[i] == 0) { > > Buy[i] = 1; > > bpa[i] = BuyPrice[i]; > > bes[i] = BuyPrice[i] * 1.005; // .5% to cover comissions, etc > > besa[i] = bes[i]; > > TS = IS[i]; > > OpenPos = 1; > > j = 0; > > TSD = L[i] - TS; > > TSDa[i] = TSD; > > } > > else Buy[i] = 0; > > if(OpenPos == 1 AND TS[i] > 0 AND L[i] <= TS[i]) { > > Sell[i] = 1; > > SellPrice[i] = Min(O[i], TS[i]); > > SPa[i] = SellPrice[i]; > > TS = 0; > > OpenPos = 0; > > j = 0; > > BES[i] = 0; > > TSD = 0; > > TSDa[i] = TSD; > > LowDown = 0; > > } > > else Sell[i] = 0; > > // reduce risk after x days, first time > > if(TS[i] > 0 AND j <= MSD) { > > TS = Max(TS[i], NS[i]); > > TSa[i] = TS[i]; > > NSa[i] = NS[i]; > > } > > if(TS[i] > 0 AND j > MSD) { > > TS = Max(TS[i], NS2[i]); > > TSa[i] = TS[i]; > > NS2a[i] = NS2[i]; > > } > > // reduce risk after x days, second time > > if(TS[i] > 0 AND j >= MSD2) { > > TS = Max(TS[i], NS3[i]); > > TSa[i] = TS[i]; > > NS3a[i] = NS3[i]; > > } > > // raise stop to BE after x days > > if(OpenPos == 1) { > > BES[i] = Max(BES[i], BES[i-1]); > > BESa[i] = BES[i]; > > } > > if(OpenPos == 1 AND j == MSBE) { > > TS = Max(TS[i], BES[i]); > > TSa[i] = TS[i]; > > BESa[i] = BES[i]; > > } > > // TSD getting smaller over last 3 days > > if(TS[i] > 0) { > > TSD[i] = L[i] - TS[i]; > > TSDa[i] = TSD[i]; > > if(TSD[i] < TSD[i-1] AND TSD[i-1] < TSD[i-2] AND TSD[i-2] < TSD[i-3]) { > > TS = Max(TS[i], TS[i] * TSDM); > > TSa[i] = TS[i]; > > LowDown = 1; > > Checka[i] = LowDown; > > } > > } > > j++; ja[i] = j; > > } > > > > Plot(TSa, "Trail Stop", colorBlue, styleLine); > > //Plot(bpa, "buyprice", colorGreen, styleLine); > > //Plot(spa, "sellprice2", colorRed, styleLine); > > //Plot(ja, "j", colorBlack, styleNoLine); > > //Plot(NSa, "NS", colorBlack, styleLine); > > //Plot(NS2a, "NS2", colorOrange, styleLine); > > //Plot(NS3a, "NS3", colorBrown, styleLine); > > //Plot(besa, "BES", colorBrightGreen, styleLine); > > //Plot(TSDa, "TSD", colorRed, styleLine); > > //Plot(Checka, "checkTSD", colorGreen, styleLine); > > > > > > // GRAPH / INDICATOR PLOT > > arrows = ParamToggle("Show Buy / Sell arrows?", "Yes please", 0); > > if(arrows == 1) { > > PlotShapes(Buy*shapeUpArrow,colorBrightGreen,0,Low); > > PlotShapes(Sell*shapeDownArrow,colorRed,0,High); > > } > > bliss = ParamToggle("Show Buy / Sell Prices", "Oh yeah! ",0); > > if(bliss == 1) { > > PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone),colorBrightGreen, 0, > > BuyPrice, 0 ); > > PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone),colorRed, 0 ,SellPrice, > > 0 ); > > FirstVisibleBar = Status( "FirstVisibleBar" ); > > Lastvisiblebar = Status("LastVisibleBar"); > > for( b = Firstvisiblebar; b <= Lastvisiblebar AND b < BarCount; b++) > > { > > if( Buy[b] ) PlotText("\n Buy\n > > "+NumToStr(BuyPrice[b],1.2),b,BuyPrice[b],colorBrightGreen); > > else if( Sell[b] ) PlotText("\n Sell\n > > "+NumToStr(SellPrice[b],1.2),b,SellPrice[b],colorRed); > > } > > } > > > _________________________________________________________________ New Windows 7: Find the right PC for you. Learn more. http://windows.microsoft.com/shop
