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.