PureBytes Links
Trading Reference Links
|
--- In amibroker@xxxxxxxxxxxxxxx, "apfxtrader" <apforex@xxx> wrote: > > Hi Don, > > Here you have it again including the PF chart code. > > You have to choose from parameters window: > 1. asset class (Stocks/Forex) > 2. Plot or not the chart grid > 3. Upon asset class selection the box size for FX or Stocks > > // COPY here------------------------------------------------ > > GraphXSpace = 5; > > SetChartBkColor(ParamColor("BackGroundColor", colorBlack)); > GraphColor = ParamColor("GarphColor",colorLightGrey); > GridColor = ParamColor("GridColor", ColorRGB(39,49, 67) ); > Class = ParamToggle("AssetClass", "Stocks|Forex", 1); > Decimals=IIf(Class, 1, LastValue(IIf(StrRight(Name(),3) == "JPY", > 100, 10000))); > Box =IIf(Class, Param("Box (Stocks)", 1, 0.2, 5, 0.2) /decimals, > Param("Box (Forex)", 10, 1, 100, 1) /decimals); > > > 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); > > > PlotOHLC(Op, Hi, Lo, Cl,"", GraphColor , > stylePointAndFigure|styleNoLabel); > > > > Last = Ref( LastValue(C), -(BarCount-1)); > Plot( Last,"", colorRed,styleNoLine|styleDots, 0 , 0, 1); > > //selected value > Value= IIf(direction>0, SelectedValue(Hi)-box/2, SelectedValue(Lo)+box/2); > > //----------------------------------------------------------------------- > // GRID CONSTRUCTION > //---------------------------------------------------------------------- > > PlotGridLines = ParamToggle("PlotdGrid", "Yes|No", 0); > if (PlotGridLines) > { > begin = SelectedValue(BarIndex()); > end = LastValue(BarIndex()); > period = end-begin +1; > > if( begin<end) > { > > > ScreenHigh =LastValue( HHV(cl, period )) + box; > ScreenLow =LastValue( LLV( Cl, period) )-box; > > shift = 7; > top= LineArray( begin-shift, screenHigh, end, screenhigh, 0 , 1); > Bot= LineArray( begin-shift, screenlow, end, screenLow, 0, 1); > > Plot( top, "", gridColor,styleLine|styleNoLabel , 0, 0,shift); > Plot( bot, "", gridColor,styleLine|styleNoLabel, 0 , 0 , shift); > > > VerticalGrid = IIf ( BarIndex() >= begin, IIf(direction==1, > screenHigh, screenLow), Null); > > Plot (VerticalGrid, "", gridColor, styleStaircase|styleNoLabel, 0,0, 1); > > > format =IIf(Class, 8.2, IIf (StrRight(Name() ,3) == "JPY", 8.2, > 8.4)); > while ( LastValue(bot)< LastValue(top)-0.5*box) > { > > Plot( bot , "", gridColor, styleLine|styleNoLabel, 0, 0 ,shift); > > > text = NumToStr(LastValue(bot) + 0.5*box, format); > xposition = BarCount+2; > yPosition = LastValue(bot)+0.27*box; > > PlotText(text, xPosition , yPosition, colorWhite); > > bot = bot + box; > } > } > > } > > > //--------------------------------------------------------------------- > // TITLE > //---------------------------------------------------------------------- > > Title = "\n" + > " Instrument : " + Name() + "\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); > > //-------------------------------------------------------------- > // END OF CODE > //-------------------------------------------------------------------- >
Hi apfx,
First thanks for submitting your source code. Second i encounter two problems while trying to use it. 1. I get Endless loop error . according to AFL engine it is located in the bellow piece of code. while ( LastValue(bot)< LastValue(top)-0.5*box) {
Plot( bot , "", gridColor, styleLine|styleNoLabel, 0, 0 ,shift);
text = NumToStr(LastValue(bot) + 0.5*box, format); xposition = BarCount+2; yPosition = LastValue(bot)+0.27*box;
PlotText(text, xPosition , yPosition, colorWhite);
bot = bot + box; }
2. I can not see the Axis price.
Regards, Hanan
__._,_.___
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
__,_._,___
|