Hi Mike,

Thanks ever so much for your help. It works a treat now.

Kind Regards,
Pete

--- In [email protected], "Mike" <sfclimb...@...> wrote:
>
> Pete,
> 
> It is not enough to just set the BuyPrice and SellPrice arrays. You must 
> include the logic in your Buy and Sell statements. It is only the Buy and 
> Sell statements that will determine whether or not a trade is taken.
> 
> e.g.
> BuyStop = Ref(H, -1);
> BuyPrice = Max(BuyStop, Low)
> Buy = ... AND High >= BuyStop;
> 
> Mike
> 
> --- In [email protected], "pcmoxon" <teklinkuk@> wrote:
> >
> > Sorry, I don't think I explained myself very well. The issue I am having is 
> > that the BuyStop & SellStop are not being executed in the correct location. 
> > It seems that as soon as a new bar is generated the BuyPrice & SellPrice 
> > get recalculated meaning the orders are executed at an incorrect price 
> > level. Is there some way of keeping the BuyPrice/SellPrice fixed?
> > 
> > Pete.
> > 
> > --- In [email protected], cas soni <soni67c@> wrote:
> > >
> > > Hello pcmoxon,you didn't use PLOT..add this lines  SetChartOptions(0, 
> > > chartShowDates); Plot(C,"Close",colorWhite,64);
> > > 
> > > 
> > > 
> > > PlotShapes(IIf(Buy , shapeSmallUpTriangle, shapeNone) ,colorGreen, 
> > > 0,L,-20); 
> > > 
> > > PlotShapes(IIf(Sell  , shapeSmallDownTriangle, shapeNone) ,colorRed, 
> > > 0,H,-20);
> > > 
> > > 
> > > 
> > > Plot(MA1,"\nDynPiv25",ParamColor("Color 
> > > 1",ColorRGB(238,174,238)),stylethick);
> > > 
> > > Plot(MA2,"\nDynPiv50",ParamColor("Color1 
> > > 2",ColorRGB(255,20,147)),styleline);
> > > and make sure your market start time / end time is correctly set
> > > 
> > > Thank you
> > > --- On Fri, 30/7/10, pcmoxon <teklinkuk@> wrote:
> > > 
> > > From: pcmoxon <teklinkuk@>
> > > Subject: [amibroker] Using BuyStop and SellStop orders - How does it work?
> > > To: [email protected]
> > > Date: Friday, 30 July, 2010, 12:01 AM
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > >  
> > >  
> > > 
> > > 
> > > 
> > >   
> > > 
> > > 
> > >     
> > >       
> > >       
> > >       Hi,
> > > 
> > > 
> > > 
> > > I am trying to test a simple MA Cross over system that uses Buy-Stop and 
> > > Sell-Stop orders. I can't for the life Of me workout how this should work.
> > > 
> > > 
> > > 
> > > What I want the system to do is only trade between the 'tstart' & 'tend' 
> > > parameter. When there is a MA-Cross set a BuyStop or Sell stop order at 
> > > the High/Low of the bar where the MA-Cross ocurred, so the trade is only 
> > > entered when the stop order is taken out.
> > > 
> > > 
> > > 
> > > I would be very gratefull if someone can take a look at my code below and 
> > > point me in the right direction to get this to work.
> > > 
> > > 
> > > 
> > > Thanks,
> > > 
> > > Pete
> > > 
> > > 
> > > 
> > > //
> > > 
> > >    //+----------------------------------------------------------+
> > > 
> > >    //| Variable/Parameters Start                                        |
> > > 
> > >    //+----------------------------------------------------------+
> > > 
> > > //        Set up the lengths for the moving averages
> > > 
> > > Length1    = Param("Fast MA",3,1,20,1);
> > > 
> > > Length2    = Param("Slow MA",30,21,80,1);
> > > 
> > > // Trade Times
> > > 
> > > tstart     = 070000; 
> > > 
> > > tend       = 150000; 
> > > 
> > > time_valid = TimeNum() >= tstart AND TimeNum() <= tend; 
> > > 
> > > 
> > > 
> > > //+----------------------------------------------------------+
> > > 
> > >    //| Buy Sell Logic                                                   |
> > > 
> > >    //+----------------------------------------------------------+
> > > 
> > > MA1 = MA(C,Length1);
> > > 
> > > MA2 = MA(C,Length2);
> > > 
> > > 
> > > 
> > > Buy   = Ref(Cross(MA1,MA2),-1) AND time_valid;
> > > 
> > > Short = Ref(Cross(MA2,MA1),-1) AND time_valid;
> > > 
> > > Sell = Short;
> > > 
> > > Cover = Buy;
> > > 
> > > 
> > > 
> > > BuyStop  = Ref(H,-1);
> > > 
> > > SellStop = Ref(L,-1);
> > > 
> > > 
> > > 
> > > BuyPrice  = Max( BuyStop, Low ); // make sure buy price not less than Low 
> > > 
> > > SellPrice = Min( SellStop, High ); // make sure sell price not greater 
> > > than High 
> > > 
> > > 
> > > 
> > > Buy  = ExRem(Buy,Sell);
> > > 
> > > Sell = ExRem(Sell,Buy);
> > >
> >
>


Reply via email to