Plot Lines on chart


#23

@twin: @fxshrat's code solved the Specific example you mentioned. When people come into a long post they often SKIM to the current area. fxshrat in particular is an amazing coder (I learn lots from his work) and often can quickly code up the solution. I don't code as well as he does, and feel that you (the original poster) should WORK to LEARN how to do it. That way it will stick with you better.

Also, when someone gives you code, it may not do EXACTLY what you want, but with a little bit of work, you should be able to take their ideas and implementation and modify it for your specific use.

fxshrat showed how to get results for the Sell side, but you should be able to do Similar/Mirror type of coding for the Buy side.

Please try to take the GIFTS given, and work with them. Complaining that it does not answer your EXACT SPECIFIC case is not constructive. Show us you have done an attempt to UNDERSTAND and MODIFY and more help is usually forthcoming.


#24

Before exiting this thread here is complete example for PLOTTING InTrade and NotInTrade lines (as the OP as shown some own effort via PM):

/// dummy system 
// !!!!!!!!!!! REMOVE BELOW 4 LINES IF USING OTHER SIGNALS !!!!!!!!!
period = 20;
m = MA( Close, period );
Buy =  Cross( Close, m ); 
Sell = Cross( m, Close ); 

/// http://forum.amibroker.com/t/plot-lines-on-chart/5581/24
/// Plots the highest since previous Sell and lowest since previous Sell
/// code snippet by fxshrat@gmail.com
bi = BarIndex();
lastbar = bi == LastValue(bi);

NotInTrade = Flip(Sell, Buy);
sfutlow = Valuewhen( Sell, ValueWhen( Buy OR lastbar, Ref(LowestSince(Sell, L), -1), 0 ) );// looks into "future", don't use for BT!
sll = IIf( NotInTrade, sfutlow, Null );// looks into "future", don't use for BT!
sfuthigh = ValueWhen( Sell, ValueWhen(Buy OR lastbar, Ref(HighestSince(Sell, H),-1), 0) );// looks into "future", don't use for BT!
shh = IIf( NotInTrade, sfuthigh, Null );// looks into "future", don't use for BT!

InTrade = Flip(Buy, Sell);
bfutlow = Valuewhen( Buy, ValueWhen( Sell OR lastbar, Ref(LowestSince(Buy, L), -1), 0 ));// looks into "future", don't use for BT!
bll = IIf( InTrade, bfutlow, Null );// looks into "future", don't use for BT!
bfuthigh = ValueWhen( Buy, ValueWhen(Sell OR lastbar, Ref(HighestSince(Buy, H),-1), 0) );// looks into "future", don't use for BT!
bhh = IIf( InTrade, bfuthigh, Null );// looks into "future", don't use for BT!


_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} - {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%), Vol %g {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ), V ) );

Plot( C, "", colorDefault, styleBar );

PlotShapes( Buy * shapeUpArrow, colorGreen, 0, L );
PlotShapes( Sell * shapeDownArrow, colorRed, 0, H );

Plot( shh, "\nHighest Since Previous Sell", colorRed, styleStaircase );
Plot( sll, "Lowest Since Previous Sell", colorRed, styleStaircase );

Plot( bhh, "\nHighest Since Previous Buy", colorGreen, styleStaircase );
Plot( bll, "Lowest Since Previous Buy", colorGreen, styleStaircase );

12


#25

Thanks @fxshrat for your Help and time