Hi, any one has a solution to spread out the end prices so they would not overlay like shown below.
You have problems because instead of using BUILT-IN price labels you are using your own PlotText in the formula. Which is absurd.
Instead of re-inventing the wheel (and doing it wrong),
use built-in price labels that you get FOR FREE just if you use Plot() without styleNoLabel.
You did not include formula in your question. Answers therefore are guessing games.
Please follow this advice: How to ask a good question
each price is the last price of a specific curve. PlotText requires offset pixels and I don't know know how to transform price into pixel. Below function try to do that.
function Plot_MIDAS( sr_id, lbar )
{
global midasColor, midasShapeDigit, lastBar, Price_PksVal, Price_BotVal, alertPct, sayAlert, eEmail, Price; //xAxis, ypixels,S2_Trigger,
VisibleBarCount = lastvisiblebar - firstvisiblebar;
yLowest = GetYLowestSupport( L , VisibleBarCount );
yHighest = GetYHighestResistance( H, VisibleBarCount );
DeltaMaxMinPrice = yHighest-yLowest;
// m_ID = "S" + sr_id;
// m_ID = "";
yAxisDelta = Status ( "axismaxy" ) - Status ( "axisminy" );
yp = IIf( sr_id <= S8, -20, 20 );
if (sr_id <=8) {
yTextOffset = 0;//(Status ( "pxchartheight" )/2 - ((8-sr_id)*100)); // start from top pixel of chart
// _trace("pxchartheight_" + Status ( "pxchartheight" ));
}
else {
yTextOffset = 0; // (Status ( "pxchartheight" )/2 - ((sr_id-8)*5)); // start from top pixel of chart
// _trace("pxchartheight_" + Status ( "pxchartheight" ));
}
// yTextOffset = (DeltaMaxMinPrice/16) + yLowest; // start from yLowest pixel of chart
midas_array = generate_MidasSR( lbar ); // generating curve using existing launch bar point.
Plot( midas_array , "", midasColor[sr_id], styleLine | styleThick );
PlotShapes( ( lbar + 1 == xAxis ) * midasShapeDigit[sr_id], midasColor[sr_id], 0 , midas_array, yp );
// PlotTextSetFont( NumToStr(LastValue(midas_array),1.2), "Tahoma",8, (lbar + 1), LastValue(midas_array) , colorGold , colorDefault, -5); //
// PlotText( NumToStr(LastValue(midas_array),1.2), LastValue(BarIndex())+1, LastValue(midas_array) , colorBlack , midasColor[sr_id], -1); //
PlotText( NumToStr(LastValue(midas_array),1.2), LastValue(BarIndex())+1, LastValue(midas_array) , colorBlack , midasColor[sr_id], yTextOffset); //
if( 0 && (sr_id == S1 || sr_id == R1) )
PlotShapes( ( xAxis == lastBar ) * midasShapeDigit[sr_id], midasColor[sr_id], 0 , midas_array, IIf( sr_id == S1, -12, 12 ) );
if( eEmail )
{
triggerThreshold = midas_array * ( alertPct / 100 );
PksTrigger = barssince( Price_PksVal >= ( midas_array - triggerThreshold ) AND Price_PksVal <= ( midas_array + triggerThreshold ) );
BotTrigger = barssince( Price_BotVal >= ( midas_array - triggerThreshold ) AND Price_BotVal <= ( midas_array + triggerThreshold ) );
trigger_array = PksTrigger OR BotTrigger;
If( Interval() == inDaily )
curr_interval = " Daily ";
else
curr_interval = " Weekly ";
touch_S = cross( Price, midas_array ) || ( Price / midas_array ) <= ( 1 + alertPct );
touch_R = cross( midas_array, Price ) || ( midas_array / Price ) <= ( 1 + alertPct );
}
if( sr_id <= 8 )
{
// sr_id = sr_id; // S curve start at 1
SayNotTooOften( Name() + " S" + sr_id , sayAlert );
if( eEmail )
AlertIF( barssince( touch_S ) <= 10, "EMAIL", FullName() + curr_interval + "Touch Bottom S" + sr_id, 1 );
}
else
{
sr_id = ( 17 - sr_id );
SayNotTooOften( Name() + " R" + sr_id , sayAlert );
if( eEmail )
AlertIF( barssince( touch_R ) <= 10, "EMAIL", FullName() + curr_interval + "Touch Top R" + sr_id, 1 );
}
}
Moderator comment:
When posting the formula, please make sure that you use Code Tags (using
</>
>code button) as explained here: How to use this site.
Code tags are required so formulas can be properly displayed and copied without errors.
As written here: How to ask a good question
The formula posted must be runnable. You need to make sure that it is possible to just copy-paste formula and it works. In current state the formula is incomplete (syntax errors due to missing functions). Also it does not produce any output since it only defines the function but it does not call it.
Anyway, as I wrote, you don't need that PlotText and you don't need to worry about you don't need to plot labels yourself as BY DEFAULT labels are automatically drawn and are automatically spread out so they don't cover.
The following code uses Plot() alone (without PlotText) and it produces charts with LABELS that DO NOT overlap.
for( i = 1; i < 5; i++ )
{
Plot( C - i, "label"+i, colorCustom1 + 2 * i, styleLine );
Plot( C + i, "label"+i, colorCustom1 + 2*i + 1, styleLine );
}
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.