PureBytes Links
Trading Reference Links
|
Here is my BuySellVisualize.afl, which I include in every script that
does buying/selling, even those that have no plots (yet).
It shows how to deal with elminating extra buy/sell arrows. But it
is also useful to see the range of bars that have buy/sell signals,
so I use a background (area) color for that. I also wanted a visual
indicator what my profit/loss would be for each trade, so I added a
histogram of percent changes relative to the last buy point.
I was not able to deal with stops because I had some problem calling
the Equity function. I would appreciate help on that. Thanks.
dan
// Indicate buy/sell points and profit changes.
// Daniel LaLiberte liberte@xxxxxxxxxxxxx
// Save in Include folder and add the following to your scripts after
Buy/Sell settings:
// #include <BuySellVisualize.afl>
// Remove your own ExRem() calls to see the full extent of your Buy
and Sell regions.
// Please send improvements. Things to do:
// Show stops/limits.
// Show equity, accounting for commissions.
// Show pyramid trades, number of shares per trade.
// Display text of profit/loss above Sell arrow.
// Parameterize all this.
//GraphZOrder = 1; Using this conflicts with BuySellVisualize.afl
rawBuy = Buy;
rawSell = Sell;
/* This causes all charts to fail for me:
eq = Equity(1);
//Plot(eq, "Equity", colorBlack);
*/
buyExRem = ExRem(buy, sell);
sellExRem = ExRem(sell, buy);
sinceBuy = BarsSince (buyExRem);
sinceSell = BarsSince (sellExRem);
// Add up and down arrows to previous plot, if any.
PlotShapes(shapeUpArrow * buyExRem, colorLime);
PlotShapes(shapeDownArrow * sellExRem, colorRed);
lastBuyPrice = ref ( BuyPrice, - sinceBuy);
percentDiff = 100 * (SellPrice - lastBuyPrice) / lastBuyPrice;
// Plot( lastBuyPrice, "last buy", colorBlack, styleOwnScale |
styleLine);
Plot( percentDiff, "% Profit",
Iif(ref(sinceSell, -1) < sinceBuy, colorLightGrey,
Iif(percentDiff > 0, colorGreen, colorRed)),
styleOwnScale | styleHistogram);
// Show background of raw buy or sell signal
backgroundColor = colorWhite;
Plot( 100, // height of the ribbon
"Buy-Sell",
Iif( rawBuy, ColorRGB(200, 255, 200), // very PaleGreen,
Iif( rawSell, colorRose,
backgroundColor) ),
styleOwnScale | styleArea | styleNoLabel, 0, 100 );
--- In amibroker@xxxxxxxxxxxxxxx, "atilla" <atilla@xxx> wrote:
>
> I'm a new Amibroker user, just moving over from Wealth-lab. Spent
> most of the evening trying to come up to speed on Amibroker and
have a
> couple of questions.
>
> For a test case, I'm trying to make a basic system that buys when
the
> close > EMA(45) and sells after 5 days using ApplyStop().
>
> Here is my code:
>
> ---------------------
>
> Equity(1);
>
> ApplyStop( stopTypeNBar, stopModeBars, 5 );
> Buy = Cross(Close, EMA(Close, 45));
> Sell = 0;
>
> GraphXSpace = 10; /* create empty space of 10% top and bottom of
chart */
> Plot(C, " Close Price", colorGrey50, styleCandle);
>
> PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L, - 10);
> PlotShapes(shapeDownArrow * Sell, colorRed, 0, H, - 10);
>
> Plot(EMA(Close, 45), "EMA", colorRed);
>
> -------------------------------
>
> What I'm having problems with is:
>
> 1. How I generate sell arrows for sells caused by the Apply Stop?
>
> 2. On my chart, how can I not show a green arrow for a buy signals
> that occurs when a position is already active?
>
> Thanks.
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
GFT Forex Trading Accounts As low as $250 with up to 400:1 Leverage. Free Demo.
http://us.click.yahoo.com/lpv1TA/jlQNAA/U1CZAA/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/
|