- Joined
- 15 February 2012
- Posts
- 51
- Reactions
- 0
Add this for visualization ----- also Ed's code
// chart
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
chartflag = ParamToggle("Heikin Ashi","show|hide",1);
if (chartFlag)
{
Plot( C, "\nPrice",colorWhite, styleCandle );
}
else
{
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Modified " + Name(), colorWhite,
styleCandle );
}
PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10);
PlotShapes(shapeSmallCircle*PHigh,colorRed,0,H,10);
Study on this ----- not Ed's code.
This gives you the values of the preceding, opposite-side pivot values. IOW, at the pivot-low, the prior-high price is known. At the pivot-high, the prior-low price is known.
PriorHigh = ValueWhen(PLow,PHighPrice);
PriorLow = ValueWhen(PHigh,PLowPrice);
Perhaps these will help. Place this plot-code in a separate pane below the previous code (Ed's pivots)----then you'll be able to see the timing for the flags and arrays. Comment out these plot statements as desired.
Plot( PHigh, "High_flag", colorRed, styleHistogram | styleOwnScale );
Plot( PLow, "Low_flag", colorGreen, styleHistogram | styleOwnScale );
Plot( PHighPrice, "High",colorBlue );
Plot( PLowPrice, "Low",colorBrown );
Plot( PriorHigh,"Prior_H",colorGreen );
Plot( PriorLow,"Prior_L",colorViolet );
The "instance" number in the ValueWhen function is the key. It looks back the desired number of flags---then gathers the designated array.
TwoHighsAgo = ValueWhen(PLow,PHighPrice,2); // note the "instance" number
TwoLowsAgo = ValueWhen(PHigh,PLowPrice,2); // note the "instance" number
Good luck with your study GB --- this is a good example from which to learn. I'm new at this code stuff myself, but am glad I could help out a fellow student.
_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
Sellperiods=Param("Exit Breakout",5,1,100,1,1);
Buy =Cross( C, Ref( HHV(H,Buyperiods), -1 )) ;
Sell=Cross(Ref(LLV(Low,Sellperiods),-1),C);
//Buy=Ref(Buy,-1); // entry on same bar
//Sell=Ref(Sell,-1);
Cover=Buy; // [B]need a better cover code here[/B]
Short=Sell; // [B]need a better exit code here[/B]
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
//BuyPrice=O;//ValueWhen(Buy,C,1);
//SellPrice=O;//ValueWhen(Sell,C,1);
SellPrice = Min(Ref(C,-1),Open); //.
BuyPrice = Max(Ref(C,-1),Open); //
//Cover=ExRem(Cover,Exit);
//Exit=ExRem(Exit,Cover);
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), 51, layer = 0,yposition = Low, offset = -15);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), 42, layer = 0, yposition = High, offset = -15);
//PlotShapes( IIf( Exit, shapeDigit7, shapeNone ), 51, layer = 0, ypo
//PlotShapes( IIf( Cover, shapeDigit4, shapeNone ), 25, layer = 0,yposition = sition = High, offset = 15);
TrailStop = HHV( C - 2 * ATR(10), 15 );
ProfitTaker = EMA( H, 13 ) + 2 * ATR(10);
/* plot price chart and stops */
Plot( TrailStop, "Trailing stop", colorBrown, styleThick | styleLine );
Plot( ProfitTaker, "Profit taker", colorLime, styleThick );
_SECTION_END();
("Trendlines Multitimeframe ");
// Amibroker AFL code by Edward Pottasch, 6/8/2011
Hi sr114,
Not really sure who the "we" are (alluded to, in your post), but I'll play along. Besides, it's a decent topic and I don't have much going on this weekend;~).
First off, why the usage of ConstantRangeBars (CRB) ? Yes, it seems obvious that for a range-breakout system that those would be reasonable......but, does the methodology work with ConstantVolumeBars (or just "regular" bars)? I'm not trying to be an ***hole, just curious.
Second, as to the usage of Ed's trendline stuff: Do trendlines applied to CRB charts behave in the same manner (wrt any possible advantage to the trader) as the "standard" trendlines that are most commonly studied? Lots of rhetorical questions here.......simply thinking out loud.
Later,
RutheezKey
I am always happy to help anyone with writing AFL for AB. I am a regular in the AB yahoo group, AB website forum, RC and other places.
"I am new to AB(with little programming experience) and want to develop a rotational trading system using the EnableRotationalTrading command - however am unable to get the program set to the data list I want to use - have tried the Filters and Symbols select, etc, but never get, say, the S&P500. I would appreciate your help. Paul
_SECTION_BEGIN( "Point & Figure w Values adj" );
//mandeep Singh 05-Jan-2009
GfxSetBkColor(colorBlack);
GfxSetTextColor( colorOrange );
GfxSelectFont("Times New Roman", 10, 700, True );
GfxTextOut("man4urheart.blogspot.com", 10 , 0 );
GraphXSpace = 5;
SetChartBkColor( ParamColor( "BackGroundColor", colorBlack) );
//GraphColor = ParamColor("GarphColor",colorLightGrey);
GridColor = ParamColor( "GridColor", colorLightGrey );
Scaling = ParamList( "Scaling Method", "Traditional|Percentage|AVG True Range" );
if ( scaling == "Traditional" )
{
Box = Param( "Box", 1, 0.2, 100, 0.1 );
}
else
if ( scaling == "Percentage" )
Box = Param( "Box ", 1, 0.2, 10, 0.1 ) / 100 * LastValue( C );
else
if ( scaling == "AVG True Range" )
Box = Param( "Box", 1, 0.3, 5, 0.1 ) * LastValue( ATR ( 20 ) );
shiftChart = 0;
shiftLastClose = 1;
shiftGrid = 7;
shiftPriceAxis = 2;
Reverse = Param( "Reverse", 3, 1, 5 );
j = 0;
PFL[0] = Box * ceil( Low[0] / Box ) + Box;
PFH[0] = Box * floor( High[0] / Box );
direction = 0;
for ( i = 1; i < BarCount; i++ )
{
if ( direction[j] == 0 )
{
if ( Low[i] <= PFL[j] - Box )
{
PFL[j] = Box * ceil( Low[i] / Box );
}
else
{
if ( High[i] >= PFL[j] + Reverse*Box )
{
j++;
direction[j] = 1;
PFH[j] = Box * floor( High[i] / Box );
PFL[j] = PFL[j - 1] + Box;
}
}
}
else
{
if ( High[i] >= PFH[j] + Box )
{
PFH[j] = Box * floor( High[i] / Box );
}
else
{
if ( Low[i] <= PFH[j] - Reverse * Box )
{
j++;
direction[j] = 0;
PFH[j] = PFH[j - 1] - Box;
PFL[j] = Box * ceil( Low[i] / Box );
}
}
}
}
delta = BarCount - j - 1;
direction = Ref( direction, - delta );
Hi = Ref( PFH, -delta ) + Box / 2;
Lo = Ref( PFL, -delta ) - Box / 2;
Cl = IIf( direction == 1, Hi, Lo );
Op = IIf( direction == 1, Cl - Box, Cl + Box );
Graphcolor = IIf( direction == 1, ParamColor( "X_Color",colorBrightGreen ),
ParamColor( "O_Color", colorRed ) );
PlotOHLC( Op, Hi, Lo, Cl, "", GraphColor , stylePointAndFigure | styleNoLabel, 0, 0 , shiftChart );
PlotOHLC( Op, Hi, Lo, Cl, "", GraphColor , stylePointAndFigure | styleNoLabel, 0, 0 , shiftChart );
Last = Ref( LastValue( C ), -( BarCount - 1 ) );
Plot( Last, "", colorRed, styleNoLine | styleDots, 0 , 0,shiftLastClose );
// selected value
Value = IIf( direction > 0, SelectedValue( Hi ) - box / 2,SelectedValue( Lo ) + box / 2 );
//----------------------------------------------------------
// GRID CONSTRUCTION
//----------------------------------------------------------
PlotGridLines = ParamToggle( "PlotdGrid", "Yes! |No", 1 ) ;
if ( PlotGridLines ==1)
{
begin = SelectedValue( BarIndex() );
end = LastValue( BarIndex() );
period = end - begin + 1;
if ( begin < end )
{
ScreenHigh = LastValue( HHV( cl, period ) );
ScreenLow = LastValue( LLV( Cl, period ) );
top = LineArray( begin - shiftGrid, screenHigh, end, screenhigh, 0 ,
1 );
Bot = LineArray( begin - shiftGrid, screenlow, end, screenLow, 0, 1 );
Plot( top, "", gridColor, styleLine | styleNoLabel , 0, 0, shiftGrid );
//Plot( bot, "", gridColor,styleLine|styleNoLabel, 0 , 0 , shiftGrid);
VerticalGrid = IIf ( BarIndex() >= begin, IIf( direction == 1,
screenHigh,
screenLow ), Null );
Plot ( VerticalGrid, "", gridColor, styleStaircase | styleNoLabel,
0, 0, 1
);
format = 8.2;
for ( n = LastValue( bot ); n < LastValue( top ) - 0.5*box; n = n +
box )
{
Plot( bot , "", gridColor, styleLine | styleNoLabel, 0, 0 , shiftGrid );
text = NumToStr( LastValue( bot ) + 0.5 * box, format );
xposition = BarCount + shiftPriceaxis;
yPosition = LastValue( bot ) + 0.27 * box;
PlotText( text, xPosition , yPosition, colorWhite );
bot = bot + box;
Graphcolor = IIf( direction == 1, ParamColor( "X_Color",
colorBrightGreen ),
ParamColor( "O_Color", colorRed ) );
PlotOHLC( Op, Hi, Lo, Cl, "", GraphColor , stylePointAndFigure | styleNoLabel, 0, 0 , shiftChart );
}
}
}
//----------------------------------------------------------
// TITLE
//----------------------------------------------------------
Title = "\n" +
" Instrument : " + Name() + FullName() + "\n " +
"Formula : " + " Point & Figure (High/Low Range)" + "\n " +
"Box : " + NumToStr( Box, 4.4 ) + " " +
"Reverse : " + NumToStr( Reverse, 2.0 ) + "\n " +
"ATR : " + WriteVal( LastValue( ATR( 100 ) ), format = 4.4 );
_SECTION_END();
//Formula:
_SECTION_BEGIN( "Point & Figure w Values adj" );
//mandeep Singh 05-Jan-2009
GfxSetBkColor(colorBlack);
GfxSetTextColor( colorOrange );
GfxSelectFont("Times New Roman", 10, 700, True );
GfxTextOut("man4urheart.blogspot.com", 10 , 0 );
GraphXSpace = 5;
SetChartBkColor( ParamColor( "BackGroundColor", colorBlack) );
//GraphColor = ParamColor("GarphColor",colorLightGrey);
GridColor = ParamColor( "GridColor", colorLightGrey );
Scaling = ParamList( "Scaling Method", "Traditional|Percentage|AVG True Range"
);
if ( scaling == "Traditional" )
{
Box = Param( "Box", 1, 0.2, 100, 0.1 );
}
else
if ( scaling == "Percentage" )
Box = Param( "Box ", 1, 0.2, 10, 0.1 ) / 100 * LastValue( C );
else
if ( scaling == "AVG True Range" )
Box = Param( "Box", 1, 0.3, 5, 0.1 ) * LastValue( ATR ( 20 ) );
shiftChart = 0;
shiftLastClose = 1;
shiftGrid = 7;
shiftPriceAxis = 2;
Reverse = Param( "Reverse", 3, 1, 5 );
j = 0;
PFL[0] = Box * ceil( Low[0] / Box ) + Box;
PFH[0] = Box * floor( High[0] / Box );
direction = 0;
for ( i = 1; i < BarCount; i++ )
{
if ( direction[j] == 0 )
{
if ( Low[i] <= PFL[j] - Box )
{
PFL[j] = Box * ceil( Low[i] / Box );
}
else
{
if ( High[i] >= PFL[j] + Reverse*Box )
{
j++;
direction[j] = 1;
PFH[j] = Box * floor( High[i] / Box );
PFL[j] = PFL[j - 1] + Box;
}
}
}
else
{
if ( High[i] >= PFH[j] + Box )
{
PFH[j] = Box * floor( High[i] / Box );
}
else
{
if ( Low[i] <= PFH[j] - Reverse * Box )
{
j++;
direction[j] = 0;
PFH[j] = PFH[j - 1] - Box;
PFL[j] = Box * ceil( Low[i] / Box );
}
}
}
}
delta = BarCount - j - 1;
direction = Ref( direction, - delta );
Hi = Ref( PFH, -delta ) + Box / 2;
Lo = Ref( PFL, -delta ) - Box / 2;
Cl = IIf( direction == 1, Hi, Lo );
Op = IIf( direction == 1, Cl - Box, Cl + Box );
Graphcolor = IIf( direction == 1, ParamColor( "X_Color",colorBrightGreen ),
ParamColor( "O_Color", colorRed ) );
PlotOHLC( Op, Hi, Lo, Cl, "", GraphColor , stylePointAndFigure | styleNoLabel,
0, 0 , shiftChart );
PlotOHLC( Op, Hi, Lo, Cl, "", GraphColor , stylePointAndFigure | styleNoLabel,
0, 0 , shiftChart );
Last = Ref( LastValue( C ), -( BarCount - 1 ) );
Plot( Last, "", colorRed, styleNoLine | styleDots, 0 , 0,shiftLastClose );
// selected value
Value = IIf( direction > 0, SelectedValue( Hi ) - box / 2,SelectedValue( Lo )
+ box / 2 );
//----------------------------------------------------------
// GRID CONSTRUCTION
//----------------------------------------------------------
PlotGridLines = ParamToggle( "PlotdGrid", "Yes! |No", 1 ) ;
if ( PlotGridLines ==1)
{
begin = SelectedValue( BarIndex() );
end = LastValue( BarIndex() );
period = end - begin + 1;
if ( begin < end )
{
ScreenHigh = LastValue( HHV( cl, period ) );
ScreenLow = LastValue( LLV( Cl, period ) );
top = LineArray( begin - shiftGrid, screenHigh, end, screenhigh, 0 ,
1 );
Bot = LineArray( begin - shiftGrid, screenlow, end, screenLow, 0, 1 );
Plot( top, "", gridColor, styleLine | styleNoLabel , 0, 0, shiftGrid );
//Plot( bot, "", gridColor,styleLine|styleNoLabel, 0 , 0 , shiftGrid);
VerticalGrid = IIf ( BarIndex() >= begin, IIf( direction == 1,
screenHigh,
screenLow ), Null );
Plot ( VerticalGrid, "", gridColor, styleStaircase | styleNoLabel,
0, 0, 1
);
format = 8.2;
for ( n = LastValue( bot ); n < LastValue( top ) - 0.5*box; n = n +
box )
{
Plot( bot , "", gridColor, styleLine | styleNoLabel, 0, 0 , shiftGrid );
text = NumToStr( LastValue( bot ) + 0.5 * box, format );
xposition = BarCount + shiftPriceaxis;
yPosition = LastValue( bot ) + 0.27 * box;
PlotText( text, xPosition , yPosition, colorWhite );
bot = bot + box;
Graphcolor = IIf( direction == 1, ParamColor( "X_Color",
colorBrightGreen ),
ParamColor( "O_Color", colorRed ) );
PlotOHLC( Op, Hi, Lo, Cl, "", GraphColor , stylePointAndFigure | styleNoLabel,
0, 0 , shiftChart );
}
}
}
//----------------------------------------------------------
// TITLE
//----------------------------------------------------------
Title = "\n" +
" Instrument : " + Name() + FullName() + "\n " +
"Formula : " + " Point & Figure (High/Low Range)" + "\n " +
"Box : " + NumToStr( Box, 4.4 ) + " " +
"Reverse : " + NumToStr( Reverse, 2.0 ) + "\n " +
"ATR : " + WriteVal( LastValue( ATR( 100 ) ), format = 4.4 );
_SECTION_END();
I recently purchased AmiBroker and I was hoping someone could tell me how to download stock data history and have the stocks seperated in to their respective sectors?
Thanks. I was hopeing I could do it through Yahoo for free.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?