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

Re: [amibroker] Re: Plot() and z-order



PureBytes Links

Trading Reference Links

Rob,

no problem - see the attachment.

Greetings,

Thomas

> Thomas,
>
> Would you mind posting just so we know what Dennis is talking
> about...?
>
> TIA
>
> --- In amibroker@xxxxxxxxxxxxxxx, Dennis Brown <see3d@xxx> wrote:
> > Oops, my apologies to Daniel LaLiberte.  It was his Trade
> > Visualizer that I was referring to.
> >
> > It was in a post on this board with the subject: [amibroker] Re: I
> > need your thoughts on an Optimisation issue.  June 9, 2007 3:09:00
> > PM EDT
> >
> > I saved it in my emails, so I don't have a pointer to it..
> >
> > I get so many ideas from so many different people, I sometimes get
> > confused who's was whos.  I love all ideas!  Even a few of my own.
> > LOL
> >
> > Best regards,
> > Dennis
> >
> > On Feb 18, 2009, at 9:08 AM, sidhartha70 wrote:
> > > Thomas/Dennis,
> > >
> > > I must admit my memory is a little sketchy of my 'trade
> > > visualiser' ideas myself... if Dennis can jog my memory maybe I
> > > can help...!!
> > >
> > > Rob
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, Thomas Ludwig <Thomas.Ludwig@>
> > >
> > > wrote:
> > >> Dennis,
> > >>
> > >> your chart is really terrific!
> > >>
> > >> I found Dave's ribbon code, but my search for sidharta70's trade
> > >> visualizer got no results. Any idea where we can find it?
> > >>
> > >> Thanks for sharing!
> > >>
> > >> Thomas
> > >>
> > >>> Dave,
> > >>>
> > >>> I was inspired by seeing and trying out your ribbon code a very
> > >>> long time ago.  I don't actually use your code (I wrote a more
> > >>> extensive one for my charts), yet it is often just the sight of
> > >>> how someone else does things that inspires more creativity.  I
> > >>> was also inspired by sidhartha70's trade visualizer, and many
> > >>> other things have been shared in the AB community.
> > >>>
> > >>> Best regards,
> > >>> Dennis
> > >
> > > ------------------------------------
> > >
> > > **** IMPORTANT PLEASE READ ****
> > > This group is for the discussion between users only.
> > > This is *NOT* technical support channel.
> > >
> > > TO GET TECHNICAL SUPPORT send an e-mail directly to
> > > SUPPORT {at} amibroker.com
> > >
> > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > > http://www.amibroker.com/feedback/
> > > (submissions sent via other channels won't be considered)
> > >
> > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > > http://www.amibroker.com/devlog/
> > >
> > > Yahoo! Groups Links
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>



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

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

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

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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/

// TradeVisualizer.afl -- Indicate trades and change in equity.

// Daniel LaLiberte liberte@xxx

/*

Features:

Show realized and unrealized net profit

Show trade signals.

Show trade arrows.

Bugs, limitations, and side effects:

Assumes GraphZOrder == 0 which is the default.

Assume only one open position.

Calls Equity(0, 0), which should not have side effects.

This visualizer should not affect your actual signals.

Instructions:

Save TradeVisualizer.afl in your Include folder.

Add the following at the end of your scripts, after your final Buy, Sell, Short, Cover assignments:

// #include <TradeVisualizer.afl>

Remove your ExRem() calls to see regions of raw Buy, Sell, Short, Cover signals

Things to do:

Show stops/limits.

Deal with order delays - it assumes 1 bar delay.

Show pyramid trades, number of shares per trade.

Display text of profit/loss.

Optionally compute equity across stocks.

Parameterize all this.

Please send improvements or suggestions.

*/

_SECTION_BEGIN("TradeVisualizer");

//========================================

backgroundColor = colorWhite;

// Colors of signal bars

buyColor = colorPaleGreen; // ColorRGB(230, 255, 230); // very pale

sellColor = colorRose;

shortColor = colorLavender;

coverColor = colorSkyblue;

// Colors of arrows

buyArrowColor = colorLime;

sellArrowColor = colorRed;

shortArrowColor = colorViolet;

coverArrowColor = colorBlue;

// Colors of net profit

gainColor = colorLime; // unrealized gain relative to last trade

lossColor = colorOrange; // unrealized loss relative to last trade

netPositiveColor = colorGreen; // overall realized net profit is positive

netNegativeColor = colorRed; // overall realized net profit is negative

 

//========================================

// Only show stuff if this is running as an indicator

isIndicator = Status("action") == actionIndicator;

if (isIndicator)

{

rawBuy = Buy;

rawSell = Sell;

rawShort = Short;

rawCover = Cover;

// Assume only one open position.

buyExRem = ExRem(Buy, Sell);

sellExRem = ExRem(Sell, Buy);

shortExRem = ExRem(Short, Cover);

coverExRem = ExRem(Cover, Short);

 

// Show realized and unrealized gain or loss relative to last buy or short trade.

 

if (ParamToggle("Show net profit", "no|yes", 1))

{

// Last trade event: buy, sell, short or cover.

lastTrade = buyExRem + shortExRem + sellExRem + coverExRem;

closeTrade = sellExRem + coverExRem;

 

// Calculate equity change since initial equity, i.e. the unrealized net profit.

// Equity is what we might have at the beginning of each bar, if we were to sell all assets.

// Avoid calling Equity(1) which has side effects on trades.

netProfit = Nz( Equity(0, 0) - GetOption("InitialEquity"));

// Calculate realized net profit at beginning of last close trade event.

// Since trade happens at the beginning of the bar after the signal (i.e. a delay of 1),

// then we check whether there was a close trade in the previous bar.

realizedNetProfit = Nz( ValueWhen( Ref(closeTrade, -1), netProfit) );

realP = Ref(realizedNetProfit, 0);

// Move the unrealized profit back to when it was generated by looking forward 1 bar.

unrealP = Ref(netProfit, 1);

PlotOHLC( realP , realP , unrealP , unrealP , "net profit",

IIf (unrealP > realP , gainColor,

IIf (unrealP < realP , lossColor,

// no change, so height is zero. Use realized net profit color instead.

IIf (realizedNetProfit > 0, netPositiveColor, netNegativeColor))),

styleCandle | styleOwnScale ); // Use styleLeftAxisScale if also showing realizedNetProfit above.

}

//========================================

// Show buy, sell, short, or cover signals

if (ParamToggle("Show trade signals", "no|yes", 1))

{

GraphXSpace = 5; // adds 5% extra space above AND below.

Plot(IIf(buyExRem OR sellExRem, 95, 3), "",

IIf(rawBuy, buyColor, IIf(rawSell, sellColor, backgroundColor)),

styleHistogram | styleThick | styleOwnScale | styleNoLabel, 0, 100);

Plot(IIf(shortExRem OR coverExRem, -95, -3), "",

IIf(rawShort, shortColor, IIf(rawCover, coverColor, backgroundColor)),

styleHistogram | styleThick | styleOwnScale | styleNoLabel, -100, 0);

}

//========================================

// Add up and down arrows. The vertical position will be your first plot, if any.

// Too noisy with many trades.

if (ParamToggle("Show trade arrows", "no|yes", 0))

{

PlotShapes(shapeUpArrow * buyExRem, buyArrowColor);

PlotShapes(shapeDownArrow * sellExRem, sellArrowColor);

// Bump the short and cover arrows out one if there is a sell or buy arrow

PlotShapes(shapeHollowDownArrow * shortExRem, shortArrowColor, 0,  -24 * sellExRem);

PlotShapes(shapeHollowUpArrow * coverExRem, coverArrowColor, 0,  -24 * buyExRem);

}

 

 



sinceBuy = BarsSince (buyExRem);

sinceSell = BarsSince (sellExRem);

sinceShort = BarsSince (shortExRem);

sinceCover = BarsSince (coverExRem);

inLong = Ref(sinceSell, -1) > sinceBuy;

inShort = Ref(sinceCover, -1) > sinceShort;

lastBuyPrice = Ref ( BuyPrice, - sinceBuy);

lastShortPrice = Ref ( ShortPrice, - sinceShort);

percentBuy = inLong * 100 * (SellPrice - lastBuyPrice) / lastBuyPrice;

percentShort = inShort * 100 * (CoverPrice - lastShortPrice) / lastShortPrice;



} // end if indicator

_SECTION_END();