Simple Coding Help - No Promise.

cloudTrader

Well-Known Member
After evaluating the code, found that the TradeStation not that easy to convert to Amibroker. Cause CoefficientR() function is private to TradeStation. Not many programmer able to do it. so the R is automatic calculated.

For easy way, here the Metastock Version, but you need to manually key in the R value.

PHP:
Length = Param("30 day historical volatility", 30, 3);
r=Param("Correlation coefficient of these securities",0.5,0,100);
Vf=Param("Volatility factor",1.5, 0,5);
Ticker2= ParamStr("2nd Ticker to Compare", "D05");

p1= C;
p2= Foreign(Ticker2, "Close");

hv1=StDev(Log(p1/Ref(p1, -1)), Length);
hv2=StDev(Log(p2/Ref(p2, -1)), Length);

newday=ROC(DayOfWeek(),1) !=0;
yp1=ValueWhen(newday, Ref(p1,-1));
yp2=ValueWhen(newday, Ref(p2,-1));
sprd= (p1/yp1) - (p2/yp2);

vb=vf*(hv1 + hv2) * sqrt(1/252) * (1-r);
Plot(sprd, "Spread", colorAqua, styleNoLabel);
Plot(vb, "UpperVB", colorRed);
Plot(-vb, "LowerVB", colorLime);
PlotGrid(0,colorGrey50);

Sorry my Net went down so couldn't reply. Thank you so much for the help.

The above code as you said is from the Metastock version , it is still wonderful for me as I will now be able to backtest in the real trading time. I will read the article and then manually backtest things.

Much Thanks to your humble replies. :clapping:

Regards.
 

LoneWolf

Well-Known Member
Hello AFL Coders,

Can some one help me in coding the follwing things -

1. I want to make an AFL marking PH/PL on charts. The conditions for PH is to be a bar whose high is higher than previous 2 bars and also higher from succeeding two bars. Reverse is true for PL.

Till This point its easy and I have coded. But on this there can be situations where there will be two consecutive PL, with no PH in between. IN such case I want to show only the recent lowest PL. So 2nd requiremnt is-

2. PH and PL should appear alternatively.

Thank you.
 
bro, I m an amateur in coding, still, few doubts in ur strategy.
1. only sell, no buy? that means is it short only strategy?
2. "Sell when price decrease 10% compare to buy price ", how can buy price be defined without buying anything? :annoyed: :confused:
3. Is this strategy applicable for intraday charts or daily charts? :confused:
4. for backtesting u need to define ur exit criteria also, it is missing :annoyed::annoyed:

thanks you very much

I want to buy when volume 3 time as average of 100 day

Sell when
1,price < 90% buy price ex: buy: 10$, sell if price < 9$
or 2, price < 90% of highest price in 10 day from the buying day

exp: Buy: 14/2 10
price 11 12 10 11 12
day 15/2 16/2 17/2 18/2 19/2
=> sell at 10$ in 17/2

(all is closing price of a day)
thanks you
 

LoneWolf

Well-Known Member
Hello AFL Coders,

Can some one help me in coding the follwing things -

1. I want to make an AFL marking PH/PL on charts. The conditions for PH is to be a bar whose high is higher than previous 2 bars and also higher from succeeding two bars. Reverse is true for PL.

Till This point its easy and I have coded. But on this there can be situations where there will be two consecutive PL, with no PH in between. IN such case I want to show only the recent lowest PL. So 2nd requiremnt is-

2. PH and PL should appear alternatively.

Thank you.
ANy Help ?? Any Body ??
 
thanks you very much

I want to buy when volume 3 time as average of 100 day

Sell when
1,price < 90% buy price ex: buy: 10$, sell if price < 9$
or 2, price < 90% of highest price in 10 day from the buying day

exp: Buy: 14/2 10
price 11 12 10 11 12
day 15/2 16/2 17/2 18/2 19/2
=> sell at 10$ in 17/2

(all is closing price of a day)
thanks you
please help
 

Similar threads