PureBytes Links
Trading Reference Links
|
Tip --
This is a copy of a response I sent to a newbie on 2/2/06.
I think this is what
you had in mind. One program -> two graphs.
(Doesn't use BackTester.)
1. Open AB editor and Copy code below thereto.
2. SaveAs with a name.
3. AFL check (icon). Fix any errors.
4. Select an unused sheet.
5. Insert indicator (icon) (twice).
6. You should now see two new graphs on the sheet (probably blank).
7. Right click the top new graph. Select Parameters->Axis and Grid.
8. Near bottom of new Axis and Grid find 'ChartId' number.
9. Enter number in place of '1486' in code.
10. Enter number+1 in place of '1487' in code.
11. Modify for your system, if that's sorta what you wanted.
// Trythis.afl
// simple system just to illustrate same
code displaying different
// charts on same sheet.
SetTradeDelays(1,1,1,1);
SetBarsRequired(100000,100000);
Filter
= 0;
// code to go long
Buy = Cross(MA(C, 10)*0.95, MA(C,20)); // I did say 'simple'
BuyPrice
= Open;
LongStop = Ref(L, -1);
Sell =
L <
LongStop;
Buy = ExRem( Buy, Sell );
Sell =
ExRem( Sell, Buy );
SellPrice = Min(Open, LongStop);
// code to go short
Short
= Cross(MA(C, 20), MA(C, 10)*1.05); // still simple
ShortPrice = Open;
ShortStop = Ref(H, -1);
Cover
= H
> ShortStop;
Short
= ExRem( Short, Cover );
Cover
= ExRem( Cover, Short );
CoverPrice = Max(Open, ShortStop);
// Plot charts
SetChartOptions(1,chartShowArrows|chartShowDates);
Plot(C,"Close",colorBlack,styleCandle);
// Chart for long trades
if(GetChartID()==1486){
Plot(LongStop,"LongStop",colorBlue,styleDots);
//PlotShapes(LongSetup*shapeUpArrow,colorBlack,0,L,-12);
// LongSetup not defined
PlotShapes(Buy*shapeUpArrow,colorGreen,0,L,-12);
PlotShapes(Sell*shapeDownArrow,colorRed,0,H,-12);
}
// Chart for short trades
if(GetChartID()==1487){
Plot(ShortStop,"LongStop",colorBlue,styleDots);
//PlotShapes(LongSetup*shapeUpArrow,colorBlack,0,L,-12);
PlotShapes(Cover*shapeHollowUpArrow,colorRed,0,L,-12);
PlotShapes(Short*shapeHollowDownArrow,colorGreen,0,H,-12);
}
tipequity wrote:
is it possible to plot to 2 different chart panes from within the
same
afl file? if so, how?
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
__,_._,___
|
|