Problems with AFL Formula

#1
Hi I'm Having some problems with a formula, please help me out if you can:

I want to buy when pico1>pico2 AND Preco1<Preco2 is True. I used PlotShapes to determine if my formula was correct and it was as I expected. But when I use the same formula to Buy it, nothing happens on the Backtest, no stocks are bought. I can't undestand why...

pico1 = ValueWhen( Ref(HistMinCond,0), Ref(HistInd,-1), 1 );
pico2 = ValueWhen( Ref(HistMinCond,0), Ref(HistInd,-1), 2 );

Preco1 = ValueWhen( Ref(HistMinCond,0), L, 1 );
Preco2 = Preco1 = ValueWhen( Ref(HistMinCond,0), L, 2 );

PlotShapes( IIf( pico1>pico2 AND Preco1<Preco2,shapeSmallUpTriangle,shapeNone ),
colorGreen, 0, 0 , -12 );

Buy=pico1>pico2 AND Preco1<Preco2;
 
Last edited:

manojborle

Well-Known Member
#2
Hi I'm Having some problems with a formula, please help me out if you can:

I want to buy when pico1>pico2 AND Preco1<Preco2 is True. I used PlotShapes to determine if my formula was correct and it was as I expected. But when I use the same formula to Buy it, nothing happens on the Backtest, no stocks are bought. I can't undestand why...

pico1 = ValueWhen( Ref(HistMinCond,0), Ref(HistInd,-1), 1 );
pico2 = ValueWhen( Ref(HistMinCond,0), Ref(HistInd,-1), 2 );

Preco1 = ValueWhen( Ref(HistMinCond,0), L, 1 );
Preco2 = Preco1 = ValueWhen( Ref(HistMinCond,0), L, 2 );

PlotShapes( IIf( pico1>pico2 AND Preco1<Preco2,shapeSmallUpTriangle,shapeNone ),
colorGreen, 0, 0 , -12 );

Buy=pico1>pico2 AND Preco1<Preco2;
HistMinCond, HistInd this variable is not initialised.
You should first define these variables..., I have not seen any such functions in the AFL
 

Similar threads