Hi Don --
The line of code you are asking about has IIF nested within IIF.
----------
Value3 = IIf(Range < Ref(Range, -1) OR Range > Ref(Range, -1), V, IIf(Range == Ref(Range, -1), V / Range , 0));
-----------
The statement is computing some value that will be assigned to variable Value3. This is an array function. It accepts arrays as inputs and returns an array as output.
It is easy to confuse the Function IIF with the Control Statement IF. Read up on both.
The sequence AmiBroker takes is to make the tests in order.
If Range < Range one bar ago, use V. (The remainder of the statement is executed, but no matter what the result is, V will be used for the assignment.)
If not, make the test that is in the false_part.
If Range is exactly equal to Range one bar ago, use V / Range
If not, use 0
Assign whichever value is to be used to variable Value3.
-----------------------
The code in line 5 makes little sense to me. After execution of line 5, Value3 will have one of three values:
V, V / Range, or 0.
These three do not even have the same dimension, so the code is immediately suspect.
Thanks,
Howard
SetChartBkColor( ParamColor("Chart Back Color",colorBlack));
Color=(colorGrey50); //=(colorAqua)== BarColor(Cyan)
LowColor=(colorYellow);
ClimaxColor=(colorRed);
ChurnColor=(colorGreen);
ClimaxChurnColor=(colorCustom12);
LowChurnColor=(colorWhite);
//AvgColor(Red);
//Variables: BarColor(Cyan);
// Set the variable "BarColor" equal to Color (Is "Color a variable also?)
BarColor = Color;
// Set the variable "Range" equal to the current bar's High minus the current bar's Low
Range = High - Low;
// Set the variable "Value1" equal to the current bar's Volume
Value1 = Volume;
// Set the variable "Value2" equal to the current bar's Volume multiplied by the the current bar's calculated Range
Value2 = Volume * Range;
/* Here is the line of code that I need help interpretting
Value3 = IIf(Range < Ref(Range, -1) OR Range > Ref(Range, -1), V, IIf(Range == Ref(Range, -1), V / Range , 0));
Plot(Value3,"Volume, Volume/Range, or Zero",colorWhite);
Plot(Range,"Range",colorGreen);
Plot(Volume / Range,"Volume/Range",colorRed);
// if Range <> 0 then Value3 = V/Range;
// Set the variable "Value4" equal to the 30-day moving average of Value1
Value4 = MA(Value1,30);
Color12=
// LowColor = Yellow
IIf (Value1 == LLV(Value1,20), LowColor,
// ClimaxColor = Red
IIf (Value2 == HHV(Value2,20), ClimaxColor,
// ChurnColor = Green
IIf (Value3 == HHV(Value3,20), ChurnColor,
// ClimaxChurnColor = Custom12
IIf (Value2 == HHV(Value2,20) AND Value3 == HHV(Value3,20), ClimaxChurnColor,
// LowChurnColor = White
IIf (Value3 == LLV(Value3,20) ,LowChurnColor,Color)))));
Plot(Value1,"Volume",Color12,2+4);
Plot(Value4,"Avg",colorYellow);
_SECTION_END();
Sell=Cross(trailArray,C);SellPrice=trailArray;
Thanks rnr. I tried that and it now sells at the high for some reason. I checked all of the backtest exit prices and they are all the high.
Well on daily quotes you only have the Open, High, Low and Close prices to work with. Your "intraday low crosses the trailing stop level" price is known only to you after it has happened so you could sell on the close that day or the open following day if EOD trading.Hi
I have noticed in the backtest results that when prices crosses below my trailstop the sellprice is the close because I have written
Buy=Cross(Close,trailArray) ; BuyPrice=C;
Sell=Cross(trailArray,Low) ; SellPrice = C;
Could someone please tell me what I have to write to have "sellprice= the price when the intraday low crosses the trailing stop level" so that when I backtest the sell price is my trailstop level?
Fixed it rnr
Thanks heaps
Sell=Cross(trailArray,C);SellPrice=Ref(trailArray,-1);
art27 said:I have noticed in the backtest results that when prices crosses below my trailstop the sellprice is the close because I have written
Buy=Cross(Close,trailArray) ; BuyPrice=C;
Sell=Cross(trailArray,Low) ; SellPrice = C;
Could someone please tell me what I have to write to have "sellprice= the price when the intraday low crosses the trailing stop level" so that when I backtest the sell price is my trailstop level?
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?