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

[amibroker] 3rd Argument to Peakbars cannot be resolved if a variable



PureBytes Links

Trading Reference Links

Hi – the following does not work:

// Find valid peak number

LastValidPeakNumber = IIf(BarsSince(Sell_Valid)<BarsSince
(PivotHigh),1,2);
 

// find bars to last valid peak

//THE FOLLOWING STATEMENT GIVES ERROR 5: Argument #3 has incorrect 
type (the function expects different argument type here)

ValidPeakBars=PeakBars(ZigArray,ZigPct,LastValidPeakNumber);

 
The LastValidPeakNumber should be an admissible parameter to 
PeakBars. If I substitute the first sentence to 

 

LastValidPeakNumber = IIf(True,1,2);


Then the second statement works. I include the whole formula below - 
that otherwise works fine to identify when the zig function is 
valid. 

Is there a "bug" – or is there something I'm not getting?

 

Best regards

Jens Tiedemann 

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

// find last valid peak to be used in PeakBars function as in 
PeakBars(Array,%Change,LastValidPeakNumber)

ZigPct = 3;
ZigArray = Close;

// Calculate Buy_Valid/Sell_Valid - all works!
mystartbar = SelectedValue(BarIndex());  // FOR GRAPHING
mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), 
DateNum(),1));
InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), 
ZigArray , 1 ) ) ;
Temp1 = IIf(BarIndex() >= mystartbar, InitialValue, Null) ;
ZZ = Zig(ZigArray,LastValue(ZigPct)) ; 
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1, 
Null),1);
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1, 
Null),1);
Buy_Valid = IIf(ZigArray>(1+(LastValue(ZigPct)/100))*(ValueWhen
(PivotLow, ZigArray, 1))
AND ROC(ZZ,1) > 0,1,0); 
Sell_Valid = IIf(ZigArray<(1-(LastValue(ZigPct)/100))*(ValueWhen
(PivotHigh, ZigArray, 1))
AND ROC(ZZ,1) < 0,1,0); 
Buy_Valid = ExRem(Buy_Valid,Sell_Valid);
Sell_Valid = ExRem(Sell_Valid,Buy_Valid);




// Find valid peak number
LastValidPeakNumber = IIf(BarsSince(Sell_Valid)<BarsSince
(PivotHigh),1,2);

// find bars to last valid peak
//THE FOLLOWING STATEMENT GIVES ERROR 5: Argument #3 has incorrect 
type (the function expects different argument type here)
ValidPeakBars=PeakBars(ZigArray,ZigPct,LastValidPeakNumber);




//Plot section - can be disregarded...
PlotShapes( shapeCircle*PivotLow, colorGreen,0, L, -20) ; 
PlotShapes( shapeCircle*PivotHigh,colorRed,0,H, 20) ;

Plot(Temp1, " ", colorBlack,styleLine);
Plot((1+(LastValue(ZigPct)/100))*(Temp1), " ", colorGreen, 
styleLine) ;
Plot((1-(LastValue(ZigPct)/100))*(Temp1), " ", colorRed, styleLine) ;

PlotShapes( shapeUpArrow*Buy_Valid, colorGreen,0, L, -20); 
PlotShapes( shapeDownArrow*Sell_Valid, colorRed,0,H, -20) ;

BarColors = 
IIf(BarsSince(Buy_Valid) < BarsSince(Sell_Valid) 
AND BarsSince(Buy_Valid)!=0, colorGreen,
IIf(BarsSince(Sell_Valid) < BarsSince(Buy_Valid)
AND BarsSince(Sell_Valid)!=0,  colorRed, colorBlue));

Plot(C, " ", BarColors,  styleBar ) ; 
Plot(ZZ," ", colorLightGrey,styleLine|styleThick);
Plot(ZZ," ", BarColors,styleDots|styleNoLine);








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/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/