[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] LineArray to start day after buy signal



PureBytes Links

Trading Reference Links

Hi All

I think I have the basics of LineArray.

The code below shows the lines starting at the Open of
today, if today gives the Buy Signal.

However I will enter the trade tomorrow, so I need the
LineArray to start at the Open of tomorrow.

How to achieve this?

********************

// set linearrays for x% annualized return.
// to use in Trading plan for exits.

EMAtimeperiod =
Param("ematimeperiod",25,10,50,1);//vary the ema

Buy = Cross( Close,EMA(C,EMAtimeperiod));

BuyPrice = O;
//set minimum annualized returns.
Mingain = Param("mingain",1.2, 1.1, 2.0, 0.05);
//set maximal annualized returns to trigger an exit
Maxgain = Param("maxgain", 2.0 , 2.0 , 5.0, 0.5);
//define the wait period after buy
WP = Waitperiod = Param("waitperiod", 1, 0, 30, 1);

x0 = LastValue(ValueWhen(Buy,BarIndex() + WP,1 ) );
y0 = LastValue(ValueWhen(Buy, BuyPrice,1));// what to
use here?
x1 = x0 + 260;// one trading year
y1 = y0 * Mingain;
y2 = y0 * Maxgain;
MingainLine = LineArray(x0,y0,x1,y1,0,1);
Maxgainline = LineArray(x0,y0,x1,y2,0,1);

Plot(C, "", 1, 64);
Plot(EMA(C,EMAtimeperiod),"", colorGreen,1);
PlotShapes(shapeUpArrow * Buy, colorBlue, 0 , L, -15);
Plot(mingainLine, "line", colorGreen, 1);
Plot(Maxgainline,"maxgain",colorRed,1);

printf("barindex   = " + BarIndex());
printf(" \n buyprice  = " + BuyPrice);
printf("\n valuwhen buy  = " + ValueWhen(Buy,C,1));

**************

Any suggestions appreciated.

Regards

ChrisB

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/