Circular Reference thru StaticVarGet/Set.

LOVEENAJYOTHI

Well-Known Member
#1
Is Circular Reference possible in AFL ?
Tried StaticVarGet & Set , got desired results along with a lot of garbage AND utterly UnReliable in Live Trade bcoz everytime Explore/Scan/Backtest Button Clicked --> the AFL gives Different results each time.

Sample codes:
1.Basic Code

Code:
Buy=Buycondn;
Sell=SellCondn dependent on BuyCondn;
Short=ShortCondn OR Ref(Sell,-1);
Cover=CoverCondn dependent on ShortCondn;
//Wud love to define Buy=BuyCondn [B][COLOR="Red"]OR Ref(Cover,-1)[/COLOR][/B],  but obviously will not work, so tried the below code
2.Modified Code.
Code:
TempCvr=StaticVarGet("TempCvr");
Buy=Buycondn or TempCvr;
Sell=SellCondn dependent on BuyCondn;
Short=ShortCondn OR Ref(Sell,-1);
Cover=CoverCondn dependent on ShortCondn;
TempCvr= Ref(Cover,-1) ;
StaticVarSet("TempCvr",TempCvr,persist=True);
This Modified code gives, as desired, the Buy Signals @ bar next to Coverbar on chart , but in Analysis window , for every click it gives a diffrent result, especially if AllSymbols or more than 1 symbol is selected,
if CurrentSymbol is selected, the Results are Stable after the second or third clicks.

Plz Note: the ExRems are duly placed, no question of excess signals.

Any Insights by Respected Seniors/Coders wd be Highly Appreciated.

Thank You all.
LJ.
 

mastermind007

Well-Known Member
#2
Is Circular Reference possible in AFL ?
Tried StaticVarGet & Set , got desired results along with a lot of garbage AND utterly UnReliable in Live Trade bcoz everytime Explore/Scan/Backtest Button Clicked --> the AFL gives Different results each time.

Sample codes:
1.Basic Code

Code:
Buy=Buycondn;
Sell=SellCondn dependent on BuyCondn;
Short=ShortCondn OR Ref(Sell,-1);
Cover=CoverCondn dependent on ShortCondn;
//Wud love to define Buy=BuyCondn [B][COLOR="Red"]OR Ref(Cover,-1)[/COLOR][/B],  but obviously will not work, so tried the below code
2.Modified Code.
Code:
TempCvr=StaticVarGet("TempCvr");
Buy=Buycondn or TempCvr;
Sell=SellCondn dependent on BuyCondn;
Short=ShortCondn OR Ref(Sell,-1);
Cover=CoverCondn dependent on ShortCondn;
TempCvr= Ref(Cover,-1) ;
StaticVarSet("TempCvr",TempCvr,persist=True);
This Modified code gives, as desired, the Buy Signals @ bar next to Coverbar on chart , but in Analysis window , for every click it gives a diffrent result, especially if AllSymbols or more than 1 symbol is selected,
if CurrentSymbol is selected, the Results are Stable after the second or third clicks.

Plz Note: the ExRems are duly placed, no question of excess signals.

Any Insights by Respected Seniors/Coders wd be Highly Appreciated.

Thank You all.
LJ.
Cannot really add a lot to the mess without knowing what ur entry/exit conditions precisely are....

Try adding name of scrip, the chart id of the scrip etc into the static var.

Debugging this is not for faint hearted or fickle-minded!
 

LOVEENAJYOTHI

Well-Known Member
#3
Cannot really add a lot to the mess without knowing what ur entry/exit conditions precisely are....

Entry--->Nothing Special Any Entry Logic
Exit-----> Points based Trailing Stop which in turn Based on the Entry/EntryPrice


Try adding name of scrip, the chart id of the scrip etc into the static var.


YES!!!!!! just an addition of a string made all the difference, now the Results are Stable ,whether all or single symbol Selected in analysis window, The Results dont go dancing after second and subsequent Clicks.

Ofcourse there is a barely perceptible delay which TomasZ has alrdy warned abt in case of StaticVars.

Debugging this is not for faint hearted or fickle-minded!

Yup! had quite a few HeartAttacks myself looking at my own AFL.

Gud 2 know dat v hve atleast one BraveHart among us :)




Thank U MM for ur kind Help.