COCO研究院

 找回密碼
 註冊
搜索
查看: 15658|回復: 19

SOUTH WIND AFL程式碼 大家用用看吧!

[複製鏈接]
發表於 10-5-7 15:20 | 顯示全部樓層 |閱讀模式

SOUTH WIND AFL CODE PIG

SOUTH WIND AFL CODE PIG
 樓主| 發表於 10-5-7 15:24 | 顯示全部樓層
回復 1# alexwang7777


  1. // The Foundation by Southwind v-13.00 Int
  2. //southwind09@gmail.com

  3. _SECTION_BEGIN("Haiken");

  4. Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
  5. r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
  6. r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
  7. r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );

  8. Prd1=Param("ATR Period",4,1,20,1);
  9. Prd2=Param("Look Back",7,1,20,1);
  10. green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
  11. red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);

  12. HaClose =EMA((O+H+L+C)/4,3); // Woodie
  13. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  14. HaHigh = Max( H, Max( HaClose, HaOpen ) );
  15. HaLow = Min( L, Min( HaClose, HaOpen ) );
  16. Temp = Max(High, HaOpen);
  17. Temp = Min(Low,HaOpen);


  18. m1=MACD(r1,r2);
  19. s1=Signal(r1,r2,r3);
  20. mycolor=IIf(m1<0 AND m1>s1, ColorRGB(230,230,0),IIf(m1>0 AND m1>s1,ColorRGB(0,0,100),IIf(m1>0 AND m1<s1,colorOrange,colorDarkRed)));

  21. if(Show_color)

  22. {
  23. ColorHighliter = myColor;
  24. SetBarFillColor( ColorHighliter );
  25. }
  26. //////////
  27. m1=MACD(r1,r2);
  28. s1=Signal(r1,r2,r3);
  29. mycolor=IIf(m1<0 AND m1>s1, ColorRGB(230,230,0),IIf(m1>0 AND m1>s1,ColorRGB(0,0,100),IIf(m1>0 AND m1<s1,colorOrange,colorDarkRed)));
  30. if(Show_color)

  31. {
  32. ColorHighliter = mycolor;
  33. SetBarFillColor( ColorHighliter );
  34. }

  35. barColor=IIf(C>Green ,colorBlue,IIf(C < RED,colorRed,colorYellow));
  36. barColor2=IIf(Close > Open, colorWhite, colorRed);


  37. if( ParamToggle("Plot Normal Candle", "No,Yes", 1 ) )
  38. PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, " " , barcolor, styleCandle | styleThick );
  39. else
  40. PlotOHLC( Open, High, Low, Close, " " , barcolor2, styleCandle | styleThick );

  41. _SECTION_END();



  42. _SECTION_BEGIN("Line");
  43. a = Param("Average Pds", 5, 1, 10, 1 );
  44. n = Param("Short Pds", 8, 5, 21, 1 );
  45. m = Param("Long Pds", 60, 0, 90, 1 );

  46. Var4 =(Low+High+2*Close)/4;
  47. OP = EMA(Var4,a);
  48. res1 = HHV(OP,n);

  49. res2 =HHV(OP,m);
  50. sup2 =LLV(OP,m);
  51. sup1 =LLV(OP,n);

  52. Linecolor = IIf(Op==sup1,colorCustom12,IIf(Op==res1,10,7));

  53. _SECTION_BEGIN("Rays1");
  54. line=ParamToggle("Line","No|Yes",1);
  55. if(line)
  56. {

  57. Pp1=Param("Ray_Period1",3,1,20,1);
  58. Pp2=Param("ATR_Period1",4,1,20,1);
  59. Cal=HHV(LLV(HaHigh,Pp1)-ATR(Pp2),5);

  60. Plot(Cal,"",Linecolor ,ParamStyle("styleLine 1",styleLine|styleThick,maskAll));
  61. positive= Cross(HaClose,Cal);
  62. negative=Cross(Cal,HaClose);

  63. PlotShapes( IIf( positive, shapeHollowSmallCircle, shapeNone ), colorBrightGreen, layer = 0, yposition = HaLow, offset = -4);
  64. PlotShapes( IIf( negative, shapeHollowSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = 4);
  65. }

  66. _SECTION_END();




  67. _SECTION_BEGIN("OsSetting");

  68. Ovos = ParamToggle("Display_OVOS", "No|Yes", 0);
  69. OBSetting=Param("Setting",40,1,500,1);
  70. Bline = StochD(OBSetting);
  71. Oversold=Bline<=30;
  72. Overbought=Bline>=85;

  73. if(Ovos)
  74. {
  75. PlotShapes (IIf(Oversold, shapeHollowSmallCircle, shapeNone) ,38, layer = 0, yposition = haLow, offset = -8 );
  76. PlotShapes (IIf(Overbought, shapeHollowSmallCircle, shapeNone) ,colorBrown, layer = 0, yposition = haHigh, offset = 7 );
  77. }

  78. _SECTION_END();


  79. _SECTION_BEGIN("TSKPPIVOT");
  80. CHiPr = 0;
  81. CLoPr = 9999999;
  82. blsLong = 0;
  83. PrevCOBar = 0;
  84. NumBars = 0;
  85. PrePP = 0;
  86. PrevLowVal = 9999999;
  87. BuySig = 0;
  88. blsShort = 0;
  89. PrevHiVal = 0;
  90. blsNewCO = 0;
  91. BarDif = 0;

  92. KPA900Val = E_TSKPA900(Close);
  93. KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);

  94. // -- Create 0-initialized arrays the size of barcount
  95. aHPivs = haHigh - haHigh;
  96. aLPivs = haLow - haLow;
  97. aHiVal = haHigh - haHigh;
  98. aLoVal = haLow - haLow;


  99. Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
  100. sctotal = 0;
  101. sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
  102. sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
  103. sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
  104. sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
  105. sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
  106. sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
  107. sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
  108. sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
  109. sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);


  110. for (curBar=0; curBar < BarCount-1; curBar++)
  111. {

  112. if ( curBar == 0 )
  113. {
  114. CHiPr = haHigh[curBar];
  115. CHiBar = curBar;
  116. CLoPr = haLow[curBar];
  117. CLoBar = curBar;
  118. blsLong = 0;
  119. blsShort = 0;
  120. blsNewCO = 0;
  121. PrePP = 0;
  122. PrevCOBar = 0;
  123. PrevHiVal = haHigh[curBar];
  124. PrevLowVal = haLow[curBar];
  125. BuySig = 0;
  126. SellSig = 0;
  127. blsLL = 0;
  128. }

  129. if (haHigh[CurBar] >= CHiPr) {
  130. CHiPr = haHigh[CurBar];
  131. ChiBar = CurBar;
  132. }

  133. if (haLow[CurBar] <= CLoPr) {
  134. CLoPr = haLow[CurBar];
  135. CLoBar = CurBar;
  136. }

  137. if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
  138. BarDif = CurBar - PrevCOBar;
  139. if (BarDif >= NumBars) {
  140. blsLong = 1;
  141. blsShort = 0;
  142. blsNewCO = 1;
  143. PrevCOBar = CurBar;
  144. }
  145. }

  146. if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
  147. BarDif = CurBar - PrevCOBar;
  148. if (BarDif >= NumBars) {
  149. blsLong = 0;
  150. blsShort = 1;
  151. blsNewCO = 1;
  152. PrevCOBar = CurBar;
  153. }
  154. }

  155. if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
  156. LVal = CurBar - CLoBar;
  157. for (j= CLoBar-1; j <= CLoBar+1; j++)
  158. {
  159. if (j >=0) {
  160. aLPivs[j] = 1;
  161. aLoVal[j] = CLoPr;
  162. }
  163. }
  164. PrePP = -1;
  165. blsNewCO = 0;
  166. CHiPr = haHigh[CurBar];
  167. CHiBar = CurBar;
  168. CLoPr = haLow[Curbar];
  169. CLoBar = CurBar;
  170. }
  171. else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
  172. HVal = CurBar - CHiBar;
  173. for (j= CHiBar-1; j <= CHiBar+1; j++)
  174. {
  175. if (j >=0) {
  176. aHPivs[j] = 1;
  177. aHiVal[j] = CHiPr;
  178. }
  179. }
  180. PrePP = 1;
  181. blsNewCO = 0;
  182. CHiPr = haHigh[CurBar];
  183. CHiBar = CurBar;
  184. CLoPr = haLow[Curbar];
  185. CLoBar = CurBar;
  186. }
  187. }

  188. PlotShapes(IIf(aHPivs == 1, shapeHollowSmallSquare,shapeNone), 25,0, aHiVal+0.05,Offset = 6);
  189. PlotShapes(IIf(aLPivs == 1, shapeHollowSmallSquare,shapeNone), colorCustom11,0, aLoVal-0.05, Offset = -6);

  190. _SECTION_END();



  191. _SECTION_BEGIN("TSKPMoMo");


  192. blsLong = 0;



  193. KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
  194. // tskp_upsell, tskp_triggerline, tskp_triggerlinevma
  195. sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
  196. KPTriggerLine = tskp_triggerline;
  197. KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
  198. //tskp_fast2val1, tskp_fast2val2
  199. dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
  200. KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1);



  201. Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
  202. sctotal = 0;
  203. sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
  204. sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
  205. sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
  206. sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
  207. sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
  208. sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
  209. sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
  210. sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
  211. sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);

  212. // tskp_mediumma,tskp_mediumup,tskp_mediumdown
  213. dummy = E_TSKPMEDIUM(Close);
  214. KPMediumUP = tskp_mediumup;
  215. KPMediumDwn = tskp_mediumdown;
  216. KPMediumMA = tskp_mediumma;

  217. // -- Create 0-initialized arrays the size of barcount
  218. aHPivs = H - H;
  219. aLPivs = L - L;
  220. aHiVal = H - H;
  221. aLoVal = L - L;


  222. for (curBar=5; curBar < BarCount-1; curBar++)
  223. {


  224. if( (blsLong == -1) OR (blsLong == 0))
  225. {
  226. if ((sctotal[CurBar] >= 5) AND (KPMediumUP[CurBar] > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == 1) AND
  227. (KPFast2Val[CurBar] == 1) AND (KPTriggerLine[CurBar] >= KPStopLine[CurBar] ))
  228. {
  229. blsLong = 1;
  230. aLPivs[CurBar] = 1;
  231. aLoVal[CurBar] = Low[CurBar];
  232. }
  233. }

  234. if( (blsLong == 1) OR (blsLong == 0))
  235. {
  236. if ((sctotal[CurBar] <= -5) AND (KPMediumDwn[CurBar] < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == -1) AND
  237. (KPFast2Val[CurBar] == -1) AND (KPTriggerLine[CurBar] <= KPStopLine[CurBar] ))
  238. {
  239. blsLong = -1;
  240. aHPivs[Curbar] = 1;
  241. aHiVal[Curbar] = High[Curbar];
  242. }
  243. }

  244. if ((blsLong == 1) AND ((sctotal[CurBar] < 5) OR (KPMediumUP[CurBar] < KPMediumMA[CurBar] ) OR
  245. (KPFast2Val[CurBar] < 1) OR (KPFast3Val[CurBar] < 1) OR (KPTriggerLine[CurBar] < KPStopLine[CurBar] )) )
  246. {
  247. blsLong= 0;
  248. }

  249. if ((blsLong == -1) AND ((sctotal[CurBar] > -5) OR (KPMediumDwn[CurBar] > KPMediumMA[CurBar] ) OR
  250. (KPFast2Val[CurBar] > -1) OR (KPFast3Val[CurBar] > -1) OR
  251. (KPTriggerLine[CurBar] > KPStopLine[CurBar] )) )
  252. {
  253. blsLong = 0;
  254. }
  255. }


  256. PlotShapes (IIf(aHPivs == 1, shapeSmallCircle, shapeNone) ,colorOrange, layer = 0, yposition = haHigh, offset = 7 );
  257. PlotShapes (IIf(aLPivs == 1, shapeSmallCircle, shapeNone) ,10, layer = 0, yposition = haLow, offset = -8 );

  258. _SECTION_END();






  259. _SECTION_BEGIN("Pivot");
  260. nBars = Param("Number of bars", 12, 3, 40);
  261. LP=Param("LookBack Period",150,1,500,1);
  262. bShowTCZ = Param("Show TCZ", 0, 0, 1);
  263. nExploreBarIdx = 0;
  264. nExploreDate = 0;
  265. nCurDateNum = 0;
  266. DN = DateNum();
  267. DT = DateTime();
  268. bTCZLong = False;
  269. bTCZShort = False;
  270. nAnchorPivIdx = 0;
  271. ADX8 = ADX(8);
  272. if(Status("action")==1) {
  273. bDraw = True;
  274. bUseLastVis = 1;
  275. } else {
  276. bDraw = False;
  277. bUseLastVis = False;
  278. bTrace = 1;
  279. nExploreDate = Status("rangetodate");
  280. for (i=LastValue(BarIndex());i>=0;i--) {
  281. nCurDateNum = DN[i];
  282. if (nCurDateNum == nExploreDate) {
  283. nExploreBarIdx = i;
  284. }
  285. }
  286. }

  287. if (bDraw) {
  288. }
  289. aHPivs = HaHigh - HaHigh;
  290. aLPivs = HaLow - HaLow;
  291. aHPivHighs = HaHigh - HaHigh;
  292. aLPivLows = HaLow - HaLow;
  293. aHPivIdxs = HaHigh - HaHigh;
  294. aLPivIdxs = HaLow - HaLow;
  295. aAddedHPivs = HaHigh - HaHigh;
  296. aAddedLPivs = HaLow - HaLow;
  297. aLegVol = HaHigh - HaHigh;
  298. aRetrcVol = HaHigh - HaHigh;
  299. nHPivs = 0;
  300. nLPivs = 0;
  301. lastHPIdx = 0;
  302. lastLPIdx = 0;
  303. lastHPH = 0;
  304. lastLPL = 0;
  305. curPivBarIdx = 0;
  306. aHHVBars = HHVBars(HaHigh, nBars);
  307. aLLVBars = LLVBars(HaLow, nBars);
  308. aHHV = HHV(HaHigh, nBars);
  309. aLLV = LLV(HaLow, nBars);
  310. nLastVisBar = LastValue(
  311. Highest(IIf(Status("barvisible"), BarIndex(), 0)));
  312. curBar = IIf(nlastVisBar > 0 AND bUseLastVis, nlastVisBar,
  313. IIf(Status("action")==4 AND nExploreBarIdx > 0, nExploreBarIdx,
  314. LastValue(BarIndex())));
  315. curTrend = "";
  316. if (aLLVBars[curBar] < aHHVBars[curBar])
  317. curTrend = "D";
  318. else
  319. curTrend = "U";
  320. if (curBar >= LP) {
  321. for (i=0; i<LP; i++) {
  322. curBar = IIf(nlastVisBar > 0 AND bUseLastVis,
  323. nlastVisBar-i,
  324. IIf(Status("action")==4 AND nExploreBarIdx > 0,
  325. nExploreBarIdx-i,
  326. LastValue(BarIndex())-i));
  327. if (aLLVBars[curBar] < aHHVBars[curBar]) {
  328. if (curTrend == "U") {
  329. curTrend = "D";
  330. curPivBarIdx = curBar - aLLVBars[curBar];
  331. aLPivs[curPivBarIdx] = 1;
  332. aLPivLows[nLPivs] = HaLow[curPivBarIdx];
  333. aLPivIdxs[nLPivs] = curPivBarIdx;
  334. nLPivs++;
  335. }
  336. } else {
  337. if (curTrend == "D") {
  338. curTrend = "U";
  339. curPivBarIdx = curBar - aHHVBars[curBar];
  340. aHPivs[curPivBarIdx] = 1;
  341. aHPivHighs[nHPivs] = HaHigh[curPivBarIdx];
  342. aHPivIdxs[nHPivs] = curPivBarIdx;
  343. nHPivs++;
  344. }
  345. }
  346. }
  347. }
  348. curBar =
  349. IIf(nlastVisBar > 0 AND bUseLastVis,
  350. nlastVisBar,
  351. IIf(Status("action")==4 AND nExploreBarIdx > 0,
  352. nExploreBarIdx,
  353. LastValue(BarIndex()))
  354. );
  355. if (nHPivs >= 2 AND nLPivs >= 2) {
  356. lastLPIdx = aLPivIdxs[0];
  357. lastLPL = aLPivLows[0];
  358. lastHPIdx = aHPivIdxs[0];
  359. lastHPH = aHPivHighs[0];
  360. nLastHOrLPivIdx = Max(lastLPIdx, lastHPIdx);
  361. nAddPivsRng = curBar - nLastHOrLPivIdx;
  362. aLLVAfterLastPiv = LLV(HaLow, nAddPivsRng);
  363. nLLVAfterLastPiv = aLLVAfterLastPiv[curBar];
  364. aLLVIdxAfterLastPiv = LLVBars(HaLow, nAddPivsRng);
  365. nLLVIdxAfterLastPiv = curBar - aLLVIdxAfterLastPiv[curBar];
  366. aHHVAfterLastPiv = HHV(HaHigh, nAddPivsRng);
  367. nHHVAfterLastPiv = aHHVAfterLastPiv[curBar];
  368. aHHVIdxAfterLastPiv = HHVBars(HaHigh, nAddPivsRng);
  369. nHHVIdxAfterLastPiv = curBar - aHHVIdxAfterLastPiv[curBar];
  370. if (lastHPIdx > lastLPIdx) {




  371. if (aHPivHighs[0] < aHPivHighs[1]) {

  372. if (nLLVAfterLastPiv < aLPivLows[0] AND
  373. (nLLVIdxAfterLastPiv - lastHPIdx - 1) >= 1
  374. AND nLLVIdxAfterLastPiv != curBar ) {

  375. // -- OK, we'll add this as a pivot.
  376. // Mark it for plotting...
  377. aLPivs[nLLVIdxAfterLastPiv] = 1;
  378. aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

  379. // ...and then rearrange elements in the
  380. // pivot information arrays
  381. for (j=0; j<nLPivs; j++) {
  382. aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
  383. aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
  384. }
  385. aLPivLows[0] = nLLVAfterLastPiv;
  386. aLPivIdxs[0] = nLLVIdxAfterLastPiv;
  387. nLPivs++;

  388. // -- Test whether to add piv given last piv is high
  389. // AND we have lower highs
  390. }

  391. // -- Here, the last piv is a high piv, and we have
  392. // higher-highs. The most likely addition is a
  393. // Low piv that is a retracement.
  394. } else {

  395. if (nLLVAfterLastPiv > aLPivLows[0] AND
  396. (nLLVIdxAfterLastPiv - lastHPIdx - 1) >= 1
  397. AND nLLVIdxAfterLastPiv != curBar ) {

  398. // -- OK, we'll add this as a pivot.
  399. // Mark it for plotting...
  400. aLPivs[nLLVIdxAfterLastPiv] = 1;
  401. aAddedLPivs[nLLVIdxAfterLastPiv] = 1;

  402. // ...and then rearrange elements in the
  403. // pivot information arrays
  404. for (j=0; j<nLPivs; j++) {
  405. aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
  406. aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
  407. }
  408. aLPivLows[0] = nLLVAfterLastPiv;
  409. aLPivIdxs[0] = nLLVIdxAfterLastPiv;
  410. nLPivs++;

  411. // -- Test whether to add piv given last piv is high
  412. // AND we have lower highs
  413. }
  414. // -- The last piv is a high and we have higher highs
  415. // OR lower highs
  416. }

  417. /* ****************************************************************
  418. Still finding missed pivot(s). Here, the last piv is a low piv.
  419. **************************************************************** */


  420. } else {

  421. // -- First case, lower highs
  422. if (aHPivHighs[0] < aHPivHighs[1]) {

  423. if (nHHVAfterLastPiv < aHPivHighs[0] AND
  424. (nHHVIdxAfterLastPiv - lastLPIdx - 1) >= 1
  425. AND nHHVIdxAfterLastPiv != curBar ) {

  426. // -- OK, we'll add this as a pivot.
  427. // Mark that for plotting
  428. aHPivs[nHHVIdxAfterLastPiv] = 1;
  429. aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

  430. // ...and then rearrange elements in the
  431. // pivot information arrays
  432. for (j=0; j<nHPivs; j++) {
  433. aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
  434. aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
  435. }
  436. aHPivHighs[0] = nHHVAfterLastPiv;
  437. aHPivIdxs[0] = nHHVIdxAfterLastPiv;
  438. nHPivs++;

  439. // -- Test whether to add piv given last piv is high
  440. // AND we have lower highs
  441. }

  442. // -- Second case when last piv is a low piv, higher highs
  443. // Most likely addition is high piv that is a retracement.
  444. // Considering adding a high piv as long as it is higher
  445. } else {

  446. // -- Where I have higher highs,
  447. if (nHHVAfterLastPiv > aHPivHighs[0] AND
  448. (nHHVIdxAfterLastPiv - lastLPIdx - 1) >= 1
  449. AND nHHVIdxAfterLastPiv != curBar ) {

  450. // -- OK, we'll add this as a pivot.
  451. // Mark it for plotting...
  452. aHPivs[nHHVIdxAfterLastPiv] = 1;
  453. aAddedHPivs[nHHVIdxAfterLastPiv] = 1;

  454. // ...and then rearrange elements in the
  455. // pivot information arrays
  456. for (j=0; j<nHPivs; j++) {
  457. aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
  458. aHPivIdxs[nHPivs-j] = aHPivIdxs[nhPivs-(j+1)];
  459. }
  460. aHPivHighs[0] = nHHVAfterLastPiv;
  461. aHPivIdxs[0] = nHHVIdxAfterLastPiv;
  462. nHPivs++;

  463. // -- Test whether to add piv given last piv is high
  464. // AND we have lower highs
  465. }

  466. }

  467. }

  468. // -- If there are at least two of each
  469. }

  470. /* ****************************************
  471. // -- Done with finding pivots
  472. ***************************************** */


  473. if (bDraw) {

  474. // -- OK, let's plot the pivots using arrows

  475. PlotShapes( IIf(aAddedHPivs==1, shapeHollowSmallSquare, shapeNone), colorCustom12,layer = 0, yposition = HaHigh, offset = 13);
  476. PlotShapes( IIf(aAddedLPivs==1, shapeHollowSmallSquare, shapeNone), colorYellow, layer = 0, yposition = HaLow, offset = -13);
  477. }


  478. /* ****************************************
  479. // -- Done with discovering and plotting pivots
  480. ***************************************** */

  481. // -- I'm going to want to look for possible retracement

  482. risk = 0;
  483. profInc = 0;
  484. nLeg0Pts = 0;
  485. nLeg0Bars = 0;
  486. nLeg0Vol = 0;
  487. nLeg1Pts = 0;
  488. nLeg1Bars = 0;
  489. nLeg1Vol = 0;
  490. nLegBarsDiff = 0;
  491. nRtrc0Pts = 0;
  492. nRtrc0Bars = 0;
  493. nRtrc0Vol = 0;
  494. nRtrc1Pts = 0;
  495. nRtrc1Bars = 0;
  496. nRtrc1Vol = 0;

  497. minRtrc = 0;
  498. maxRtrc = 0;
  499. minLine = 0;
  500. maxLine = 0;
  501. triggerLine = 0;
  502. firstProfitLine = 0;
  503. triggerInc = 0;
  504. triggerPrc = 0;
  505. firstProfitPrc = 0;
  506. retrcPrc = 0;
  507. retrcBar = 0;
  508. retrcBarIdx = 0;
  509. retrcRng = 0;
  510. aRetrcPrc = HaHigh-HaHigh;
  511. aRetrcPrcBars = HaHigh-HaHigh;
  512. aRetrcClose = HaClose;
  513. retrcClose = 0;

  514. // -- Do TCZ calcs. Arrangement of pivs very specific
  515. // for this setup.
  516. if (nHPivs >= 2 AND
  517. nLPivs >=2 AND
  518. aHPivHighs[0] > aHPivHighs[1] AND
  519. aLPivLows[0] > aLPivLows[1]) {

  520. tcz500 =
  521. (aHPivHighs[0] -
  522. (.5 * (aHPivHighs[0] - aLPivLows[1])));

  523. tcz618 =
  524. (aHPivHighs[0] -
  525. (.618 * (aHPivHighs[0] - aLPivLows[1])));

  526. tcz786 =
  527. (aHPivHighs[0] -
  528. (.786 * (aHPivHighs[0] - aLPivLows[0])));

  529. retrcRng = curBar - aHPivIdxs[0];
  530. aRetrcPrc = LLV(HaLow, retrcRng);
  531. aRetrcPrcBars = LLVBars(HaLow, retrcRng);

  532. retrcPrc = aRetrcPrc[curBar];
  533. retrcBarIdx = curBar - aRetrcPrcBars[curBar];
  534. retrcClose = aRetrcClose[retrcBarIdx];

  535. // -- bTCZLong setup?
  536. bTCZLong = (

  537. // -- Are retracement levels arranged in
  538. // tcz order?

  539. // .500 is above .786 for long setups
  540. tcz500 >= (tcz786 * (1 - .005))
  541. AND
  542. // .681 is below .786 for long setups
  543. tcz618 <= (tcz786 * (1 + .005))
  544. AND

  545. // -- Is the low in the tcz range
  546. // -- Is the close >= low of tcz range
  547. // and low <= high of tcz range
  548. retrcClose >= ((1 - .01) * tcz618)
  549. AND
  550. retrcPrc <= ((1 + .01) * tcz500)
  551. );

  552. // -- risk would be high of signal bar minus low of zone
  553. //risk = 0;

  554. // -- lower highs and lower lows
  555. } else if (nHPivs >= 2 AND nLPivs >=2
  556. AND aHPivHighs[0] < aHPivHighs[1]
  557. AND aLPivLows[0] < aLPivLows[1]) {

  558. tcz500 =
  559. (aHPivHighs[1] -
  560. (.5 * (aHPivHighs[1] - aLPivLows[0])));

  561. tcz618 =
  562. (aHPivHighs[0] -
  563. (.618 * (aHPivHighs[1] - aLPivLows[0])));

  564. tcz786 =
  565. (aHPivHighs[0] -
  566. (.786 * (aHPivHighs[0] - aLPivLows[0])));

  567. retrcRng = curBar - aLPivIdxs[0];
  568. aRetrcPrc = HHV(HaHigh, retrcRng);
  569. retrcPrc = aRetrcPrc[curBar];
  570. aRetrcPrcBars = HHVBars(HaHigh, retrcRng);
  571. retrcBarIdx = curBar - aRetrcPrcBars[curBar];
  572. retrcClose = aRetrcClose[retrcBarIdx];

  573. bTCZShort = (
  574. // -- Are retracement levels arranged in
  575. // tcz order?

  576. // .500 is below .786 for short setups
  577. tcz500 <= (tcz786 * (1 + .005))
  578. AND
  579. // .681 is above .786 for short setups
  580. tcz618 >= (tcz786 * (1 - .005))
  581. AND

  582. // -- Is the close <= high of tcz range
  583. // and high >= low of tcz range
  584. retrcClose <= ((1 + .01) * tcz618)
  585. AND
  586. retrcPrc >= ((1 - .01) * tcz500)
  587. );

  588. // -- Risk would be top of zone - low of signal bar
  589. //risk = 0;
  590. }

  591. // -- Show zone if present
  592. if (bTCZShort OR bTCZLong) {

  593. // -- Be prepared to see symmetry
  594. if (bTCZShort) {
  595. if (aLPivIdxs[0] > aHPivIdxs[0]) {
  596. // -- Valuable, useful symmetry information
  597. nRtrc0Pts = aHPivHighs[0] - aLPivLows[1];
  598. nRtrc0Bars = aHPivIdxs[0] - aLPivIdxs[1] + 1;
  599. nRtrc1Pts = retrcPrc - aLPivLows[0];
  600. nRtrc1Bars = retrcBarIdx - aLPivIdxs[0] + 1;
  601. } else {
  602. nRtrc0Pts = aHPivHighs[1] - aLPivLows[1];
  603. nRtrc0Bars = aHPivIdxs[1] - aLPivIdxs[1] + 1;
  604. nRtrc1Pts = aHPivHighs[0] - aLPivLows[0];
  605. nRtrc1Bars = aHPivIdxs[0] - aLPivIdxs[0] + 1;
  606. }
  607. } else { // bLongSetup
  608. if (aLPivIdxs[0] > aHPivIdxs[0]) {
  609. nRtrc0Pts = aHPivHighs[0] - aLPivLows[1];
  610. nRtrc0Bars = aHPivIdxs[0] - aLPivIdxs[1] + 1;
  611. nRtrc1Pts = retrcPrc - aLPivLows[0];
  612. nRtrc1Bars = retrcBarIdx - aLPivIdxs[0] + 1;
  613. } else {
  614. nRtrc0Pts = aHPivHighs[1] - aLPivLows[0];
  615. nRtrc0Bars = aLPivIdxs[0] - aHPivIdxs[1] + 1;
  616. nRtrc1Pts = aHPivHighs[0] - aLPivLows[0];
  617. nRtrc1Bars = aLPivIdxs[0] - aHPivIdxs[0] + 1;
  618. }
  619. }

  620. if (bShowTCZ) {
  621. Plot(
  622. LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
  623. tcz500, curBar, tcz500 , 0),
  624. "tcz500", colorPaleBlue, styleLine);
  625. Plot(
  626. LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
  627. tcz618, curBar, tcz618, 0),
  628. "tcz618", colorPaleBlue, styleLine);
  629. Plot(
  630. LineArray( IIf(bTCZLong, aHPivIdxs[0], aLPivIdxs[0]),
  631. tcz786, curBar, tcz786, 0),
  632. "tcz786", colorTurquoise, styleLine);
  633. }

  634. // -- if (bShowTCZ)
  635. }
  636. _SECTION_END();



  637. W52_High=WriteVal(HHV(H,260),1.2);
  638. W52_Low=WriteVal(LLV(L,260),1.2);




  639. _SECTION_BEGIN("Fundamental data");

  640. declara=GetFnData("LastSplitDate" );
  641. declara1=GetFnData("DividendPayDate" ); // yahoo.format


  642. //=================Trend & Signals ===============================
  643. /// Please replace "00DSEGEN" with your market index ticker and activate the codes

  644. /// Market Bull Bear

  645. Cg = Foreign("00DSEGEN", "C");
  646. Cgo= Ref(Cg,-1);

  647. //Longterm Bullish or Bearish
  648. Bullg = Cg > WMA(Cg,200);
  649. Bearg= Cg <WMA(Cg,200);

  650. //Midterm Bullish or Bearish
  651. mBullg = Cg >WMA(Cg,50);
  652. mBearg= Cg <WMA(Cg,50);

  653. //Shortterm Bullish or Bearish
  654. sBullg = Cg >WMA(Cg,15);
  655. sBearg= Cg <WMA(Cg,15);
  656. ////////////////////////////////



  657. xChange1=Cg - Ref(Cg,-1);
  658. Change1 = StrFormat("%1.2f% ",xChange1);
  659. barche1= xChange1>=0;
  660. Comche1= xChange1<0;
  661. xperchange1 = xChange1/100;
  662. perchange1 = StrFormat("%1.2f% ",xperchange1);
  663. positivechange1 = xperchange1>0;
  664. negativechange1 = xperchange1<0;




  665. //=================Trend & Signals ===============================
  666. #include <T3_Include.afl>;

  667. //Longterm Bullish or Bearish
  668. //Bull = C > T3(C,233);
  669. //Bear= C < T3(C,233);

  670. Bull = C > WMA(C,200);
  671. Bear= C <WMA(C,200);

  672. //Midterm Bullish or Bearish
  673. //mBull = C > T3(C,55);
  674. //mBear= C < T3(C,55);

  675. mBull = C >WMA(C,50);
  676. mBear= C <WMA(C,50);


  677. //Shortterm Bullish or Bearish
  678. //sBull = C > T3(C,15);
  679. //sBear= C < T3(C,15);

  680. sBull = C >WMA(C,15);
  681. sBear= C <WMA(C,15);


  682. //--------------------------------------------------------
  683. //Long-term Price Trend(LTPT)

  684. rc= C > EMA (C,50) AND C < EMA(C,200) AND EMA(C,50) < EMA(C,200);
  685. ac= C > EMA (C,50) AND C > EMA(C,200) AND EMA(C,50) < EMA(C,200);
  686. bl= C > EMA (C,50) AND C > EMA(C,200) AND EMA(C,50) > EMA(C,200);
  687. wr= C < EMA (C,50) AND C > EMA(C,200) AND EMA(C,50) > EMA(C,200);
  688. ds= C < EMA (C,50) AND C < EMA(C,200) AND EMA(C,50) > EMA(C,200);
  689. br= C < EMA (C,50) AND C < EMA(C,200) AND EMA(C,50) < EMA(C,200);

  690. //------------------------


  691. //Trend Strength


  692. _SECTION_BEGIN("JSB_Pic_DMX_3");

  693. SetBarsRequired(100000, 100000);

  694. JSB_InitLib();

  695. range=Param( "Length ", 9, 0, 500);

  696. aup = JSB_JDMX(C,range) > 0;
  697. adown = JSB_JDMX(C,range) < 0;
  698. achoppy = JSB_JDMX(C,range) < JSB_JDMXplus(C,range) AND JSB_JDMX(C,range) < JSB_JDMXminus(C,range);

  699. adxBuy = Cross(JSB_JDMXplus(C,range), JSB_JDMXminus(C,range));
  700. adxSell = Cross(JSB_JDMXminus(C,range), JSB_JDMXplus(C,range));
  701. adxBuy = ExRem(adxBuy, adxSell);
  702. adxSell = ExRem(adxSell, adxBuy);
  703. adxbuy1 = JSB_JDMXplus(C,range) > JSB_JDMXminus(C,range);
  704. adxsell1 = JSB_JDMXminus(C,range)> JSB_JDMXplus(C,range);

  705. //Plot( JSB_JDMXplus( Close, Length), "JDMXplus", colorGreen, styleLine);
  706. //Plot( JSB_JDMXminus( Close, Length), "JDMXminus", colorRed, styleLine);
  707. //Plot( JSB_JDMX( Close, Length), "JDMX", colorBlue, styleLine | styleOwnScale);
  708. _SECTION_END();



  709. _SECTION_BEGIN("Breakout Setting");
  710. Buyperiods=Param("Breakout periods",5,1,100,1,1);
  711. BuyBreakout= C>Ref(HHV(H,Buyperiods),-1);

  712. Buyperiods2=Param("2 Breakout periods",17,1,100,1,1);
  713. BuyBreakout2= Cross( C, Ref( HHV(H,Buyperiods2), -1 ) );



  714. _SECTION_END();


  715. /*

  716. // Plots a 20 period Donchian channel
  717. pds=5;
  718. exitpds=5;
  719. DonchianUpper =HHV(Ref(H,-1),pds);
  720. DonchianLower = LLV(Ref(L,-1),exitpds);
  721. //DonchianMiddle = (DonchianUpper+DonchianLower)/2;
  722. a1=H>=DonchianUpper;
  723. a2=C<=DonchianLower;

  724. // Plots a 55 period Donchian channel
  725. pds2=15;
  726. exitpds2=15;
  727. DonchianUpper2 =HHV(Ref(H,-1),pds2);
  728. DonchianLower2 = LLV(Ref(L,-1),exitpds2);
  729. d1=H>=DonchianUpper2;
  730. d2=C<=DonchianLower2;

  731. //PlotShapes( IIf( a1, shapeHollowSmallCircle, shapeNone ), 11, layer = 0, yposition = Hahigh, offset = 6);
  732. //PlotShapes( IIf( d1, shapeHollowSmallSquare, shapeNone ), colorBrightGreen, layer = 0, yposition = Hahigh, offset = -6);

  733. */



  734. //Price Volume Breakout: close greater than last close and volume at least twice as much 50-day MA
  735. HIV = C > Ref (C,-1) AND V > (MA(V,15)*2);
  736. LIV = C < Ref (C,-1) AND V < (MA(V,15)*2);

  737. //------------------------------------------------------------


  738. //Initial Buy Signal
  739. Ibuy = Cross(RSI(14), EMA(RSI(14),9));
  740. Isell = Cross(EMA(RSI(14),9), RSI(14));
  741. Ibuy = ExRem(Ibuy, ISell);
  742. Isell = ExRem(ISell, Ibuy);
  743. BlRSI = RSI(14) > EMA(RSI(14),9);
  744. BrRSI = RSI(14) < EMA(RSI(14),9);


  745. //Price Smoothing -T3
  746. TBuy = Cross (T3(C,3), T3(C,5));
  747. TSell = Cross (T3(C,5), T3(C,3));
  748. TBuy = ExRem(TBuy, TSell);
  749. TSell = ExRem(TSell, TBuy);
  750. T33 = T3(C,3) > T3(C,5);
  751. T333 = T3(C,3) < T3(C,5);

  752. //Tillson's Part (RSI Smoothing)
  753. TillsonBuy = Cross (t3(RSI(9),3), t3(RSI(9),5));
  754. TillsonSell = Cross (t3(RSI(9),5), t3(RSI(9),3));
  755. TB = t3(RSI(9),3)> t3(RSI(9),5);
  756. TS = t3(RSI(9),3)< t3(RSI(9),5);



  757. //ZerolagEMA & T-3 Crosses
  758. P = ParamField("Price field",-1);
  759. Periods = Param("Periods", 4, 2, 200, 1, 10 );
  760. EMA1=EMA(P,Periods);
  761. EMA2=EMA(EMA1,Periods);
  762. Difference=EMA1-EMA2;
  763. ZerolagEMA=EMA1+Difference;
  764. ebuy = Cross(ZerolagEma, t3(ZerolagEma,3));
  765. esell = Cross(t3(ZerolagEma,3), ZerolagEma);
  766. ebuy1 = ZerolagEma > t3(ZerolagEma,3);
  767. esell1= t3(ZerolagEma,3)>ZerolagEma;

  768. //Stochastics Part
  769. //StochBuy = Cross(StochK(9,3), StochD(9,3,3));
  770. //StochSell = Cross (StochD(9,3,3), StochK(9,3));
  771. //StBuy=StochK(9,3)>StochD(9,3,3);
  772. //StSell=StochK(9,3)<StochD(9,3,3);

  773. //Stochastics Part

  774. StochKval = StochK(10,5);
  775. StochDval = StochD(10,5,5);

  776. StochBuy = Cross(StochK(10,5), StochD(10,5,5));
  777. StochSell = Cross (StochD(10,5,5), StochK(10,5));

  778. StBuy=StochK(10,5)>StochD(10,5,5);
  779. StSell=StochK(10,5)<StochD(10,5,5);


  780. //Filter = Buy OR Sell;


  781. //Stochbuy_status= WriteIf(StochBuy, "Buy", WriteIf(StochSell, "Sell", "No Signal"));
  782. //Stoch_Col=IIf(StochBuy, colorGreen, IIf(StochSell, colorRed, colorLightGrey));
  783. //PlotShapes( IIf( StochBuy, shapeSmallCircle, shapeNone ), 7, layer = 0, yposition = 0, offset = 0);


  784. //PlotShapes(IIf(StochBuy AND StochKval<26,35,shapeNone),colorBrightGreen,layer = 0, yposition = 0, offset = -30);
  785. //PlotShapes(IIf(StochBuy AND StochKval > 26,33,shapeNone),colorPaleBlue,layer = 0, yposition = 0, offset = -30);

  786. //PlotShapes(IIf(StochSell AND StochKval>67,37,shapeNone),colorRed,layer = 0, yposition = 0, offset = 0);



