Just a step to the right |
Post Reply |
Author | |
blackdog
Regular Joined: 14 Nov 2006 Location: Vatican City State Posts: 43 |
Post Options
Quote Reply
Topic: Just a step to the right Posted: 15 Nov 2006 at 9:43am |
I have written an indicator that shows what tomorrows price must be for MACD crossover to occur. To do this I displace the indicator plot one bar to the right using Next>Advanced>Horizontal Shift 1 so that it plots the last price on tomorrows bar. I would prefer to do it within the formula but so far all attempts result in a plot which is truncated at todays bar. Any suggestions?
Here is the code sofar:-
n1 := input("Short moving average",12,1);n2 := input("Long moving average",26,1);ns := input("Signal periods",9,1);
r1 := 2/(n1+1); r2 := 2/(n2+1); ma12 := C*r1 + previous(C)*(1-r1); ma26 := C*r2 + previous(C)*(1-r2); res := wait(ma12 - ma26,25); signal := ma(res,ns,E); predictor := (signal+ma26*(1-r2)-ma12*(1-r1))/(r1-r2); [Name =MACDP; color=green]predictor;
{ Fill } {shows green for Predictor below price line = MACDH positive} {shows red for Predictor above price line = MACDH negative} [name =Fill; linestyle=fill][color =green] c;[color =red] predictor;[visible =true]
{ Markers } [visible =false][name =BUY; linestyle=marker; marker=type1; tooltip="Price passed above MACD Predictor"]cross (C,predictor);[name =SELL; linestyle=marker; marker=type2; tooltip="Price passed below MACD Predictor"]cross (predictor,C); |
|
lmbull
Newbie Joined: 08 Dec 2006 Posts: 11 |
Post Options Quote Reply Posted: 21 Nov 2007 at 6:52pm |
Thanks for this piece of code. What I was wondering is if it is possible to do an intra day scan of stock that have met this criteria, or on the snapshot data.
|
|
Post Reply |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |