Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
garykong wrote:This is one of the toughest thing to code. Let say the trading timeframe is 5-min, the "MH7" means the higher timeframe (15-min). The condition here requiring the moving average of 7-period in 15-min timeframe, ie. trending upward for BUY & trending downward for SELL... remember that we are coding in 5-min timeframe chart...
Gary,
Have you thought about simplifying the criteria to meet the capabilities of MS?
Instead of writing eoms of code to create sniffers to find out the current periodicity amd then increase one unit of periodicity for the sake of one line in an indicator; why not just use a longer multiple in the current periodicity.
e.g. If the base time frame is five minutes, then a seven-period 15 minute MA is almost equal to a 7*3 = 21 period 5 minute MA.
If your trading system is too sensitive to deal with these very small "indiscretions" then might I suggest the system is too sensitive to be dealing with everyday life on the bourse?
wabbit :D
--8<-------------------------
prdMultiplier:=3;
{Bollinger Bands}
UB:=BBandTop(Typical(),20,S,2);
LB:=BBandBot(Typical(),20,S,2);
{Keltner}
UKband:=Mov(Typical(),20,S)+1.5*Mov((H-L),20,S);
LKband:=Mov(Typical(),20,S)-1.5*Mov((H-L),20,S);
{Moving Averages}
M7:=Mov(C,7,S);
M23:=Mov(C,23,S);
MH7:=Mov(C,7*prdMultiplier,S);
{Slow Stochastic}
StDK:=Mov(Stoch(14,3),3,S);
StDD:=Mov(StDK,3,S);
{MACD}
FL:=Mov(C,9,E)-Mov(C,19,E);
SL:=Mov(Mov(C,9,E)-Mov(C,19,E),6,E);
{Trades}
Cond1:=C>UB OR C<LB AND Mov(UKband-LKband,6,S)>Mov(UB-LB,6,S);
Short:=Cond1 AND SAR(0.02,0.2)>C AND ROC(M7,1,%)<0 AND STDK<STDD AND FL<SL AND (O-C)>((H-O)+(C-L)) AND C<LB;
Long:=Cond1 AND SAR(0.02,0.2)<C AND M7>M23 AND ROC(M7,1,%)>0 AND ROC(MH7,1,%)>0 AND STDK>STDD AND FL>SL AND (C-O)>((O-L)+(H-C)) AND C>UB;
{plot}
Long-Short;
|