複製代碼
 樓主| 發表於 10-5-7 15:25 | 顯示全部樓層
回復 2# alexwang7777


   

  1. ///////////////////////////


  2. //MACD Signal Crosses
  3. MB= Cross (MACD(), Signal());
  4. MS = Cross( Signal(), MACD());
  5. MB = ExRem(MB, MS);
  6. MS = ExRem(MS, MB);
  7. MB1= MACD() > Signal();
  8. MS1= MACD() < Signal();


  9. //30 Week New High-New Low
  10. HI2 = High > Ref(HHV(High,130),-1);
  11. LI2 = Low < Ref(LLV(Low,130),-1);
  12. HIV2=Ref(HHV(High,130),-1);
  13. LIV2=Ref(LLV(Low,130),-1);

  14. //52 Week New High-New Low
  15. HI = High > Ref(HHV(High,260),-1);
  16. LI = Low < Ref(LLV(Low,260),-1);
  17. HIV1= Ref(HHV(High,260),-1);
  18. LIV1=Ref(LLV(Low,260),-1);
  19. //HI=H>HIV1;
  20. //LI=L<LIV1;


  21. //Wad: Larry Williams Acc/Distribution Status
  22. TRH = IIf(Ref(C, -1) > H, Ref(C, -1), H);
  23. TRL = IIf(Ref(C, -1) < L, Ref(C, -1), L);
  24. ad = IIf(C > Ref(C, -1), C - TRL, IIf(C < Ref(C, -1), C - TRH, 0));
  25. WAD = Cum(ad);
  26. wu = wad > Ref(wad,-1);
  27. wd = wad < Ref(wad,-1);
  28. //wad_status= WriteIf(wu, "Rising", WriteIf(wd, "Falling", "Neutral"));


  29. //5 Year New High-New Low

  30. pdyear = Param("6-Month Back",1300,65,2600,65);
  31. pdyear1=pdyear/260;
  32. HI3 = High > Ref(HHV(High,pdyear),-1);
  33. LI3 = Low < Ref(LLV(Low,pdyear),-1);
  34. HIV3= Ref(HHV(High,pdyear),-1);
  35. LIV3=Ref(LLV(Low,pdyear),-1);
  36. //HI=H>HIV1;
  37. //LI=L<LIV1;



  38. //_SECTION_BEGIN("ZL W%R");

  39. R = ((HHV(H,14) - C) /(HHV (H,14) -LLV (L,14))) *-100;
  40. MaxGraph=10;
  41. Period= 10;
  42. EMA1= EMA(R,Period);
  43. EMA2= EMA(EMA1,5);
  44. Difference= EMA1 - EMA2;
  45. ZeroLagEMA= EMA1 + Difference;
  46. PR=100-abs(ZeroLagEMA);
  47. MoveAvg=MA(PR,5);
  48. ZBuy = Cross(PR,moveAvg) AND PR<30;
  49. ZSell = Cross(moveAvg,PR) AND PR>70;
  50. ZBuy1= PR>= MoveAvg AND PR>= Ref(PR,-1) ;
  51. ZSell1=(PR < MoveAvg) OR PR>= MoveAvg AND PR< Ref(PR,-1) ;

  52. _SECTION_END();

  53. //----------------------------------------------------------------------------------------
  54. // Find Short Term Reversals - Closing Price, Hook, Island, Key, Open-Close
  55. // and Pivot Point Reversals using automatic analysis

  56. /*Closing Price Reversals Automatic Analysis
  57. by Larry Lovrencic*/
  58. CPRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<Ref(H,-1) AND L<Ref(L,-1) AND C>Ref(C,-1);
  59. CPRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H>Ref(H,-1) AND L>Ref(L,-1) AND C<Ref(C,-1);
  60. /*Hook Reversals Automatic Analysis
  61. by Larry Lovrencic*/

  62. HRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<Ref(H,-1) AND L>Ref(L,-1);
  63. HRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H<Ref(H,-1) AND L>Ref(L,-1);
  64. /*Island Reversals Automatic Analysis
  65. by Larry Lovrencic*/

  66. IRbuy=Ref(L,-2)>Ref(H,-1) AND L>Ref(H,-1);
  67. IRsell=Ref(H,-2)<Ref(L,-1) AND H<Ref(L,-1);

  68. /*Key Reversals Automatic Analysis
  69. by Larry Lovrencic*/

  70. KRbuy=O<Ref(C,-1) AND L<Ref(L,-1) AND C>Ref(H,-1);
  71. KRsell=O>Ref(C,-1) AND H>Ref(H,-1) AND C<Ref(L,-1);

  72. /*Open/Close Reversals Automatic Analysis
  73. by Larry Lovrencic*/

  74. OCRbuy=O<(L+0.2*(H-L)) AND C>(H-0.2*(H-L)) AND H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1);
  75. OCRsell=O>(L+0.8*(H-L)) AND C<(H-0.8*(H-L)) AND H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1);
  76. /*Pivot Point Reversals Automatic Analysis
  77. by Larry Lovrencic*/

  78. PPRbuy=Ref(L,-1)<Ref(L,-2) AND Ref(L,-1)<L AND C>Ref(H,-1);
  79. PPRsell=Ref(H,-1)>Ref(H,-2) AND Ref(H,-1)>H AND C<Ref(L,-1);

  80. Buyr=Cover=CPRbuy OR HRbuy OR IRbuy OR KRbuy OR OCRbuy OR PPRbuy;
  81. Sellr=Short=CPRsell OR HRsell OR IRsell OR KRsell OR OCRsell OR PPRsell;
  82. Buyr=ExRem(Buyr,Sellr); Sellr=ExRem(Sellr,Buyr); Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short);
  83. Filter= CPRbuy OR CPRsell OR HRbuy OR HRsell OR IRbuy OR IRsell OR KRbuy OR KRsell OR OCRbuy OR OCRsell OR PPRbuy OR PPRsell;
  84. Filter=Buyr OR Sellr OR Short OR Cover;

  85. //-----------------------------------------------------------------------------



  86. //_SECTION_BEGIN("MA-T3 Setting");
  87. // Probable MA-T3 Cross-Oracle
  88. p=Param("Cross Period 1",4,1,20,1); //4
  89. MAp=T3(C,p);
  90. k=Param("Cross Period 2",5,1,20,1);//6
  91. MAk=T3(C,k);
  92. y=p*T3(C,p)-(p-1)*Ref(T3(C,p-1),-1);
  93. tClose=(p*(k-1)*T3(C,k-1)-k*(p-1)*T3(C,p-1))/(k-p);
  94. DescCrossPrediction=Cross(tClose,C);
  95. AscCrossPrediction=Cross(C,tClose);
  96. ExpectMAcross=DescCrossPrediction OR AscCrossPrediction;
  97. Confirmed=Cross(MAk,MAp) OR Cross(MAp,MAk);
  98. UR=2*Highest(ROC(C,1));LR=2*Lowest(ROC(C,1));
  99. Ucoeff=1+UR/100;Lcoeff=1+LR/100;
  100. Filter=tClose<Lcoeff*C OR tClose>Ucoeff*C;
  101. AddColumn(MAp,"MAp");
  102. AddColumn(MAk,"MAk");
  103. //Plot(C,"",7*Filter+1,64); //No. '64' designates price chart as candle
  104. //Plot(MAp,"",7,1); //Red Line - The No. '4' designates the red color & No. '1'
  105. //Plot(MAk,"",2,1); //Green Line - - The No. '4' designates the red color & No. '1'
  106. bars=BarsSince(Cross(MAp,MAk) OR Cross(MAk,MAp));
  107. expect=NOT(Filter);

  108. orBuy=AscCrossPrediction;
  109. orSell=DescCrossPrediction;
  110. orBuy1=(C>tClose);
  111. orSell1=(tClose>C);
  112. _SECTION_END();



  113. //////////////////////////////////////////////////////////////////////////////

  114. //AddColumn(ROC(V,1), "ROC Volume", 1.2, IIf(ROC(V,1) > 0, colorGreen, colorRed));

  115. //ROC(V,1);
  116. //IIf(ROC(V,1) > 0, colorGreen, colorRed);
  117. Vol=(ROC(V,1));
  118. CP=(ROC(C,1));


  119. _SECTION_BEGIN("Bull vs Bear Volume");

  120. C1 = Ref(C, -1);
  121. uc = C > C1; dc = C <= C1;
  122. ud = C > O; dd = C <= O;

  123. green = 1; blue = 2; yellow = 3; red = 4; white = 5;
  124. VType = IIf(ud,
  125. IIf(uc, green, yellow),
  126. IIf(dd,
  127. IIf(dc, red, blue), white));




  128. /* green volume: up-day and up-close*/
  129. gv = IIf(VType == green, V, 0);
  130. /* yellow volume: up-day but down-close */
  131. yv = IIf(VType == yellow, V, 0);
  132. /* red volume: down-day and down-close */
  133. rv = IIf(VType == red, V, 0);
  134. /* blue volume: down-day but up-close */
  135. bv = IIf(VType == blue, V, 0);

  136. uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
  137. dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */

  138. /* create moving average period parameters */
  139. VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);
  140. ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);

  141. /* create triple exponential moving avearges of separate up and down volume
  142. moving averages */
  143. MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
  144. MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
  145. MAtv = TEMA(V, VolPer );//total volume

  146. /* Switch for Horizontal lines indicating current level of positive and
  147. negative volume for ease in comparing to past highs/lows - toggle via
  148. parmameter window */
  149. OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
  150. CompareBullVolume = Param("Show Bull Level", 1, 0, 1, 1);
  151. if(CompareBullvolume AND !OscillatorOnly){
  152. //Plot(SelectedValue(MAuv), "", colorGreen, styleLine);
  153. }

  154. CompareBearVolume = Param("Show Bear Level", 1, 0, 1, 1);
  155. if(CompareBearVolume AND !OscillatorOnly){
  156. //Plot(SelectedValue(MAdv), "", colorRed, styleLine);
  157. }

  158. /* Volume Segment Switches - toggle via parameter window */
  159. bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);
  160. bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);
  161. totalvolume = Param("Show Total Volume", 1, 0, 1, 1);

  162. /* plot volume lines and histograms if toggled on: */
  163. bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);
  164. if(bearToFront AND !OscillatorOnly){
  165. //Plot(MAdv, "", colorRed, styleHistogram|styleNoLabel);
  166. }
  167. if(bullvolume AND !OscillatorOnly){
  168. //Plot(MAuv, "Average Bull Volume", colorGreen, styleHistogram|styleNoLabel);
  169. }
  170. if(bearvolume AND !OscillatorOnly){
  171. //Plot(MAdv, "Average Bear Volume", colorRed, styleHistogram|styleNoLabel);
  172. }
  173. if(totalVolume AND !OscillatorOnly){
  174. //Plot(MAtv, "Total Volume", colorWhite, styleHistogram|styleNoLabel);
  175. //Plot(MAtv, "", colorWhite, styleLine);
  176. }
  177. if(bullvolume AND !OscillatorOnly){
  178. //Plot(MAuv, "", colorGreen, styleLine);
  179. }
  180. if(bearvolume AND !OscillatorOnly){
  181. //Plot(MAdv, "", colorRed, styleLine);
  182. }

  183. /* better visibility of zero line: */
  184. //Plot(0, "", colorBlue, 1);

  185. /* Rise/Fall Convergence variables: */
  186. Converge = (TEMA(MAuv - MAdv, ConvPer));
  187. Converge1 = Ref(Converge, -1);
  188. ConvergeUp = Converge > Converge1;
  189. ConvergeOver = Converge > 0;
  190. rising = ConvergeUp AND ConvergeOver;
  191. falling = !ConvergeUp AND ConvergeOver;

  192. /* Rise/Fall Convergence Oscillator Switch - toggle via parameter window -
  193. (provides a better view of resulting combination of battling bull/bear volume
  194. forces) */
  195. convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
  196. if(convergenceOscillator OR OscillatorOnly){
  197. //Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet,1|styleLeftAxisScale|styleNoLabel|styleThick);
  198. //Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);
  199. }

  200. /********************************************************
  201. Convergence Rise/Fall Shadows:

  202. (provides a more easily visible display of rising and falling bull/bear
  203. volume convergence) - toggle via parameter window

  204. -posiitive Volume exceeding negative Volume: Light shadow
  205. -negative volume exceeding positive volume: dark shadow
  206. -if you use standard gray background - best shadows are:
  207. -my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));
  208. -best substitute? using AB color constants?
  209. -light: colorpalegreen; dark: colorRose;?
  210. -(depends on your color scheme - customize to your tastes)
  211. **********************************************************/

  212. /* uncomment if you use my custom color greys: */
  213. riseFallColor = IIf(rising, 14,15); //my custom shadow greys

  214. /* comment out if you use my custom color gray shadows: */
  215. /* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */

  216. /* Rise/Fall Convergence Plot Switch - toggle via parameter window */
  217. riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);
  218. if(riseFallShadows){
  219. //Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,styleHistogram|styleArea|styleOwnScale|styleNoLabel);
  220. }
  221. _SECTION_END();

  222. _SECTION_BEGIN("Haiken-Ashi");
  223. //THE QUEST FOR RELIABLE CROSSOVERS

  224. //LISTING 1
  225. function ZeroLagTEMA( array, period )
  226. {
  227. TMA1 = TEMA( array, period );
  228. TMA2 = TEMA( TMA1, period );
  229. Diff = TMA1 - TMA2;
  230. return TMA1 + Diff ;
  231. }
  232. haClose = ( haClose + haOpen + haHigh + haLow )/4;
  233. period = Param("Avg. TEMA period", 55, 1, 100 );
  234. ZLHa = ZeroLagTEMA( haClose, period );
  235. ZLTyp = ZeroLagTEMA( Avg, period );
  236. //Plot( ZLHa, "ZLTema(Ha,"+period+")", colorRed );
  237. //Plot( ZLTyp, "ZLTema(Typ,"+period+")", colorGreen );
  238. TMBuy = Cross( ZLTyp, ZLHa );
  239. TMSell = Cross( ZLHa, ZLTyp );
  240. TMBuy1= ZLTyp> ZLHa ;
  241. TMSell1=ZLHa> ZLTyp ;

  242. _SECTION_END();

  243. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  244. //Volume Price Analysis AFL - VPA Version 1.0
  245. //AFL by Karthikmarar. Detailed explanation available at www.vpanalysis.blogspot.com
  246. //====================================================================================
  247. _SECTION_BEGIN("Volume Price Analysis by Mr.Karthik ");
  248. SetChartOptions(0,chartShowArrows|chartShowDates);
  249. //=======================================================================================
  250. DTL=Param("Linear regression period",60,10,100,10);
  251. wbf=Param("WRB factor",1.5,1.3,2.5,.1);
  252. nbf=Param("NRB factor",0.7,0.3,0.9,0.1);
  253. TL=LinRegSlope(MA(C, DTL),2);
  254. Vlp=Param("Volume lookback period",30,20,300,10);
  255. Vrg=MA(V,Vlp);
  256. St = StDev(Vrg,Vlp);
  257. Vp3 = Vrg + 3*st;
  258. Vp2 = Vrg + 2*st;;
  259. Vp1 = Vrg + 1*st;;
  260. Vn1 = Vrg -1*st;
  261. Vn2 = Vrg -2*st;
  262. rg=(H-L);
  263. arg=Wilders(rg,30);
  264. wrb=rg>(wbf*arg);
  265. nrb=rg<(nbf*arg);
  266. Vl=V<Ref(V,-1) AND V<Ref(V,-2);
  267. upbar=C>Ref(C,-1);
  268. dnbar=C<Ref(C,-1);
  269. Vh=V>Ref(V,-1) AND Ref(V,-1)>Ref(V,-2);
  270. Cloc=C-L;
  271. x=rg/Cloc;
  272. x1=IIf(Cloc=0,arg,x);
  273. Vb=V>Vrg OR V>Ref(V,-1);
  274. ucls=x1<2;
  275. dcls=x1>2;
  276. mcls=x1<2.2 AND x1>1.8 ;
  277. Vlcls=x1>4;
  278. Vhcls=x1<1.35;
  279. j=MA(C,5);
  280. TLL=LinRegSlope(j,40) ;
  281. Tlm=LinRegSlope(j,15) ;
  282. tls=LinRegSlope(j,5);
  283. mp=(H+L)/2;
  284. _SECTION_END();
  285. //==========================================================================================
  286. utbar=wrb AND dcls AND tls>0 ;
  287. utcond1=Ref(utbar,-1) AND dnbar ;
  288. utcond2=Ref(utbar,-1) AND dnbar AND V>Ref(V,-1);
  289. utcond3=utbar AND V> 2*Vrg;
  290. trbar=Ref(V,-1)>Vrg AND Ref(upbar,-1) AND Ref(wrb,-1) AND dnbar AND dcls AND wrb AND tll>0 AND H==HHV(H,10);
  291. Hutbar=Ref(upbar,-1) AND Ref(V,-1)>1.5*Vrg AND dnbar AND dcls AND NOT wrb AND NOT utbar;
  292. Hutcond=Ref(Hutbar,-1) AND dnbar AND dcls AND NOT utbar;
  293. tcbar=Ref(upbar,-1) AND H==HHV(H,5)AND dnbar AND (dcls OR mcls) AND V>vrg AND NOT wrb AND NOT Hutbar ;
  294. Scond1=(utcond1 OR utcond2 OR utcond3) ;
  295. Scond2=Ref(scond1,-1)==0;
  296. scond=scond1 AND scond2;
  297. stdn0= tll<0 AND V>Ref(V,-1) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls) AND tls<0 AND tlm<0;
  298. stdn= V>Ref(V,-1) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls) AND tls<0 AND tlm<0;
  299. stdn1= tll<0 AND V>(vrg*1.5) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls)AND tls<0 AND tlm<0;
  300. stdn2=tls<0 AND Ref(V,-1)<Vrg AND upbar AND vhcls AND V>Vrg;
  301. bycond1= stdn OR stdn1;
  302. bycond= upbar AND Ref(bycond1,-1);
  303. stvol= L==LLV(L,5) AND (ucls OR mcls) AND V>1.5*Vrg AND tll<0;
  304. ndbar=upbar AND nrb AND Vl AND dcls ;
  305. nsbar=dnbar AND nrb AND Vl AND dcls ;
  306. nbbar= C>Ref(C,-1) AND Vl AND nrb AND x1<2;
  307. nbbar= IIf(C>Ref(C,-1) AND V<Ref(V,-1) AND V<Ref(V,-2) AND x1<1.1,1,0);
  308. lvtbar= vl AND L<Ref(L,-1) AND ucls;
  309. lvtbar1= V<Vrg AND L<Ref(L,-1) AND ucls AND tll>0 AND tlm>0 AND wrb;
  310. lvtbar2= Ref(Lvtbar,-1) AND upbar AND ucls;
  311. dbar= V>2*Vrg AND dcls AND upbar AND tls>0 AND tlm>0 AND NOT Scond1 AND NOT utbar;
  312. eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND V>Ref(V,-1);
  313. eftupfl=Ref(eftup,-1) AND (utbar OR utcond1 OR utcond2 OR utcond3);
  314. eftdn=H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1) AND C<=((H-L)*0.25+L) AND rg>arg AND V>Ref(V,-1);
  315. _SECTION_END();

  316. _SECTION_BEGIN("Commentary");
  317. Vpc= utbar OR utcond1 OR utcond2 OR utcond3 OR stdn0 OR stdn1 OR stdn2 OR stdn OR lvtbar1 OR Lvtbar OR Lvtbar2 OR Hutbar OR Hutcond OR ndbar OR stvol OR tcbar;

  318. if( Status("action") == actionCommentary )
  319. (
  320. printf ( "=========================" +"\n"));
  321. printf ( "VOLUME PRICE ANALYSIS" +"\n");
  322. //printf ( "www.vpanalysis.blogspot.com" +"\n");
  323. printf ( "=========================" +"\n");
  324. printf ( Name() + " - " +Interval(2) + " - " + Date() +" - " +"\n"+"High-"+H+"\n"+"Low-"+L+"\n"+"Open-"+O+"\n"+
  325. "Close-"+C+"\n"+ "Volume= "+ WriteVal(V)+"\n");
  326. WriteIf(Vpc,"=======================","");
  327. WriteIf(Vpc,"VOLUME ANALYSIS COMMENTARY:\n","");

  328. WriteIf(utbar , "Up-thrusts are designed to catch stops and to mislead as many traders as possible.
  329. They are normally seen after there has been weakness in the background. The market makers know that the
  330. market is weak, so the price is marked up to catch stops, encourage traders to go long in a weak market,
  331. AND panic traders that are already Short into covering their very good position.","")+
  332. WriteIf(utcond3,"This upthrust bar is at high volume.This is a sure sign of weakness. One may even seriously
  333. consider ending the Longs AND be ready to reverse","")+WriteIf(utbar OR utcond3," Also note that A wide spread
  334. down-bar that appears immediately after any up-thrust, tends to confirm the weakness (the market makers are
  335. locking in traders into poor positions).
  336. With the appearance of an upthrust you should
  337. certainly be paying attention to your trade AND your stops. On many upthrusts you will find that the market will
  338. 'test' almost immediately.","")+WriteIf(utcond1 , "A wide spread down bar following a Upthrust Bar.
  339. This confirms weakness. The Smart Money is locking in Traders into poor positions","");
  340. WriteIf(utcond2 , "Also here the volume is high( Above Average).This is a sure sign of weakness. The Smart Money is
  341. locking in Traders into poor positions","")+WriteIf(stdn, "Strength Bar. The stock has been in a down Trend. An upbar
  342. with higher Volume closing near the High is a sign of strength returning. The downtrend is likely to reverse soon. ","")+
  343. WriteIf(stdn1,"Here the volume is very much above average. This makes this indication more stronger. ","")+
  344. WriteIf(bycond,"The previous bar saw strength coming back. This upbar confirms strength. ","")+
  345. WriteIf(Hutbar," A pseudo Upthrust. This normally appears after an Up Bar with above average volume. This looks like an upthrust bar
  346. closing down near the Low. But the Volume is normally Lower than average. this is a sign of weakness.If the Volume is High then weakness
  347. increases. Smart Money is trying to trap the retailers into bad position. ","")+
  348. WriteIf(Hutcond, "A downbar after a pseudo Upthrust Confirms weakness. If the volume is above average the weakness is increased. ","")+
  349. WriteIf(Lvtbar2,"The previous bar was a successful Test of supply. The current bar is a upbar with higher volume. This confirms strength","")+
  350. WriteIf(dbar,"A wide range, high volume bar in a up trend closing down is an indication the Distribution is in progress. The smart money
  351. is Selling the stock to the late Comers rushing to Buy the stock NOT to be Left Out Of a Bullish move. ","")+
  352. WriteIf(Lvtbar2,"The previous bar was a successful Test of supply. The current bar is a upbar with higher volume. This confirms strength","")+
  353. WriteIf(tcbar,"The stock has been moving up on high volume. The current bar is a Downbar with high volume. Indicates weakness and probably end of the up move","")+
  354. WriteIf(eftup,"Effort to Rise bar. This normally found in the beginning of a Markup Phase and is bullish sign.These may be found at the top of an Upmove as the Smart money makes a
  355. last effort to move the price to the maximum","")+
  356. WriteIf(eftdn,"Effort to Fall bar. This normally found in the beginning of a Markdown phase.","")+

  357. WriteIf(nsbar,"No Supply. A no supply bar indicates supply has been removed and the Smart money can markup the price. It is better to wait for confirmation","")+
  358. WriteIf(stvol,"Stopping Volume. This will be an downbar during a bearish period closing towards the Top accompanied by High volume.
  359. A stopping Volume normally indicates that smart money is absorbing the supply which is a Indication that they are Bullishon the MArket.
  360. Hence we Can expect a reversal in the down trend. ","")+
  361. WriteIf(ndbar, "No Demand
  362. Brief Description:
  363. Any up bar which closes in the middle OR Low, especially if the Volume has fallen off,
  364. is a potential sign of weakness.

  365. Things to Look Out for:
  366. if the market is still strong, you will normally see signs of strength in the next few bars,
  367. which will most probably show itself as a:
  368. * Down bar with a narrow spread, closing in the middle OR High.
  369. * Down bar on Low Volume.","");
  370. _SECTION_END();

  371. //=====================================================================
  372. //background stock name (works only on Amibroker version 5.00 onwards.
  373. //=====================================================================

  374. _SECTION_BEGIN("Mabiuts-Mr.Karthik");
  375. mabBuy=EMA(C,13)>EMA(EMA(C,13),9) AND Cross (C,Peak(C,5,1));
  376. mabSell=Cross (EMA(EMA(C,13),9),EMA(C,13));
  377. mabBuy1= EMA(C,13)>EMA(EMA(C,13),9) AND C>Peak(C,2,1);
  378. mabSell1 =EMA(C,13)>EMA(EMA(C,13),9) AND C<Peak(C,2,1);

  379. _SECTION_END();

  380. //------------------------------------------------------------------------------
  381. //WEEKLY TREND

  382. weeklyprice=C;
  383. Weekly=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);

  384. W6ema = EMA(weekly,30);// 6 weeks * 5 days per week - default 30
  385. W13ema = EMA(weekly,65);// 13 weeks * 5 days per week - default 65
  386. MACDSignal = EMA((W6ema - W13ema),25);// 5 weeks * 5 days per week default 25

  387. ROCMACD = MACDSignal - Ref(MACDSignal,-25);//ROC of MACD Signal default 25

  388. //Cond1 - "V" bottom, start of climb
  389. Cond1 = IIf(ROCMACD > Ref(ROCMACD,-5) AND Ref(ROCMACD,-5) <= Ref(ROCMACD,-10),1,0);
  390. //Cond2 - "V" top, start of drop
  391. Cond2 = IIf(ROCMACD < Ref(ROCMACD,-5) AND Ref(ROCMACD,-5) >= Ref(ROCMACD,-10),1,0);
  392. //cond3 - Steady up trend
  393. Cond3 = IIf(ROCMACD> Ref(ROCMACD,-5) AND Ref(ROCMACD,-5) >= Ref(ROCMACD,-10),1,0);
  394. //Cond4 - Steady down trend
  395. Cond4 = IIf(ROCMACD < Ref(ROCMACD,-5) AND Ref(ROCMACD,-5) <= Ref(ROCMACD,-10),1,0);
  396. //Cond5 - no change - flat
  397. Cond5 = IIf(ROCMACD = Ref(ROCMACD,-5) ,1,0);
  398. /////////////////////////////////////////////////////////////
  399. _SECTION_END();

  400. _SECTION_BEGIN("Weekly_trend-mrtq13");

  401. //#include <T3.AFL>;

  402. Prd1=Param("Weekly_Period1",3,1,200,1);
  403. Prd2=Param("Weekly_Period2",5,1,200,1);

  404. TimeFrameSet (inWeekly);

  405. TM = T3 ( Close , Prd1 ) ;
  406. TM2 = T3 ( Close , Prd2 ) ;
  407. UTM = IIf(Close>TM AND Close<TM2,8,
  408. IIf(Close>TM AND Close>TM2,5,
  409. IIf(Close<TM AND Close>TM2,13,
  410. IIf(Close<TM AND Close<TM2,4,2))));

  411. //up=Close>TM AND Close<TM2;
  412. wup=Close>TM AND Close>TM2;
  413. wflat=Close<TM AND Close>TM2;
  414. wdown=Close<TM AND Close<TM2;
  415. TimeFrameRestore();

  416. _SECTION_END();



  417. //Pivot Cal

  418. Pp = ((High +Low + Close) / 3);
  419. R1 = (Pp * 2) - Low;
  420. R2 = (Pp + High) - Low;
  421. R3 = R1 +(High-Low);

  422. S1 = (Pp * 2) - High;
  423. S2 = (Pp - High) + Low;
  424. S3 = S1 - (High-Low);


  425. _SECTION_BEGIN("Spiker_Shadow");

  426. C1 = Ref(C, -1);
  427. uc = C > C1; dc = C <= C1;
  428. ud = C > O; dd = C <= O;

  429. green = 1; blue = 2; yellow = 3; red = 4; white = 5;
  430. VType = IIf(ud,
  431. IIf(uc, green, yellow),
  432. IIf(dd,
  433. IIf(dc, red, blue), white));

  434. /* green volume: up-day and up-close*/
  435. gv = IIf(VType == green, V, 0);
  436. /* yellow volume: up-day but down-close */
  437. yv = IIf(VType == yellow, V, 0);
  438. /* red volume: down-day and down-close */
  439. rv = IIf(VType == red, V, 0);
  440. /* blue volume: down-day but up-close */
  441. bv = IIf(VType == blue, V, 0);


  442. uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
  443. dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */


  444. VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);//12
  445. ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);//6


  446. MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
  447. MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
  448. MAtv = TEMA(V, VolPer );//total volume


  449. Converge = (TEMA(MAuv - MAdv, ConvPer));
  450. Converge1 = Ref(Converge, -1);
  451. ConvergeUp = Converge > Converge1;
  452. ConvergeOver = Converge > 0;
  453. rising = ConvergeUp AND ConvergeOver;
  454. falling = !ConvergeUp AND ConvergeOver;

  455. _SECTION_END();


  456. _SECTION_BEGIN("VSA by Mr.Karthik");

  457. Pp1=Param("NumberOfDays",30,1,200,1);
  458. Pp2=Param("VolOfDays",15,1,200,1);

  459. numDays = Pp1;
  460. dwWideSpread = 1.8;
  461. dwNarrowSpread = 0.8;
  462. dwSpreadMiddle = 0.5;
  463. dwHighClose = 0.7;
  464. dwLowClose = 0.3;

  465. volNumDays = Pp2;
  466. dwUltraHighVol = 2;
  467. dwVeryHighVol = 1.75; // was 1.8
  468. dwHighVol = 1.75; // was 1.8
  469. dwmoderateVol = 1.10; // was 1.8
  470. dwLowVol = 0.75; // was 0.8
  471. ////////////////////////////////////////////////////////////////////////////////////
  472. //
  473. // Classify each bar...
  474. //
  475. ////////////////////////////////////////////////////////////////////////////////////


  476. upBar = C > Ref(C,-1);
  477. downBar = C < Ref(C,-1);
  478. spread = H-L;
  479. avgRange = Sum(spread, numDays) / numDays;
  480. wideRange = spread >= (dwWideSpread * avgRange);
  481. narrowRange = spread <= (dwNarrowSpread * avgRange);
  482. testHighClose = L + (spread * dwHighClose);
  483. testLowClose = L + (spread * dwLowClose);
  484. testCloseMiddle = L + (spread * dwSpreadMiddle);

  485. upClose = C > testHighClose;
  486. downClose = C < testLowClose;
  487. middleClose = C >= testLowClose AND C <= testHighClose;

  488. avgVolume = EMA(V, volNumDays);

  489. highVolume = V > (avgVolume * dwHighVol);
  490. moderateVol= V > (avgVolume * dwmoderateVol);
  491. veryHighVolume = V > (avgVolume * dwVeryHighVol);
  492. ultraHighVolume = V > (avgVolume * dwUltraHighVol);
  493. LowVolume = V < (avgVolume * dwLowVol);


  494. ////////////////////////////////////////////////////////////////////////////////////
  495. //
  496. // direction and title
  497. //
  498. ////////////////////////////////////////////////////////////////////////////////////



  499. ////////////////////////////////////////////////////////////////////////////////////
  500. //
  501. // Basic patterns...
  502. //
  503. ////////////////////////////////////////////////////////////////////////////////////

  504. upThrustBar = downClose AND H > Ref(H,-1) AND (C == L) AND downClose AND (NOT narrowRange);
  505. noDemandBar = narrowRange AND LowVolume AND upBar AND (NOT upClose);
  506. //noDemandBar = narrowRange AND LowVolume AND upBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));
  507. noSupplyBar = narrowRange AND LowVolume AND downBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));
  508. absorption = Ref(downbar, -1) AND Ref(highVolume, -1) AND upBar;
  509. support = Ref(downBar,-1) AND (NOT Ref(downClose,-1)) AND Ref(highVolume,-1) AND upBar;
  510. stoppingVolume = Ref(downBar,-1) AND Ref(highVolume,-1) AND C > testCloseMiddle AND (NOT downBar);
  511. bullishsign=moderateVol+UpThrustBar;//OR moderateVol+upBar;
  512. //rallyEnd = (Ref(highVolume,-1) AND Ref(upBar,-1) AND wideRange AND downBar) OR
  513. // (narrowRange AND highVolume AND H > Ref(HHV(H, 250), -1));


  514. ////////////////////////////////////////////////////////////////////////////////////
  515. //
  516. // Strength and Weakness
  517. //
  518. ////////////////////////////////////////////////////////////////////////////////////

  519. weakness = upThrustBar OR noDemandBar OR
  520. (narrowRange AND (H > Ref(H,-1)) AND highVolume) OR
  521. (Ref(highVolume,-1) AND Ref(upBar,-1) AND downBar AND (H < Ref(H,-1)));

  522. _SECTION_END();


  523. _SECTION_BEGIN("Resistance");

  524. supres=ParamToggle("Sup_Res","No|Yes",1);
  525. if(supres)
  526. {


  527. Prd1=Param("Res_Period1",2,0,200,1);

  528. test = TEMA ( High , Prd1 ) ;

  529. PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
  530. PKV0 = ValueWhen(PK,haHigh,0);//PeakValue0
  531. PKV1 = ValueWhen(PK,haHigh,1);//PeakValue1
  532. PKV2 = ValueWhen(PK,haHigh,2);//PeakValue2

  533. MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak

  534. MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
  535. MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
  536. SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
  537. Plot(SD, "Resist1", colorDarkOliveGreen,ParamStyle("ResStyle1",styleLine|styleNoTitle,maskAll));

  538. MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
  539. MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
  540. SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
  541. Plot(SD2, "Resist2", colorDarkOliveGreen,ParamStyle("ResStyle2",styleLine|styleNoTitle,maskAll));


  542. MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
  543. MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
  544. SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
  545. Plot(SD3, "Resist3", colorDarkOliveGreen,ParamStyle("ResStyle3",styleLine|styleNoTitle,maskAll));


  546. MPKV4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,4); //MajorPeakValue
  547. MPKD4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),4); //MajorPeakDate
  548. SD4 = IIf(DateNum() < LastValue(MPKD4,lastmode = True ), Null, LastValue(MPKV4,Lastmode = True));//SelectedDate
  549. Plot(SD4, "Resist4", colorDarkOliveGreen,ParamStyle("ResStyle4",styleLine|styleNoTitle,maskAll));



  550. MPKV5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,5); //MajorPeakValue
  551. MPKD5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),5); //MajorPeakDate
  552. SD5 = IIf(DateNum() < LastValue(MPKD5,lastmode = True ), Null, LastValue(MPKV5,Lastmode = True));//SelectedDate
  553. Plot(SD5, "Resist5", colorDarkOliveGreen,ParamStyle("ResStyle5",styleLine|styleNoTitle,maskAll));


  554. MPKV6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,6); //MajorPeakValue
  555. MPKD6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),6); //MajorPeakDate
  556. SD6 = IIf(DateNum() < LastValue(MPKD6,lastmode = True ), Null, LastValue(MPKV6,Lastmode = True));//SelectedDate
  557. Plot(SD6, "Resist6", colorDarkOliveGreen ,ParamStyle("ResStyle6",styleLine|styleNoTitle,maskAll));




  558. _SECTION_END();


  559. _SECTION_BEGIN("Support");
  560. //SP=L > Ref(L,-1) AND Ref(L,1) < L;//Peak

  561. Prd2=Param("Sup_Period1",2,0,200,1);

  562. test2 = TEMA ( Low , Prd2 ) ;

  563. SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
  564. SPV0 = ValueWhen(SP,haLow,0);//PeakValue0
  565. SPV1 = ValueWhen(SP,haLow,1);//PeakValue1
  566. SPV2 = ValueWhen(SP,haLow,2);//PeakValue2

  567. //PKV5 = ValueWhen(PK,haHigh,5);//PeakValue5
  568. //PKV6 = ValueWhen(PK,haHigh,6);//PeakValue6

  569. MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak

  570. MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
  571. MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
  572. SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
  573. Plot(SD,"Support1", colorPlum,ParamStyle("SupportLine1",styleLine|styleNoTitle,maskAll));



  574. MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
  575. MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
  576. SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
  577. Plot(SD2,"Support2", colorPlum,ParamStyle("SupportLine2",styleLine|styleNoTitle,maskAll));



  578. MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
  579. MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
  580. SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
  581. Plot(SD3,"Support3", colorPlum,ParamStyle("SupportLine3",styleLine|styleNoTitle,maskAll));


  582. MSPV4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,4);
  583. MSPD4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),4);
  584. SD4 = IIf(DateNum() < LastValue(MSPD4,lastmode = True ), Null, LastValue(MSPV4,Lastmode = True));
  585. Plot(SD4,"Support4", colorPlum,ParamStyle("SupportLine4",styleLine|styleNoTitle,maskAll));


  586. MSPV5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,5);
  587. MSPD5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),5);
  588. SD5 = IIf(DateNum() < LastValue(MSPD5,lastmode = True ), Null, LastValue(MSPV5,Lastmode = True));
  589. Plot(SD5,"Support5", colorPlum,ParamStyle("SupportLine5",styleLine|styleNoTitle,maskAll));


  590. MSPV6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,6);
  591. MSPD6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),6);
  592. SD6 = IIf(DateNum() < LastValue(MSPD6,lastmode = True ), Null, LastValue(MSPV6,Lastmode = True));
  593. Plot(SD6,"Support6", colorPlum,ParamStyle("SupportLine6",styleLine|stylehidden|styleNoTitle,maskAll));

  594. }

  595. _SECTION_END();




  596. _SECTION_BEGIN("Pivot Box");

  597. Hi=Param("High_Period",7,1,50,1);
  598. Lo=Param("Low_Period",7,1,50,1);
  599. A1=ExRemSpan(Ref(High,-2)==HHV(High,Hi),3);
  600. A2=ExRemSpan(Ref(Low,-2)==LLV(Low,Lo),3);
  601. A3=Cross(A1,0.9);
  602. A4=Cross(A2,0.9);
  603. TOP=Ref(haHigh,-BarsSince(A3));
  604. YY1=TOP;
  605. bot=Ref(haLow,-BarsSince(A4));
  606. XX1=bot;
  607. /////////////////

  608. _SECTION_BEGIN("Beta Adjusted Trailing Stops-P.Kaufman& Bullkowski ");

  609. dif=Ref(High,0)-Ref(Low,0);
  610. dif1=Ref(High,-1)-Ref(Low,-1);
  611. dif2=Ref(High,-2)-Ref(Low,-2);
  612. dif3=Ref(High,-3)-Ref(Low,-3);
  613. dif4=Ref(High,-4)-Ref(Low,-4);
  614. dif5=Ref(High,-5)-Ref(Low,-5);
  615. dif6=Ref(High,-6)-Ref(Low,-6);
  616. dif7=Ref(High,-7)-Ref(Low,-7);
  617. dif8=Ref(High,-8)-Ref(Low,-8);
  618. dif9=Ref(High,-9)-Ref(Low,-9);
  619. dif10=Ref(High,-10)-Ref(Low,-10);
  620. dif11=Ref(High,-11)-Ref(Low,-11);
  621. dif12=Ref(High,-12)-Ref(Low,-12);
  622. dif13=Ref(High,-13)-Ref(Low,-13);
  623. dif14=Ref(High,-14)-Ref(Low,-14);
  624. dif15=Ref(High,-15)-Ref(Low,-15);
  625. dif16=Ref(High,-16)-Ref(Low,-16);
  626. dif17=Ref(High,-17)-Ref(Low,-17);
  627. dif18=Ref(High,-18)-Ref(Low,-18);
  628. dif19=Ref(High,-19)-Ref(Low,-19);
  629. dif20=Ref(High,-20)-Ref(Low,-20);
  630. dif21=Ref(High,-21)-Ref(Low,-21);

  631. Sumdif=(dif+dif1+dif2+dif3+dif4+dif5+dif6+dif7+dif8+dif9+dif10+dif11+dif12+dif13+dif14+dif15+dif16+dif17+dif18+dif19+dif20+dif21)/22;


  632. mp = Param("Multiplier",2,0.25,5,0.25);
  633. Sumdifml=(Sumdif*1);
  634. Sumdifml2=(Sumdif*1.5);
  635. Sumdifml3=(Sumdif*mp);

  636. Betastops=HHV(C,22) - Sumdifml;
  637. Betastops2=HHV(C,22) - Sumdifml2;
  638. Betastops3=HHV(C,22) - Sumdifml3;

  639. //Plot(Betastops3, "BATS", ParamColor( "Color2", colorGold ),ParamStyle("Style2",styleThick,maskAll));


  640. _SECTION_END();

  641. // 33 bar high low
  642. HIVg=Ref(HHV(High,33),1);
  643. LIVg=Ref(LLV(Low,33),1);
  644. Hchg=(C-HIVg)/HIVg*100;
  645. Lchg=(C-LIVg)/LIVg*100;
  646. Echg=(HIVg-C)/C*100;
  647. _SECTION_END();

  648. //x=Foreign("00DSEGEN","C");
  649. //Cor=Correlation(C,x,14);

  650. //Plot(Cor,"correlation index",colorWhite,styleLine);
  651. //Plot(RelStrength("00DSEGEN",1),"strength",colorRed,styleLine|styleOwnScale);

  652. _SECTION_END();


  653. // Trend Detection

  654. function Rise( Pd, perd, Pl, perl )
  655. {
  656. MAD = DEMA(Pd,perd);
  657. MAL = LinearReg(Pl,perl);
  658. CondR = ROC(MAD,1)>0 AND ROC(MAL,1)>0;
  659. CondF = ROC(MAD,1)<0 AND ROC(MAL,1)<0;
  660. R[0] = C[0]>(H[0]+L[0])/2;

  661. for(i=1;i<BarCount;i++)
  662. {
  663. if( CondR[i] )
  664. {
  665. R[i] = 1;
  666. }
  667. else
  668. {
  669. if( CondF[i] )
  670. {
  671. R[i] = 0;
  672. }
  673. else
  674. {
  675. R[i] = R[i-1];
  676. }
  677. }
  678. }
  679. return R;
  680. }

  681. PrD = C;
  682. PrL = H/2+L/2;
  683. PrdD = PrdL = PrdM = Param("Prd",12,2,40,1);

  684. permax = Max(prdd,prdl);

  685. Rs = IIf( BarIndex()<permax, 0, Rise(PrD, PrdD, PrL, PrdL) );
  686. Fs = IIf( BarIndex()<permax, 0, 1-Rs );

  687. Confirm = MA(C,prdm);

  688. function DirBar( dr, df )
  689. {
  690. B[0] = 0;

  691. for(i=1;i<BarCount;i++)
  692. {
  693. if( dr[i-1] && df[i] )
  694. {
  695. B[i] = 1;
  696. }
  697. else
  698. {
  699. if( df[i-1] && dr[i] )
  700. {
  701. B[i] = 1;
  702. }
  703. else
  704. {
  705. B[i] = B[i-1] + 1;
  706. }
  707. }
  708. }
  709. return B;
  710. }

  711. Bs = DirBar( Rs, Fs );
  712. Direction = ROC(Confirm,1) > 0 AND ROC(Confirm,5) > 0;
  713. Downward = ROC(Confirm,1) < 0 AND ROC(Confirm,5) < 0;

  714. Select = Rs AND Ref(Fs,-1);
  715. Caution = Fs AND Ref(Rs,-1);

  716. _SECTION_END();

  717. Chg=Ref(C,-1);



  718. Title = EncodeColor(colorYellow)+ Title = Name() + " " + EncodeColor(2) + Date() +EncodeColor(11)+ " ~SW~ " + EncodeColor(colorWhite) + "{{INTERVAL}} " +
  719. EncodeColor(55)+ " Open: "+ EncodeColor(colorWhite)+ WriteVal(O,format=1.2) +
  720. EncodeColor(55)+ " High: "+ EncodeColor(colorWhite) + WriteVal(H,format=1.2) +
  721. EncodeColor(55)+ " Low: "+ EncodeColor(colorWhite)+ WriteVal(L,format=1.2) +
  722. EncodeColor(55)+ " Close: "+ WriteIf(C> Chg,EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(C,format=1.2)+
  723. EncodeColor(55)+ " Change: "+ WriteIf(C> Chg,EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(ROC(C,1),format=1.2)+ "%"+

  724. EncodeColor(55)+ " Volume: "+ EncodeColor(colorWhite)+ WriteVal(V,1)



  725. +"\n"+EncodeColor(colorPink)+"-----------------------------------------"
  726. +"\n"+EncodeColor(colorOrange)+"The Foundation v 13.00 Int"
  727. +"\n"+EncodeColor(colorLightOrange)+"by SouthWind "

  728. +"\n"+EncodeColor(colorPink)+"-----------------------------------------"

  729. +"\n"+EncodeColor(colorWhite)+"G.Index: "+ WriteIf(Cg>Cgo,EncodeColor(08),EncodeColor(04))+WriteVal(Cg,format=1.2)+WriteIf(positivechange1, EncodeColor(colorBrightGreen),"")+WriteIf(negativechange1,EncodeColor(colorRed), "")+" ( "+WriteIf(barche1,"\\c08"+Change1,"")+WriteIf(barche1,"\\c08 ","")+WriteIf(Comche1,"\\c04"+Change1,"")+ WriteIf(Comche1,"\\c04 ","")+""+") "

  730. +"\n"+EncodeColor(colorWhite)+"Market Trend: "+ WriteIf(sBullg,EncodeColor(colorBrightGreen)+"UP",WriteIf(sBearg,EncodeColor(colorRed)+"Dwn",EncodeColor(colorYellow)+"Flat"))
  731. +EncodeColor(colorWhite) + " | "
  732. + WriteIf(mBullg,EncodeColor(colorBrightGreen)+"UP",WriteIf(mBearg,EncodeColor(colorRed)+"Dwn",EncodeColor(colorYellow)+"Flat"))
  733. +EncodeColor(colorWhite) + " | "
  734. + WriteIf(Bullg,EncodeColor(colorBrightGreen)+"UP",WriteIf(Bearg,EncodeColor(colorRed)+"Dwn",EncodeColor(colorYellow)+"Flat"))

  735. +"\n"+EncodeColor(colorPink)+"----------------------------------------- "


  736. +"\n"+EncodeColor(41)+"WeeklyTrend: " +WriteIf(wup,EncodeColor(colorBrightGreen)+"Up ", WriteIf(wdown,EncodeColor(colorRed)+"Down", WriteIf(wflat,EncodeColor(colorWhite)+"Flat ","")))
  737. +EncodeColor(colorWhite)

  738. //+"\n"+EncodeColor(25)+"WeeklyTrend:" + WriteIf(up,EncodeColor(colorBrightGreen)+"UP",WriteIf(down,EncodeColor(colorRed)+"Down",WriteIf(flat,EncodeColor(colorYellow)+"Flat","")))


  739. +"\n"+EncodeColor(26)+"S.TermTrend: " + WriteIf(sBull,EncodeColor(colorBrightGreen)+"UP",WriteIf(sBear,EncodeColor(colorRed)+"Down","Neutral"))
  740. +EncodeColor(colorWhite) + " | "
  741. //+WriteIf(tls>0,EncodeColor(colorLime)+"UP",EncodeColor(colorRed)+"Down")

  742. +WriteIf(Rs,EncodeColor(colorBrightGreen)+"UP",WriteIf(Fs,EncodeColor(colorRed)+"Down","Neutral"))



  743. +"\n"+EncodeColor(26)+"M.TermTrend: " + WriteIf(mBull,EncodeColor(colorBrightGreen)+"UP",WriteIf(mBear,EncodeColor(colorRed)+"Down","Neutral"))
  744. +EncodeColor(colorWhite) + " | "
  745. +WriteIf(tlm>0,EncodeColor(colorLime)+"UP",EncodeColor(colorRed)+"Down")

  746. +"\n"+EncodeColor(26)+"L.TermTrend: " + WriteIf(Bull,EncodeColor(colorBrightGreen)+"UP",WriteIf(Bear,EncodeColor(colorRed)+"Down","Neutral"))
  747. +EncodeColor(colorWhite) + " | "
  748. +WriteIf(tll>0,EncodeColor(colorLime)+"Up",EncodeColor(colorRed)+"Down")

  749. +"\n"+EncodeColor(colorPink)+"---------------------------------------- "
  750. +"\n"+EncodeColor(47)+"Signal(IBuy): " + WriteIf(Ibuy,EncodeColor(colorBrightGreen)+"BuyWarning",WriteIf(Isell,EncodeColor(colorRed)+"SellWarning",WriteIf(BlRSI,EncodeColor(colorBrightGreen)+"BullishZone",WriteIf(BrRSI,EncodeColor(colorRed)+"BearishZone","Neutral"))))
  751. +"\n"+EncodeColor(47)+"Signal(T3) : " + WriteIf(TBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(TSell,EncodeColor(colorRed)+"Sell",WriteIf(T33,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(T333,EncodeColor(colorRed)+"Bearish","Neutral"))))
  752. +"\n"+EncodeColor(47)+"Signal(ZLW) : " + WriteIf(ZBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(ZSell,EncodeColor(colorRed)+"Sell",WriteIf(ZBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(ZSell1,EncodeColor(colorRed)+"Bearish","Neutral"))))
  753. +"\n"+EncodeColor(47)+"Signal(Mab) : " + WriteIf(mabBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(mabSell,EncodeColor(colorRed)+"Sell",WriteIf(mabBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(mabSell1,EncodeColor(47)+"Neutral",EncodeColor(colorRed)+"Bearish"))))
  754. +"\n"+EncodeColor(47)+"Signal(TMA) : " + WriteIf(TMBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(TMSell,EncodeColor(colorRed)+"Sell",WriteIf(TMBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(TMSell1,EncodeColor(colorRed)+"Bearish","Neutral"))))
  755. +"\n"+EncodeColor(47)+"Signal(T3-RSI) : " + WriteIf(TillsonBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(TillsonSell,EncodeColor(colorRed)+"Sell", WriteIf(TB,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(TS,EncodeColor(colorRed)+"Bearish","Neutral"))))
  756. +"\n"+EncodeColor(47)+"Signal(ADX) : " + WriteIf(adxBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(adxSell,EncodeColor(colorRed)+"Sell",WriteIf(adxBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(adxSell1,EncodeColor(colorRed)+"Bearish","Neutral"))))
  757. +"\n"+EncodeColor(47)+"Signal(MACD) : " + WriteIf(MB,EncodeColor(colorBrightGreen)+"Buy",WriteIf(MS,EncodeColor(colorRed)+"Sell",WriteIf(MB1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(MS1,EncodeColor(colorRed)+"Bearish","Neutral"))))
  758. +"\n"+EncodeColor(47)+"Signal(Stoch) : " + WriteIf(StochBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(StochSell,EncodeColor(colorRed)+"Sell",WriteIf(StBuy,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(StSell,EncodeColor(colorRed)+"Bearish","Neutral"))))
  759. +"\n"+EncodeColor(47)+"Signal(TM) : "+ WriteIf(orBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(orSell,EncodeColor(colorRed)+"Sell",WriteIf(orBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(orSell1,EncodeColor(colorRed)+"Bearish","Neutral"))))


  760. //+"\n"+EncodeColor(47)+"Signal(Drava) : " + WriteIf(Buyrule,EncodeColor(colorBrightGreen)+"Buy",WriteIf(Sellrule,EncodeColor(colorRed)+"Sell",WriteIf(Buyrule1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(Sellrule1,EncodeColor(colorRed)+"Bearish","Neutral"))))
  761. +"\n"+EncodeColor(47)+"Signal(P5/15):" + WriteIf(Buybreakout,EncodeColor(colorBrightGreen)+"BreakOut1",WriteIf(Buybreakout2>Buybreakout,EncodeColor(colorBrightGreen)+"BreakOut2","Neutral"))
  762. +"\n"+EncodeColor(47)+"Signal(B):"+WriteIf(C>YY1,EncodeColor(colorBrightGreen)+"BreakOut",WriteIf(C<XX1,EncodeColor(colorRed)+"BreakDown","Neutral"))

  763. +"\n"+EncodeColor(colorPink)+"----------------------------------------"
  764. +"\n"+EncodeColor(07)+"Volume: "+WriteIf(V>Vp2,EncodeColor(colorLime)+"Very High",WriteIf(V>Vp1,EncodeColor(colorLime)+" High",WriteIf(V>Vrg,EncodeColor(colorLime)+"Above Average",
  765. WriteIf(V<Vrg AND V>Vn1,EncodeColor(colorRed)+"Less than Average",WriteIf(V<Vn1,EncodeColor(colorRed)+"Low","")))))

  766. +"\n"+EncodeColor(colorYellow)+"Spread: "+WriteIf(rg >(arg*2),EncodeColor(colorLime)+" Wide",WriteIf(rg>arg,EncodeColor(colorLime)+" Above Average",EncodeColor(colorRed)+" Narrow"))

  767. +"\n"+(EncodeColor(colorYellow)+"Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid",
  768. WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))

  769. +"\n"+EncodeColor(colorYellow) + "Zone : " +WriteIf(rising , EncodeColor(colorBrightGreen) + "Accumulation",WriteIf(falling , EncodeColor(colorCustom12) + "Distirbution",EncodeColor(colorAqua) + "Flat")) + " "
  770. +"\n"+
  771. EncodeColor(colorYellow) + "Status : " +
  772. WriteIf(Weakness , EncodeColor(colorRed) + "Weak",
  773. WriteIf(stoppingVolume , EncodeColor(colorCustom12) + "StoppingVol",
  774. WriteIf(noSupplyBar , EncodeColor(colorLightOrange) + "NoSupply",
  775. WriteIf(support , EncodeColor(colorLightBlue) + "SupportVol",
  776. WriteIf(noDemandBar , EncodeColor(colorPink) + "NoDemand",
  777. WriteIf(absorption, EncodeColor(colorSkyblue) + "Absorption",
  778. WriteIf(upThrustBar, EncodeColor(colorBlue) + "Upthrust",
  779. WriteIf(bullishsign, EncodeColor(colorPaleGreen) + "STRONG",
  780. EncodeColor(colorTan) + "Neutral")))))))) + " "
  781. +"\n"+EncodeColor(colorPink)+"----------------------------------------"
  782. +"\n"+EncodeColor(49)+"KeyReversal : " + WriteIf(Buyr,EncodeColor(colorBrightGreen)+"ReverseUP",WriteIf(Sellr,EncodeColor(colorRed)+"ReverseDown","Flat"))
  783. +"\n"+EncodeColor(49) +"Phaze(LTPT) : " + WriteIf(rc,EncodeColor(26)+"Recovery",WriteIf(ac,EncodeColor(colorGreen)+"Accumulation",WriteIf(bl,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(wr,EncodeColor(colorOrange)+"Warning",WriteIf(ds,EncodeColor(colorRed)+"Distribution",WriteIf(br,EncodeColor(colorRed)+"Bearish","Neutral"))))))
  784. //+"\n"+EncodeColor(49)+"T.Strength(ADX): "+StrFormat("%1.2f",ADX(per)) + WriteIf( PDI(per)>MDI(per),EncodeColor(colorBrightGreen)+ " UP",EncodeColor(colorRed)+" Down")
  785. +"\n"+EncodeColor(49)+"PV BreakOut : " + WriteIf(HIV,EncodeColor(colorBrightGreen)+"Positive",WriteIf(LIV,EncodeColor(colorRed)+"Negative","Neutral"))

  786. +"\n"+EncodeColor(49)+"A/D : " + WriteIf(wu,EncodeColor(colorBrightGreen)+"Accumulation",WriteIf(wd,EncodeColor(colorRed)+"Distribution","Neutral"))



  787. +"\n"+ EncodeColor(49) +"Vol Change:" + WriteIf(Vol>0,EncodeColor(08),EncodeColor(04)) +WriteVal(Vol,format=1.2)+ "%"
  788. //+"\n"+EncodeColor(49)+"Vol: " + WriteIf(Buy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(Sell,EncodeColor(colorRed)+"Sell",""))
  789. +WriteIf(MAuv>MAdv,EncodeColor(colorBrightGreen)+" : BullVol",WriteIf(MAuv<MAdv,EncodeColor(colorRed)+" : BearVol",": Neutral"))+WriteIf(rising,EncodeColor(colorBrightGreen)+" Rising",WriteIf(falling,EncodeColor(colorRed)+" Falling"," Flat"))

  790. +"\n"+ EncodeColor(49) +"RSI: " +WriteIf(RSI(15)>30 AND RSI(15)<70,EncodeColor(08),WriteIf(RSI(15)<30 ,EncodeColor(07),EncodeColor(04))) + WriteVal(RSI(15),format=1.2)

  791. +WriteIf(RSI(15)>30 AND RSI(15)<70," Range"+EncodeColor(08),WriteIf(RSI(15)<30 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(04)))


  792. //+(EncodeColor(colorYellow)+" Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid",
  793. //WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))

  794. //+"\n"+EncodeColor(49)+"26 WHL: " +HIV2+" : "+LIV2+"-"+ WriteIf(H>HIV2,EncodeColor(colorBrightGreen)+"High",WriteIf(L<LIV2,EncodeColor(colorRed)+"Low","Neutral"))
  795. +"\n"+EncodeColor(49)+"52 WHL: " + HIV1+" : "+LIV1+" - "+WriteIf(H>HIV1,EncodeColor(colorBrightGreen)+"High",WriteIf(L<LIV1,EncodeColor(colorRed)+"Low","Neutral"))
  796. +"\n"+EncodeColor(49)+"HL:"+"("+pdyear1+" Yerars"+"):"+ HIV3+" :"+LIV3+"-"+WriteIf(H>HIV3,EncodeColor(colorBrightGreen)+"High",WriteIf(L<LIV3,EncodeColor(colorRed)+"Low","Neutral"))





  797. +"\n"+EncodeColor(colorRose)+"----------------------------------------"
  798. +"\n"+EncodeColor(02)+"BATS : "+ WriteIf(Betastops>C,EncodeColor(colorLightOrange)+"Exit-1","")+WriteIf(Betastops2>C,EncodeColor(colorOrange)+"| Exit-2","")+WriteIf(Betastops3>C,EncodeColor(colorRed)+" | Exit-3","")


  799. //+"\n"+EncodeColor(colorRose)+"---------------------------"
  800. //+"\n"+EncodeColor(02)+"PivotPoint: "+StrFormat("%1.2f",Pp)
  801. //+"\n"+EncodeColor(colorCustom11)+"R1 "+StrFormat("%1.2f",R1)+" R2 "+StrFormat("%1.2f",R2)+" R3 "+StrFormat("%1.2f",R3)
  802. //+"\n"+EncodeColor(11)+"S1 "+StrFormat("%1.2f",S1)+" S2 "+StrFormat("%1.2f",S2)+" S3 "+StrFormat("%1.2f",S3)
  803. +"\n"+EncodeColor(colorRose)+"----------------------------------------"
  804. +"\n"+EncodeColor(11)+"FV : " //+ absFace_Value
  805. +EncodeColor(44)+" Lot : " //+ absMarket_Lot
  806. +EncodeColor(07)+" CataGory: " //+ absMarket_Category
  807. +"\n"+EncodeColor(05)+"Electronic Share : "//+ absElectronic_Share


  808. //+"\n"+EncodeColor(4)+"Last Declaration : "+ WriteVal(declara, formatDateTime )

  809. +"\n"+EncodeColor(4)+"Last Declaration : " //+ WriteVal(declara1, formatDateTime )//declara1// formatDateTime

  810. +"\n"+EncodeColor(colorRose)+"-------------------------------------------------"

  811. +"\n"+EncodeColor(11)+"R1 "+StrFormat("%1.2f",R1)+" R2 "+StrFormat("%1.2f",R2)+" R3 "+StrFormat("%1.2f",R3)
  812. +"\n"+EncodeColor(02)+"PivotPoint: "+StrFormat("%1.2f",Pp)
  813. +"\n"+EncodeColor(colorCustom11)+"S1 "+StrFormat("%1.2f",S1)+" S2 "+StrFormat("%1.2f",S2)+" S3 "+StrFormat("%1.2f",S3)
  814. +"\n"+EncodeColor(colorRose)+"===========================";

  815. _SECTION_END();


  816. _SECTION_BEGIN("Name");
  817. GfxSetOverlayMode(1);
  818. GfxSelectFont("Tahoma", Status("pxheight")/8 );
  819. GfxSetTextAlign( 6 );// center alignment
  820. GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
  821. GfxSetBkMode(0); // transparent
  822. GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
  823. GfxSelectFont("Tahoma", Status("pxheight")/18 );
  824. GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/4 );

  825. GfxSelectFont("Tahoma", Status("pxheight")/18 );
  826. GfxSelectFont("Tahoma", Status("pxheight")/36 );
  827. GfxTextOut( "chartistsbd.net", Status("pxwidth")/2, Status("pxheight")/3 );
  828. _SECTION_END();


  829. _SECTION_BEGIN("Graphics");
  830. GrpPrm=Param("Graphic Space",2,-5,10);
  831. GraphXSpace=GrpPrm;
  832. _SECTION_END();
