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

[amibroker] Re: Charting spreads using custom symbols / OHLC candlesticks



PureBytes Links

Trading Reference Links

Another variation offered as an example below. It just plots the 
selected symbol UNTIL you right-click and change the parameters to 
enter a Foreign symbol and the number of shares of each:

_SECTION_BEGIN("ForeignSpreadRatios");

ticker = ParamStr( "Foreign Symbol?" , Name() );
selected = Name(); 

forShares = Param( "#shares of Foreign", 1 , 1 , 999999 , 1 );
selShares = Param( "#shares of Selected", 1 , 1 , 999999 , 1 );

sharesRatio = ( selShares / forShares );

spreadOratio = Open - Foreign( ticker, "O" ) * sharesRatio;

spreadHratio = High - Foreign( ticker, "H" ) * sharesRatio;

spreadLratio = Low - Foreign( ticker, "L" ) * sharesRatio;

spreadCratio = Close - Foreign( ticker, "C" ) * sharesRatio;

spreadVratio = Volume / Foreign( ticker, "V" ) * sharesRatio;

colorSwitch = IIf( Close > Open , colorCustom11 , colorYellow );

if ( ticker != selected )
{
_N(Title = FullName() + "^{{INTERVAL}}  {{DATE}}^SPREAD RATIOS ~ 
("+selShares+
StrFormat("-shares of-{{NAME}}) vs. ("+forshares+"-shares of-
"+ticker+")\n ~ ratioV = "
+Prec(spreadVratio,2)+" ~  spreadO = "
+Prec(spreadOratio,2)+" ~  spreadH = "
+Prec(spreadHratio,2)+" ~  spreadL = "
+Prec(spreadLratio,2)+" ~  spreadC = "
+Prec(spreadCratio,2)+" ~", V , O , H , L , C , SelectedValue( ROC( 
C, 1 ) ) ) );
PlotOHLC( spreadOratio , spreadHratio , spreadLratio , 
spreadCratio , "SpreadRatios"
, colorSwitch , styleCandle | styleNoTitle | styleNoLabel );
}
else
{
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %.2f, 
Hi %.2f, Lo %.2f, Close %.2f (%.1f%%) {{VALUES}}", O, H, L, C, 
SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | 
ParamStyle("Style" ) | GetPriceStyle() ); 
}
_SECTION_END();


--- In amibroker@xxxxxxxxxxxxxxx, "cbs7777777" <eyoxall@xxx> wrote:
>
> Hi Joe
> 
> I also struggled with this, however I eventually found there is a 
> very simple solution where you create a composite symbol. See my 
> example below for a Dow-Gold ratio:
> 
> OpenDowGLD = Foreign("^DJI","Open") / Foreign("GLD","Open");
> HighDowGLD = Foreign("^DJI","High") / Foreign("GLD","High");
> LowDowGLD = Foreign("^DJI","Low") / Foreign("GLD","Low");
> CloseDowGLD = Foreign("^DJI","Close") / Foreign("GLD","Close");
> 
> AddToComposite( OpenDowGLD, "~Dow-GLD", "O", 1 + 2 + 8 + 16 );
> AddToComposite( HighDowGLD, "~Dow-GLD", "H", 1 + 2 + 8 + 16 );
> AddToComposite( LowDowGLD, "~Dow-GLD", "L", 1 + 2 + 8 + 16 );
> AddToComposite( CloseDowGLD, "~Dow-GLD", "C", 1 + 2 + 8 + 16 );
> 
> Buy=Sell=Short=Cover=0;
> Filter=1;
> 
> The tickers are based from Yahoo data - you simply view the symbol 
> ~Dow-GLD
> 
> An alternative if you want to create a chart that displays 
alongside 
> your current symbol is to create an andicator like this:
> 
> ticker = ParamStr( "Ticker", "GLD" );
> OpenSpread = Open / Foreign(ticker,"Open");
> HighSpread = High / Foreign(ticker,"High");
> LowSpread = Low / Foreign(ticker,"Low");
> CloseSpread = Close / Foreign(ticker,"Close");
> PlotOHLC( OpenSpread, HighSpread, LowSpread, CloseSpread, FullName()
> +"-"+ticker+" Spread", colorBlack, styleCandle );
> 
> Hope that helps
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "venturerider2" <venturerider2@> 
> wrote:
> >
> > I'm new using AB.  I'd like to be able to chart a spread of two 
> stock 
> > symbols and I'd like the chart to be a candlestick price chart ? 
> just 
> > as if I was looking at the price chart of a single security.  So, 
> for 
> > example, if I were plotting a capital balanced equity spread in 
> Coke 
> > and Pepsi, I need to be able to plot it on a capital balanced 
ratio 
> > (120 shares of Coke minus 100 shares of Pepsi).  In Esignal this 
is 
> > accomplished by creating a custom spread symbol, which in this 
case 
> > would be "1.2KO ? PEP".  
> > 
> > I plotted a spread in AB using the Foreign function: spread = 
> Foreign
> > ( "ticker1", "C") - Foreign( "ticker2", "C");
> > Plot( spread, "spread", colorRed);  
> > 
> > However, this does not give me a true price plot with OHLC 
> > candlesticks.  It plots it like an indicator ? as a line.  
Ideally, 
> I 
> > do not want to create an indicator.  Ideally, like in eSignal, I 
> want 
> > to create a custom symbol, which corresponds to a custom price 
> plot ? 
> > this price plot being the ratio adjusted difference between two 
> > stocks, as described above.  Then I would like to be able to 
apply 
> > all of the various indicators (MA's, RSI, CCI, MACD, etc.) to 
that 
> > custom price plot.
> > 
> > I covered the AFL Library, UKB, Yahoo Users Group and  AB 
manuals.  
> I 
> > cannot find any information on this.  If you can point me in the 
> > right direction I would greatly appreciate it.  Thanks.
> > 
> > -Joe
> >
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/