參數(shù):j1 為(1000,-1000,2000) DIF:(EMA(c,12)-EMA(c,26)); DEA:EMA(DIF,9); MACD:(DIF-DEA)*2,COLORSTICK; DEA1:=2/10*DIF+8/10*EMA(REF(DIF,1),9); Tsmacd:=2*DIF-2*DEA1; MACD1:=MACD; MACD昨:=ref(Tsmacd,1); Macdx:=if(j1=-999,macd1,if(j1=-1000,MACD昨,j1)); 股價(jià):=351/28*(10/16*macdx+ema(ref(dif,1),9)-11/13*EMA(REF(c,1),12)+25/27*EMA(REF(c,1),26)); DRAWTEXT(j1=-999 and Islastbar ,dif ,'設(shè)J=-999,所演即時(shí)股價(jià);'+NUMTOSTR(股價(jià),2)+' ' ),colorc0c0c0,ALIGN2; 本帖隱藏的內(nèi)容DRAWTEXT(j1=-1000 and Islastbar ,dif ,'設(shè)J=-1000,J線拐頭股價(jià);'+NUMTOSTR(股價(jià),2)+' ' ),colorc0c0c0,ALIGN2;DRAWTEXT(j1=Macdx and Islastbar ,dif ,'設(shè)J=自定義,J線達(dá)標(biāo)臨界股價(jià);'+NUMTOSTR(股價(jià),2)+' ' ),colorc0c0c0,ALIGN2; 山丘村長(zhǎng)先生的公式: 黃線是金叉死叉反推價(jià),白線是diff反推價(jià),紫線是macd反推價(jià)。 各代碼如下: 參數(shù): short(12,1,100,1) long(26,1,100,1) M(9,1,100,1) DIFF :=EMA(CLOSE,SHORT) - EMA(CLOSE,LONG); DEA :=EMA(DIFF,M); MACD :=2*(DIFF-DEA); jcsc:=(M-1)/(M+1)*dea/(1-2/(m+1));{計(jì)算出金叉死叉時(shí)的Diff值} dd:=(macd/2+(dea*(m-1)/(M+1)))/(1-2/(m+1));{計(jì)算出明日macd=macd時(shí)的Diff值} xx:(diff*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{計(jì)算今日Diff=diff的對(duì)應(yīng)股價(jià)} js:(jcsc*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{計(jì)算金叉死叉的對(duì)應(yīng)股價(jià)} ddd:(dd*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{計(jì)算macd柱體變向時(shí)的對(duì)應(yīng)股價(jià)} {改山丘村長(zhǎng)反向推算macd 便于看盤(pán) macd參數(shù)長(zhǎng)短自己改就是了} input: short (12,1,20), long(26,1,60),M(9,1,30); DIFF: EMA(CLOSE, short)-EMA(CLOSE, long ),color0066ff,LINETHICK1; {partline(DIFF,DIFF>=ref(DIFF,1),rgb(255,0,0),DIFF<ref(DIFF,1),rgb(0,255,0)),linethick1;} DEA:EMA(DIFF,M),COLOR00BB00,LINETHICK1; MACD: (DIFF-DEA)*2,COLORSTICK; {partline(DIFF,DIFF>=ref(DIFF,1),rgb(255,0,0),DIFF<ref(DIFF,1),rgb(0,255,0)),linethick2; FILLRGN(DIFF,DEA,DIFF>DEA,rgb(255,0,0),DIFF<DEA,rgb(0,255,0)),linethick2;} {中軸:0,LAYER0,Coloreeeeee,LINETHICK1;} jcsc:=(M-1)/(M+1)*dea/(1-2/(m+1));{計(jì)算出金叉死叉時(shí)的Diff值} dd:=(macd/2+(dea*(m-1)/(M+1)))/(1-2/(m+1));{計(jì)算出明日macd=macd時(shí)的Diff值} xx:=(diff*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{計(jì)算今日Diff=diff的對(duì)應(yīng)股價(jià)} js:=(jcsc*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{計(jì)算金叉死叉的對(duì)應(yīng)股價(jià)} ddd:=(dd*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{計(jì)算macd柱體變向時(shí)的對(duì)應(yīng)股價(jià)}; DRAWTEXTEX(c,3,0,400,'DIFF拐頭股價(jià):'+NUMTOSTR(xx,2)),ColorFFFFFF,LINETHICK3; DRAWTEXTEX(c,175,0,0,'MACD柱體變向?qū)?yīng)股價(jià):'+NUMTOSTR(ddd,2)),Color00A5FF,LINETHICK3; DRAWTEXTEX(c,410,0,800,'金叉死叉對(duì)應(yīng)股價(jià):'+NUMTOSTR(js,2)),COLOR00BB00,LINETHICK3; {PARTLINE(DIFF,CROSS(DIFF,DEA) AND DIFF<-0.2,RGB(255,245,12)),CROSSDOT,LINETHICK5; PARTLINE(DIFF,CROSS(DIFF,DEA) AND DIFF>0,RGB(252,24,212)),CROSSDOT,LINETHICK5; PARTLINE(DIFF,CROSS(DIFF,DEA) AND DIFF>-0.2 AND DIFF<0,RGB(200,80,20)),CROSSDOT,LINETHICK7; PARTLINE(DIFF,CROSS(DEA,DIFF) AND DIFF>0,RGB(125,245,252)),CIRCLEDOT,LINETHICK5;} |
|
來(lái)自: agoha > 《我的圖書(shū)館》