複製代碼
 樓主| 發表於 10-5-7 15:30 | 顯示全部樓層
請將圖2及圖3程式碼!合併起來!
大家用用看吧!


對了再問大家一個問題!全都賺有個"歐元1006"我該如何設到AMIBROKER DDE DATABASE
有誰有設成功!我設了老半天都跑不出來....
感謝!
發表於 10-5-7 17:22 | 顯示全部樓層
好長啊~~~~好長的程式碼...
請問一下,這個如果用去TS 是直接可以用,還是還要改呢??
我愛紅茶 該用戶已被刪除
發表於 10-5-7 19:48 | 顯示全部樓層

這個畫面屌@@~要怎樣使用啊?
發表於 10-5-7 22:22 | 顯示全部樓層
這... 不能執行吧!?有缺檔案..

詳見 http://www.marketcalls.in/2010/0 ... 0-int-afl-code.html
發表於 10-5-7 23:04 | 顯示全部樓層
程式碼真的好長...按滑鼠中間的捲輪(?是這樣稱呼嗎)捲了半天還沒捲完
 樓主| 發表於 10-5-7 23:19 | 顯示全部樓層
回復 8# sdnian

謝謝sdnian指教

這個程式碼我試過可以用!
也感謝sdnian提供更好的方法!
這網站可以得到該程式的完整安裝方式!
記的沒錯的話有3樣 東西要安裝!

