Thanks cas soni, I appreciate your input, and adding the plot. The problem I am having is the sellprice and sellstop seem to be floating numbers and recalculated every day. I want them to be calculated once at entry, and remain that fixed value until a sell is triggered. Any help is much appreciated.
--- In [email protected], cas soni <soni...@...> wrote: > > Hello Jeff , > First let me say i am not an afl expert , > so please try this .... > ATRx = Optimize("ATR Multiplier", 3, 1, 5, 1); // ATR Multiplier > WATR = (Ref(ATR(8),-2)*8 + (ATR(1)*1.125) + (Ref(ATR(1)*1.125,-1)))/10; > //Weighted ATR (last 20% has a 12.5% weighting factor) > twentydayupper = Ref(HHV(H, 20), -1); > > > > Plot(C,"",3,64); > Plot(twentydayupper,"",7,1); > > > Buy = Cross(C, twentydayupper); > > BuyPrice=ValueWhen(Buy,C,1); > > Sellstop = BuyPrice - WATR*2; > > SellPrice = BuyPrice + WATR*ATRx; > Sell = Cross(Sellstop, C) OR Cross(C, SellPrice); > Plot(SellPrice,"sellprice",4,1); > Plot(Sellstop,"sellstop",6,1); > > PlotShapes(Buy*shapeUpArrow,colorGreen,0,L,-5); > PlotShapes(Sell*shapeDownArrow,colorRed,0,H,-5); > > AddColumn(ATRx, "ATRx"); > AddColumn(ATR(10), "ATR"); > AddColumn(WATR, "Weighted ATR"); > AddColumn(Ref(ATR(8),-2), "ATR(8) Two Days Ago"); > AddColumn(ATR(1)*1.125, "Weighted ATR Today"); > AddColumn(Ref(ATR(1)*1.125,-1), "Weighted ATR Yesterday"); > AddColumn(twentydayupper, "20 Day Upper"); > AddColumn(Sellstop, "Sellstop"); > AddColumn(SellPrice, "SellPrice"); > AddColumn(BuyPrice, "BuyPrice"); > AddColumn(C, "Close"); > > Filter=1; > Hope this helps > Thank you > > --- On Sat, 28/8/10, JEFF F <je...@...> wrote: > > > From: JEFF F <je...@...> > Subject: [amibroker] Formula Help Needed > To: [email protected] > Date: Saturday, 28 August, 2010, 8:53 PM > > > Â > > > > If one of the AFL experts out there could help me out, it would be greatly > appreciated. I do not understand why, in this formula the sell price is not > being executed according to my stops. Please understand this is a > work-in-progress and not meant to be a complete formula. I put in all the > columns to try and trace the calculations. I'm sure it is a simple answer, > but I seem to be missing it. > > ATRx = Optimize("ATR Multiplier", 3, 1, 5, 1); // ATR Multiplier > WATR = ((Ref(ATR(8),-2)*8) + (ATR(1)*1.125) + (Ref(ATR(1)*1.125,-1)))/10; > //Weighted ATR (last 20% has a 12.5% weighting factor) > twentydayupper = Ref(HHV(H, 20), -1); > > Sellstop = BuyPrice - WATR*2; > SellPrice = BuyPrice + WATR*ATRx; > > Buy = Cross(C, twentydayupper); > Sell = Cross(Sellstop, C) OR Cross(C, SellPrice); > > AddColumn(ATRx, "ATRx"); > AddColumn(ATR(10), "ATR"); > AddColumn(WATR, "Weighted ATR"); > AddColumn(Ref(ATR(8),-2), "ATR(8) Two Days Ago"); > AddColumn(ATR(1)*1.125, "Weighted ATR Today"); > AddColumn(Ref(ATR(1)*1.125,-1), "Weighted ATR Yesterday"); > AddColumn(twentydayupper, "20 Day Upper"); > AddColumn(Sellstop, "Sellstop"); > AddColumn(SellPrice, "SellPrice"); > AddColumn(BuyPrice, "BuyPrice"); > AddColumn(C, "Close"); > > Filter=1; > > Any help is appreciated >
