The code to add Y axis : Modify the first line of Market Profile SetChartOptions( 0);//3 , chartShowDates );
and add the following at the end. gridINCR = box; GridMAX = DH + gridINCR ; GridMIN = DL - gridINCR ; steps = ( GridMAX - GridMIN ) / gridINCR ; SetChartOptions( 1, 0, 0, GridMIN, GridMAX ); for ( i = 0;i < steps;i++ ) //Plot(GridMIN+i*gridINCR, "",ParamColor("color", colorBlack ), styleNoTitle | ParamStyle("style", styleLine | styleNoLabel, maskHistogram ) );//solid PlotGrid( GridMIN + i*gridINCR, colorBlack );// dash Caveat : The new Y scale and the MP scale are not quite the same. A tiny difference, between one or two ticks, but I cannot find why. I have to fully understand the gfx mode, I suppose. I am very close to the solution, if a few passers-by could bring some light, I will appreciate. Best regards --- In amibroker@yahoogroups.com, "reinsley" <reins...@...> wrote: > > Hello, > > I overlaid a price above an indicator that comes from a formula. > The formula does not show the Y axis. > > I 'd like to add Y axis, to use the cross cursor. > > > In archives I saw a TJ answer : > > Turn ON Grid : Show middle lines > > > > BUt this param comes back to OFF. > > Does it exist a way to display Y axis by formula ? > Or as an alternate to overlaid the price then to maks the candle ? > > I tried may options but things are getting worse. > > > Thank you for the help. > > Best regards > > > > Here is the formula : Market profile > > // Market profile > > > SetChartOptions(3, chartShowDates); > GfxSetOverlayMode( mode = 1 ); > > nn = StrToNum(ParamList("Days", "1|2|3", 2)); > box = Param("step", 10, 1, 100, 1)*TickSize; > > NewDay = Day()!= Ref(Day(), -1); > DH = LastValue(HighestSince(NewDay, H, nn)); > DL = LastValue(LowestSince(NewDay, L, nn)); > _TRACE("DH = "+DH); > _TRACE("DL = "+DL); > Range = DH - DL; > steps = ceil(Range/box); > // linage > height = Status("pxheight") - 50; // > width of the profile > (indention overhand 30 from below 20 pixels) > boxheight = LastValue(height/steps); // size of the box > > width = (Status("pxwidth")-110)/3; // offset of > the profiles > > bars = Highest(BarsSince(NewDay)); > ColorStep = LastValue(185/bars); > > // > L = IIf(C > Ref(C, -1) AND L > Ref(C, - 1) AND NOT NewDay, Ref(C, -1), L); > H = IIf(C < Ref(C, -1) AND H < Ref(C, - 1) AND NOT NewDay, Ref(C, -1), H); > > function GetDayPrice( fild, shift) > { > DayPrice = LastValue(TimeFrameGetPrice(fild, inDaily, -shift)); > return DayPrice; > } > > function pixlev(price) > { > result = 30 + (DH - price)/box * boxheight; > return result; > } > > procedure PlotProfile(DH, DL, begini, endi, disp) > { > m = 0; > for(j = DH; j > DL; j = j-box) > { > n = 0; > for(i = begini; i < endi; i++) > { > if(H[i] >= j AND L[i] <= j) > { > GfxSelectPen( colorBlack, 1, 0); > > GfxSelectSolidBrush(ColorHSB((i-begini)*ColorStep, 255, 255)); > GfxRectangle( disp+n*boxheight, 30+m*boxheight, > disp+(n+1)*boxheight, 30+(m+1)*boxheight); > n++; > } > } > m++; > } > } > > procedure PlotLine(x1, y1, x2, y2, Color) > { > GfxSelectPen(Color, 1, 0); > GfxPolyline( x1, y1, x2, y2); > } > > procedure PlotRect(x1, y1, x2, y2, Color) > { > GfxSelectPen(Color, 0, 5); > GfxSelectSolidBrush(Color); > GfxRectangle(x1, y1, x2, y2); > } > > procedure PlotPrice(Text, FontName, FontSize, Color, x, y, yAlign, xAlign) > { > GfxSetBkMode(1); > GfxSetTextColor(Color); > GfxSetTextAlign( xAlign|yAlign); > GfxSelectFont(FontName, FontSize, 600); // dont work orientation > GfxTextOut(Text, x, y); > } > > for(q = nn; q > 0; q--) > { > begini = LastValue(ValueWhen(NewDay, BarIndex(), q)); > endi = LastValue(IIf(q == 1, BarCount, ValueWhen(NewDay, BarIndex(), > q-1))); > PlotRect(50 + width*(nn-q), pixlev(GetDayPrice("H", q-1)), > // > day range > 50 + width*(nn-q+1), pixlev(GetDayPrice("L", q-1)), > colorLightYellow); > PlotRect(50 + width*(nn-q), pixlev(GetDayPrice("O", q-1)), > // > open-close range > 50 + width*(nn-q+1), pixlev(GetDayPrice("C", q-1)), > IIf(GetDayPrice("O", q-1) > GetDayPrice("C", q-1), ColorHSB(15, > 40, > 255), > ColorHSB(80, 40, 255))); > PlotLine(50 + width*(nn-q), pixlev(GetDayPrice("C", q-1)), > // > close line > 50 + width*(nn-q+1), pixlev(GetDayPrice("C", q-1)), > IIf( GetDayPrice("O", q-1) > GetDayPrice("C", q-1), colorRed, > colorGreen)); > PlotProfile(DH, DL, begini, endi, 50 + width*(nn-q)); > PlotLine(50 + width*(nn-q), height+40, 50 + width*(nn-q), 0, > colorBlack); // vertical line > PlotPrice( " close " + NumToStr(GetDayPrice("C", q-1))+" ", > "Tahoma", 10, // plot close price > IIf( GetDayPrice("O", q-1) > GetDayPrice("C", q-1), colorRed, > colorGreen), > 50+width*(nn-q+1), pixlev(GetDayPrice("C", q-1)), > IIf( GetDayPrice("O", q-1) > GetDayPrice("C", q-1), 0, 8), 2); > PlotPrice( " open " + NumToStr(GetDayPrice("O", q-1))+" ", > "Tahoma", 10, // plot open price > colorBlack, 50+width*(nn-q+1), pixlev(GetDayPrice("O", q-1)), > IIf( GetDayPrice("O", q-1) > GetDayPrice("C", q-1), 8, 0), 2); > PlotPrice( " "+NumToStr(GetDayPrice("H", q-1)), "Tahoma", 10, > > // plot high price > colorBlack, 50+width*(nn-q), pixlev(GetDayPrice("H", q-1)), 8, > 0); > PlotPrice(" "+NumToStr(GetDayPrice("L", q-1)), "Tahoma", 10, > // > plot low price > colorBlack, 50+width*(nn-q), pixlev(GetDayPrice("L", q-1)), 0, > 0); > } >