hi,

below I adjusted your code for the simplified sell algorithm. Like the buyPrice 
you can now also display the sellprice. Best to go from there. Expand your sell 
algorithm and look if you can display it, that will help you to see what your 
code is doing, rgds, Ed

SetBarsRequired(10000,10000); 

Entrypt=HHV(H,3); 

Buy= Cross(H,Ref(Entrypt,-1)); 
BuyPrice=ValueWhen(Buy,Max(O,Ref(Entrypt,-1))); 

//MaxTRADECLOSE=Ref(HighestSince(Buy,C),-1); 

Sell= L < Ref(LLV(L,5),-1);// OR (Maxtradeclose-BuyPrice) > 2*ATR(10); 
SellPrice=ValueWhen(Sell,Min(O, Ref(LLV(L,5),-1))); 

Buy = ExRem(Buy,Sell); 
Sell = ExRem(Sell,Buy); 

Plot(BuyPrice,"buyprice",colorBlue,styleLine); 
Plot(SellPrice,"maxtradeclose",colorLightBlue,styleLine); 

SetChartOptions(0, chartShowDates); 
Plot(C,"Last=",colorBlack,64); 

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15); 
PlotShapes(IIf(Buy,shapeHollowCircle,shapeNone),colorGreen,0,BuyPrice,0); 
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15); 
PlotShapes(IIf(Sell,shapeHollowCircle,shapeNone),colorRed,0,SellPrice,0); 




  ----- Original Message ----- 
  From: cagigas00 
  To: [email protected] 
  Sent: Friday, July 11, 2008 11:08 AM
  Subject: [amibroker] Buyprice changes while long



  The following code replicates the problem I am having with a system. The 
buyprice is suppossed to be constant while the system is long, however it keeps 
changing. How can I make the Buyprice a constant?

  Thanks

  Oscar

  //COND//

  Entrypt=HHV(H,3);

  //ENTRY SIGNAL//

  Buy= H > Ref(Entrypt,-1);

  BuyPrice=ValueWhen(Buy,Ref(Entrypt,-1));

  //EXIT SIGNAL//

  MaxTRADECLOSE=Ref(HighestSince(Buy,C),-1);

  Sell= L < Ref(LLV(L,5),-1) OR (Maxtradeclose-BuyPrice) > 2*ATR(10);

  //REMOVE EXCESIVE SIGNALS//

  Buy=ExRem(Buy,Sell);

  Sell=ExRem(Sell,Buy);

  //PLOT BUY AND SELL POINTS//

  Plot(C,"Last=",colorBlack,styleBar|styleThick);

  PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);

  PlotShapes(IIf(Buy,shapeHollowCircle,shapeNone),colorGreen,0,BuyPrice,0);

  PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);

  PlotShapes(IIf(Sell,shapeHollowCircle,shapeNone),colorRed,0,SellPrice,0);

  //AUX//

  Plot(Buy,"buy",colorRed,styleLine|styleOwnScale);

  Plot(BuyPrice,"buyprice",colorBlue,styleLine);

  Plot(Maxtradeclose,"maxtradeclose",colorGreen,styleLine);


   

Reply via email to