- Joined
- 11 December 2011
- Posts
- 10
- Reactions
- 0
It takes an exit the next bar after the buy because the variable "BuyPrice" is a reserved variable which is an array. You assign "Close" to the BuyPrice at the beginning of the formula outside the loop so on every iteration of the loop the variable "PriceatBuy" is assigned the close price of that particular bar. That's why your exits are triggered immediately after your entry.
Captian black, sorry. BuyPrice is an array, but PriceAtBuy no, it is a single number. It is created for to be single number.
I
Is it possible to have Amibroker draw price bars without the open tick, like Tradeguider. For intraday charts the open tic isn't that useful, and by not show it IMO makes the graph easier to read. Even MS.net charts package has an option to not draw the open tic.
PlotOHLC (Null, High, Low, Close, "" , ColorBlack, StyleBar|StyleThick );
I think you will find every variable defined in AB is an array. If you create a variable PriceAtBuy = 2, it will just create an array n periods long with every array element set to the value of 2.
This code plots thick, black bars. I use coloured bars to give an indication of the trend and volume etc.Code:PlotOHLC (Null, High, Low, Close, "" , ColorBlack, StyleBar|StyleThick );
IIf(C>O, IIf(H>C, colorRGB(72,170,222), colorRGB(53,83,218)), IIf(L<C, colorRGB(245,170,13), colorRGB(227,43,36)))
Thanks that works fine, replacing ColorBlack, I can get different colours based on open and close.
Code:IIf(C>O, IIf(H>C, colorRGB(72,170,222), colorRGB(53,83,218)), IIf(L<C, colorRGB(245,170,13), colorRGB(227,43,36)))
I looked at it sometime back and looked to complicated, but I do use my own method for classifying relative volume.It's worth having a look at Karthik's VPA code as well to pick up a few ideas. It uses LinRegSlope calculations to change the bar colours depending on whether price is trending or in accumulation/distribution zones. I also have bars with extreme volume a particular colour as well.
I'm interested in identifying the value of the line signal of the MACD in the penultimate top. In the last one I am using the function ValueWhen (LastTop, Signal ()).
Could anyone help me?
Thanks.
Edilson
Hi Edilson --
ValueWhen has three parameters. From the AmiBroker Useer's Guide:
-----------------
VALUEWHEN
- get value of the array when condition met Trading system toolbox
(AFL 1.1)
SYNTAX valuewhen(EXPRESSION, ARRAY, n = 1)
RETURNS ARRAY
FUNCTION Returns the value of the ARRAY when the EXPRESSION was true on the n -th most recent occurrence. Note: this function allows also 0 and negative values for n - this enables referencing future
EXAMPLE valuewhen( cross( close, ma(close,5) ) ,macd(), 1)
--------------
If it is omitted, the third parameter has a default value of 1. To return the value one occurrence earlier, use a 2.
Your example would be:
xxx = ValueWhen (LastTop, Signal (), 2);
Thanks,
Howard
SetChartBkGradientFill(colorWhite,colorLightGrey,colorWhite);
Period= ParamList("Base","Monthly|Weekly|Daily|Hourly|15Minute|5Minute|1Minute",0);
if(Period=="Monthly"){
TimeFrameSet(inMonthly);
PlotOHLC(Open, High, Low, Close, "Monthly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}.....
Can anyone help me with restricting my symbols to those with only 3 characters?
Either in the importing of the data initially or in the coding where the buy's are selected.
I'd prefer it to be done when I import the data if possible...
Buy = StrLen ( Name () ) == 3;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?