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 <[email protected]> wrote:
From: pcmoxon <[email protected]>
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);