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

Re: [amibroker] help for a formula



PureBytes Links

Trading Reference Links



hi Ravi,
 
some code below. This code does not do a backtest (although I added some necessary ingredients) since you did not define where your exits need to be but will get you started.
 
 
/*
how does one write a formula and which also gives visual buy and
sell arrows, and also runs for a back test......buy when 13 period
EMA crosses 21EMA on close (completed candle) of a 1 minute chart
with a condition that the 21 minute EMA of a 5 minute chart should
be above 13 EMA in 5 mins chart.
*/


SetBarsRequired(10000,10000
);
SetTradeDelays(0,0,0,0
);

SetOption("CommissionMode", 3
);
SetOption("CommissionAmount", 2.75
);
SetOption("FuturesMode",True
);
NumContracts =
1
;
PositionSize = NumContracts * MarginDeposit
;

starttime =
153000
;
endtime =
220000
;
timearray =
TimeNum() >= starttime AND TimeNum
() <= endtime;

per1 =
13
;
per2 =
21
;

Aema1 =
EMA(C
,per1);
Aema2 =
EMA(C
,per2);

// create 5min arrays

TimeFrameSet( in5Minute
);
Bema1 =
EMA(C
,per1);
Bema2 =
EMA(C
,per2);
TimeFrameRestore
();

// expand 5min arrays

Bema1 =
TimeFrameExpand( Bema1, in5Minute);
Bema2 =
TimeFrameExpand( Bema2, in5Minute
);

// buy constraint

Buy = Cross(Aema1,Aema2) AND
Bema2 > Bema1;
Buy = Ref(Buy,-1); BuyPrice = Open
;

// chart

SetChartOptions(0, chartShowDates
);
Plot(C,"Last=",colorWhite,64
);
Plot(Aema1,"Aema1",colorBlue,1
);
Plot(Aema2,"Aema2",colorGreen,1
);
Plot(Bema1,"Bema1",colorAqua,1
);
Plot(Bema2,"Bema2",colorYellow,1
);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15
);
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,L,-15
);
PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
 
 
 
 
----- Original Message -----
From: mravie7
Sent: Monday, April 20, 2009 12:46 PM
Subject: [amibroker] help for a formula

Hi,
how does one write a formula and which also gives visual buy and sell arrows, and also runs for a back test......
buy when 13 period EMA crosses 21EMA on close (completed candle) of a 1 minute chart with a condition that the 21 minute EMA of a 5 minute chart should be above 13 EMA in 5 mins chart.

Thanks in anticipation
Cheers
Ravi



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___