@benlai0117 - it is pretty simple. Just provide correct coordinates. Currently you are using last bar value, while you should be using actual X and Y value for given bar. Your "x" coordinate is i (bar number), your "y" coordinate should be price at that bar, say Low[ i ]
Your code should look like this:
Plot(C, "Price", colorDefault, styleCandle );
Plot(MA(C,20),"MA20", colorRed );
Buy= Cross( C, MA(C,20 ) );
Sell= Cross( MA( C, 20 ), C );
dist = 1.5*ATR(10);
bi = BarIndex();
first = FirstVisibleValue( bi );
last = LastVisibleValue( bi );
last = Min( BarCount - 1, last );
for( i = first; i < last; i++ )
{
if (Buy[i]) PlotTextSetFont("C" , "Wingdings", 40, i, Low[ i ], colorgreen, colorDefault, -30 );
if (sell[i]) PlotTextSetFont( "D", "Wingdings", 40, i, High[ i ] , colorred, colorDefault, -20 ); // will use new font too
}
Also note that it makes no sense to iterate through all bars. It is way more efficient to use visible bars only.
There can't be PlotText for styleOwnScale because each own scale plot sets separate invisible scale so simply, there is no scale to refer to (you can only refer to right or left axis scale). If you need more than 2 separate scales in single pane, consider REMAPING own scale to either left/right scale (Use Remap function).
You can also use GfxTextOut directly to plot text in any scale you wish. In fact GfxTextOut is much faster than thousands of PlotText calls.