samedi 5 novembre 2016

Circular Reference thru StaticVarGet/Set.

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 OR Ref(Cover,-1),  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.


Circular Reference thru StaticVarGet/Set.

Aucun commentaire:

Enregistrer un commentaire