當初覺得po上來,怕大家看不懂!所以就直接貼AFL CODE!
發表於 10-5-8 00:03 | 顯示全部樓層
回復 10# alexwang7777


不好意思, 我不是指您貼的程式不能執行.    "記的沒錯的話有3樣 東西要安裝!"  我指的是這個, 要另外複製幾個檔案到 AmiBroker 的適當位置.
發表於 10-5-8 01:46 | 顯示全部樓層
這摸長..我要暈了
K棒數只要多一點, 89成會跑不動, 太多裸碼
我愛紅茶 該用戶已被刪除
發表於 10-5-8 13:02 | 顯示全部樓層
感覺很好用
但是很吃資源
我現在打開再RUN~會頓頓的
 樓主| 發表於 10-5-10 10:08 | 顯示全部樓層
回復 13# 我愛紅茶


    之前我用單核心CPU run 就會頓頓的!(k棒會頓頓的,十字游標也會延遲)
    因此我放在雙核心CPU run 就蠻順的!

    以上建議供你參考喔!
 樓主| 發表於 10-5-10 10:10 | 顯示全部樓層
回復 6# BG


    謝謝BG大....
    我已經設定好了...可以RUN了!
發表於 11-8-12 00:21 | 顯示全部樓層
請問 大大
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
是指新增一個變數 r1 , 初始直5,最小2,最大200,每次增減1,嗎?

請問什麼情況才會增減呢?
謝謝~
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-5-16 13:57

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook