[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: How To Plot Long And Short Stop Alternately On One Chart?



PureBytes Links

Trading Reference Links


ZWZ, thanks for your suggestion. For now I'll stick with the code
based on plot statements. It's probably faster than the script based
code. I fine-tuned the formula a little bit and it's all what I need:


/*********************************/

LongSignal  = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) );
ShortSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) );
DynamicColour = IIf( LongSignal AND ShortSignal, colorYellow, IIf(
LongSignal, colorLime, IIf( ShortSignal, colorRed, colorGrey50 )));

TrailStopLong = HHV( C - 2 * ATR(10), 15 );
TargetLong = EMA( H, 13 ) + 2 * ATR(10);
TrailStopShort = LLV( C + 2 * ATR(10), 15 );
TargetShort = EMA( L, 13 ) - 2 * ATR(10);

/* plot chart and stops */
Title = Name()+"  \\c11"+Interval(format=2)+"  "+Date()+"\\c-1  C="+C;
/* white background: 55, black background: 16 */
Plot(TargetLong,     "", IIf(LongSignal  AND ShortSignal, 55,
IIf(LongSignal,  26, 55)), 512 );
Plot(TargetShort,    "", IIf(ShortSignal AND LongSignal,  55,
IIf(ShortSignal, 26, 55)), 512 );
Plot(TrailStopLong,  "", IIf(LongSignal  AND ShortSignal, 55,
IIf(LongSignal,  38, 55)), 512 );
Plot(TrailStopShort, "", IIf(ShortSignal AND LongSignal,  55,
IIf(ShortSignal, 53, 55)), 512 );

Plot( Close, "", DynamicColour, 64 );
SetChartOptions(0, chartShowDates);

/*********************************/

--- In amibroker@xxxxxxxxxxxxxxx, "zwz21766" <zwzhang@xxxx> wrote:
> 
> hi,
> 
> After looking at how SAR is plotted:
> Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color",
> colorCycle ), ParamStyle("Style", styleDots | styleNoLine,
maskDefault
> | styleDots | styleNoLine ) );
> 
> I find the algorism is not implemented using the Plot function, it
is
> in the SAR function. So my suggestion is:
> 
> A function, let's call it MyStop:
> 
> //pls refer to AFL syntax, I am a newbe
> function (return type) MyStop(...){ 
>     ...
>     if(LongSignal){
>        stpValue=[calculate long stop value];
>     }
>     else{
>        stpValue=[calculate short stop value];
>     }
>     return stpValue;
> }
> 
> Then plotting is simple and easy:
> Plot( MyStop(...), ...);
> //Note here: Just as SAR, plot it as dots, not line. If line, looks
> too strange.
> 
> zwz






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/