Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0 || zf < -0.06) { return(null); } if (dsh.Ref(Info.OF, 1) < -0.03) { return(null); } if (dsh.Ref(Info.ZF, 1) > 0) { return(null); } int iSigDateIndex = -1; int nUpCount = 0; int nUStopCount = 0; int nDStopCount = 0; bool bMeetRealUp = false; bool bHasUpShadowTooHight = false; bool bHasDownShadowTooLow = false; float otherMaxVol = float.MinValue; float otherMaxZF = float.MinValue; float otherMaxC = 0; float otherMaxH = 0; float sigDateVol = 0; float sigZF = 0; float minDownShadow = float.MaxValue; float maxUpShadow = float.MinValue; float totalUp = 0; float totalDown = 0; float otherMinZF = float.MaxValue; float otherMaxCO = float.MinValue; bool bMeetTradeSigAllready = false; int nNotRealCount = 0; for (int i = 1; i < 8; ++i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curLf = dsh.Ref(Info.LF, i); var curZf = dsh.Ref(Info.ZF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); var coRate = dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, i + 1); if (curZf > 0 && curZf < 0.095 && coRate > 0.05 && vol > dsh.MA(Info.V, 5, i + 1) && dsh.HH(Info.CO, 30, i) == i) { for (int j = i + 1; j < i + 6; ++j) { if (dsh.Ref(Info.V, j) > vol && dsh.Ref(Info.C, j) < dsh.Ref(Info.O, j)) { return(null); } } if (dsh.AccZF(8, i + 1) < -0.1) { return(null); } if (dsh.AccZF(3, i + 1) > 0.095) { return(null); } int iMaxVolIndex = dsh.HH(Info.V, 20, i); if (dsh.Ref(Info.C, iMaxVolIndex) > dsh.Ref(Info.O, iMaxVolIndex)) { iSigDateIndex = i; sigDateVol = vol; sigZF = curZf; break; } } if (curOf < -0.04) { return(null); } if (curZf > 0 && dsh.IsReal(i)) { nUpCount++; } if (!dsh.IsReal(i)) { ++nNotRealCount; } if (curZf > 0.095) { nUStopCount++; } else if (curZf < -0.095) { nDStopCount++; } else if (curZf > 0.012) { bMeetRealUp = true; } if (curZf < -0.03 && dsh.Ref(Info.ZF, i - 1) > 0) { bMeetTradeSigAllready = true; } float upShadow = dsh.UpShadow(i); float downShadow = dsh.DownShadow(i); if (upShadow > maxUpShadow) { maxUpShadow = upShadow; } if (downShadow < minDownShadow) { minDownShadow = downShadow; } if (curZf > 0) { totalUp += curZf; } else { totalDown += curZf; } otherMaxVol = Math.Max(vol, otherMaxVol); otherMaxZF = Math.Max(otherMaxZF, curZf); otherMaxC = Math.Max(dsh.Ref(Info.C, i), otherMaxC); otherMaxH = Math.Max(dsh.Ref(Info.H, i), otherMaxH); otherMinZF = Math.Min(otherMinZF, curZf); otherMaxCO = Math.Max(otherMaxCO, dsh.Ref(Info.CO, i)); } if (iSigDateIndex == -1) { return(null); } sigInfo = dsh.Date(iSigDateIndex).ToString(); if (otherMinZF > 0.02) { return(null); } if (nNotRealCount > 1) { return(null); } if (totalDown + totalUp < -0.01) { return(null); } if (maxUpShadow > 0.03) { bHasUpShadowTooHight = true; } if (minDownShadow < -0.03) { bHasDownShadowTooLow = true; } if (nUpCount < 2) { return(null); } if (otherMaxH < dsh.Ref(Info.H, iSigDateIndex)) { return(null); } if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp) { return(null); } float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex); if (maxUpF < 0.015 /* || maxUpF > 0.04*/) { return(null); } if (dsh.Ref(Info.C) < dsh.Ref(Info.L, iSigDateIndex)) { return(null); } if (bHasUpShadowTooHight || bHasDownShadowTooLow) { return(null); } if ( dsh.Ref(Info.ZF, 2) < 0.005 && dsh.Ref(Info.ZF, 3) < 0.005) { return(null); } if (sigDateVol < otherMaxVol * 1.2) { return(null); } if (sigDateVol > otherMaxVol * 2) { return(null); } if (otherMaxZF + zf > 0) { return(null); } if (otherMaxZF + zf < -0.02) { return(null); } if (dsh.Ref(Info.LF) < -0.06) { return(null); } var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1); if (delta > -0.01) { return(null); } if (!selectBySZ(dsh)) { return(null); } var ret = new Dictionary <String, String>(); ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")] = ""; ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")] = ""; return(ret); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0 || zf < -0.06) { return(null); } if (!dsh.IsReal()) { return(null); } if (dsh.Ref(Info.OF, 1) < -0.03) { return(null); } int iSigDateIndex = -1; int nUpCount = 0; int nUStopCount = 0; int nDStopCount = 0; bool bMeetTradeSigAllready = false; bool bMeetRealUp = false; float sigDateVol = 0; float otherMaxVol = 0; bool bHasUpShadowTooHight = false; bool bHasDownShadowTooLow = false; float otherMaxZF = 0; float otherMaxC = 0; float otherMaxH = 0; float sumOfSigDateZF = 0; float totalUp = 0; float totalDown = 0; for (int i = 1; i < 8; ++i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curZf = dsh.Ref(Info.ZF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); if (curOf < 0.03 && curZf > 0.03 && curZf < 0.095 && dsh.Ref(Info.OF, i + 1) < 0.03 && dsh.Ref(Info.ZF, i + 1) > 0.03) { for (int j = i + 2; j < i + 5; j++) { if (dsh.Ref(Info.ZF, j) < 0) { break; } if (dsh.Ref(Info.ZF, j) > 0.05) { return(null); } } if (dsh.AccZF(8, i + 2) < -0.15) { return(null); } float preVol = dsh.Ref(Info.V, i + 1); float chkVol = Math.Max(vol, preVol); for (int j = i + 2; j < i + 6; ++j) { if (dsh.Ref(Info.V, j) > chkVol * 2) { return(null); } } sumOfSigDateZF = curZf + dsh.Ref(Info.ZF, i + 1); if (sumOfSigDateZF > 0.1) { iSigDateIndex = i; sigDateVol = Math.Max(dsh.Ref(Info.V, i + 1), vol); break; } } otherMaxVol = Math.Max(vol, otherMaxVol); if (curZf > 0 && dsh.IsReal(i)) { nUpCount++; } if (curZf > 0.095) { nUStopCount++; } else if (curZf < -0.095) { nDStopCount++; } if (curZf < -0.03) { bMeetTradeSigAllready = true; } else if (curZf > 0.012) { bMeetRealUp = true; } if (curZf > 0) { totalUp += curZf; } else { totalDown += curZf; } if (dsh.UpShadow(i) > 0.03) { bHasUpShadowTooHight = true; } if (dsh.DownShadow(i) < -0.03) { bHasDownShadowTooLow = true; } otherMaxZF = Math.Max(otherMaxZF, curZf); otherMaxC = Math.Max(dsh.Ref(Info.C, i), otherMaxC); otherMaxH = Math.Max(dsh.Ref(Info.H, i), otherMaxH); } if (iSigDateIndex == -1) { return(null); } // sigInfo = dsh.Date(iSigDateIndex).ToString(); if (dsh.Ref(Info.C) < dsh.Ref(Info.L, iSigDateIndex)) { return(null); } if (dsh.Ref(Info.ZF) + Math.Min(dsh.Ref(Info.ZF, iSigDateIndex), dsh.Ref(Info.ZF, iSigDateIndex + 1)) < -0.01) { return(null); } if (totalDown + totalUp < -0.01) { return(null); } if (nUpCount < 2) { return(null); } if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp) { return(null); } float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex); if (maxUpF < 0.015 /* || maxUpF > 0.04*/) { return(null); } if (sigDateVol < otherMaxVol * 1.2) { return(null); } if (sigDateVol > otherMaxVol * 2) { return(null); } if (otherMaxZF + zf > 0) { return(null); } sigInfo = (otherMaxZF + zf).ToString("F4"); if (dsh.Ref(Info.LF) < -0.06) { return(null); } if (bHasUpShadowTooHight || bHasDownShadowTooLow) { return(null); } // if (dsh.Ref(Info.OF) < -0.02) // { // return null; // } if ( dsh.Ref(Info.ZF, 2) < 0.005 && dsh.Ref(Info.ZF, 3) < 0.005) { return(null); } // if (dsh.Ref(Info.ZF, iSigDateIndex-1) < 0 && // dsh.Ref(Info.ZF, iSigDateIndex - 2) < 0) // { // return null; // } if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex)) { return(null); } if (dsh.Ref(Info.C, iSigDateIndex + 1) < dsh.Ref(Info.O, iSigDateIndex + 1)) { return(null); } var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1); if (delta > -0.01) { return(null); } var szZF = dsh.SZRef(Info.ZF); if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03) { return(null); } if (!selectBySZ(dsh)) { return(null); } var ret = new Dictionary <String, String>(); ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")] = ""; ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")] = ""; ret[String.Format("maxZF/{0}", otherMaxZF + zf > -0.01 ? "1" : "0")] = ""; ret[String.Format("prezf/{0}", dsh.Ref(Info.ZF, 1) > 0 ? "1" : "0")] = ""; return(ret); }
public virtual Dictionary <String, String> selectFor(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0.095 || zf < -0.095) { return(null); } if (zf < 0.02) { return(null); } if (dsh.IsLikeSTStop()) { return(null); } if (dsh.Ref(Info.ZF, 2) < 0.03) { return(null); } if (dsh.Ref(Info.ZF, 1) > -0.01) { return(null); } if (dsh.Ref(Info.ZF, 3) > 0) { return(null); } if (dsh.AccZF(3) < 0.05) { return(null); } if (dsh.AccZF(3, 3) > 0) { return(null); } if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 2) { return(null); } for (int i = 0; i < 4; ++i) { if (dsh.DownShadow(i) < -0.04) { return(null); } if ((dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, i + 1)) < 0.005) { return(null); } if (dsh.Ref(Info.OF, i) > 0.02 && dsh.Ref(Info.ZF, i) < -0.02) { return(null); } } var hhCO = dsh.HH(Info.CO, 8); if (dsh.Ref(Info.ZF, hhCO) > 0) { return(null); } if (dsh.Ref(Info.ZF, dsh.LL(Info.ZF, 8)) < -0.095) { return(null); } if (dsh.HH(Info.V, 6) == 0) { return(null); } return(EmptyRateItemButSel); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0.095 || zf < -0.095) { return(null); } if (zf < 0.01) { return(null); } if (dsh.IsLikeSTStop()) { return(null); } if (dsh.DownShadow() < -0.04) { return(null); } if ((dsh.Ref(Info.C, 1) - dsh.Ref(Info.L, 3)) / dsh.Ref(Info.C, 1) > 0) { return(null); } if (dsh.Ref(Info.HL, 1) > dsh.Ref(Info.HL, 2) * 2) { return(null); } if (dsh.Ref(Info.HL, 2) > dsh.Ref(Info.HL, 1) * 2) { return(null); } if (dsh.Ref(Info.C) < dsh.Ref(Info.O, 1)) { return(null); } if ((dsh.Ref(Info.C, 1) - dsh.Ref(Info.O, 5)) / dsh.Ref(Info.C, 1) > 0.01) { return(null); } if (dsh.Ref(Info.L) < dsh.Ref(Info.L, 1) && dsh.Ref(Info.H) > dsh.Ref(Info.H, 1)) { return(null); } if (dsh.AccZF(2, 1) < -0.1) { return(null); } if (dsh.AccZF(3) > 0.02) { return(null); } if (dsh.AccZF(2) < -0.04) { return(null); } var accZF6 = dsh.AccZF(6); if (accZF6 > 0.08) { return(null); } int nDownCount = 2; if (dsh.EveryDown(1) != nDownCount) { return(null); } if (dsh.Ref(Info.ZF, nDownCount + 1) < 0.01) { return(null); } if (dsh.Ref(Info.ZF, dsh.HH(Info.ZF, 6)) < 0.03) { return(null); } if (dsh.Ref(Info.ZF, nDownCount + 2) > -0.01) { return(null); } if (dsh.Ref(Info.ZF, nDownCount + 3) < 0.01) { return(null); } var upV = dsh.Acc(Info.V, 6, 0, 1); var downV = dsh.Acc(Info.V, 6, 0, -1); if (upV > downV * 1.5) { return(null); } for (int i = 0; i <= 5; ++i) { var curOF = dsh.Ref(Info.OF, i); var curZF = dsh.Ref(Info.ZF, i); if (!dsh.IsReal(i)) { return(null); } if (curZF > 0.095 || curZF < -0.095) { return(null); } if (curOF > 0.02 && curZF < 0) { return(null); } if (curOF < -0.02 && curZF < 0) { return(null); } if (dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, i + 1) < 0.006) { return(null); } } var szZF = dsh.SZRef(Info.ZF); if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03) { return(null); } if (!selectBySZ(dsh)) { return(null); } return(EmptyRateItemButSel); }
Dictionary <String, String> selectFor(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo, int iIndex, out bool isTwoDownMode) { isTwoDownMode = false; var zf = dsh.Ref(Info.ZF, iIndex); if (zf > -0.05 || zf < -0.095) { return(null); } if (!dsh.IsRealDown()) { return(null); } if (zf < -0.09 && dsh.Ref(Info.ZF, iIndex + 1) < -0.08) { return(null); } int iSigDateIndex = -1; int nUStopCount = 0; int nDStopCount = 0; float sigDateVol = 0; float sigZF = 0; int nMeetMinus5PercentCount = 0; int iFirstMinus5PercentIndex = -1; int iTwoMinus5PercentIndex = -1; int nPlus5PercentCount = 0; bool bDanger = false; for (int i = iIndex + 1; i < SearchDayCount; ++i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curZf = dsh.Ref(Info.ZF, i); var curLf = dsh.Ref(Info.LF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); if (dsh.IsUpStopEveryDay(EveryUpCount, i)) { iSigDateIndex = i; sigDateVol = vol; sigZF = curZf; break; } if (curHf > 0.095 && curZf < 0) { bDanger = true; } } for (int i = iSigDateIndex + EveryUpCount; i < iSigDateIndex + EveryUpCount + SearchDayCount; i++) { if (dsh.IsUpStopEveryDay(EveryUpCount, i)) { return(null); } } for (int i = iSigDateIndex - 1; i > iIndex; --i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curZf = dsh.Ref(Info.ZF, i); var curLf = dsh.Ref(Info.LF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); if (curZf > 0.095) { nUStopCount++; } else if (curZf < -0.095) { nDStopCount++; } if (curZf < -0.05) { if (iFirstMinus5PercentIndex == -1) { iFirstMinus5PercentIndex = i; } ++nMeetMinus5PercentCount; if (nMeetMinus5PercentCount == 2) { iTwoMinus5PercentIndex = i; } } if (curZf > 0.06) { ++nPlus5PercentCount; } } if (iSigDateIndex == -1) { return(null); } int orgThreshold = 3; int nThreshold = orgThreshold; if (iTwoMinus5PercentIndex != -1) { bool bHasUp = false; for (int i = iIndex + 1; i < iTwoMinus5PercentIndex; i++) { if (dsh.Ref(Info.ZF, i) > 0.01) { bHasUp = true; break; } } if (!bHasUp) { nThreshold++; } } if (nThreshold == orgThreshold) { if (dsh.Ref(Info.ZF, 1 + iIndex) < 0 && dsh.Ref(Info.ZF, 2 + iIndex) < 0) { nThreshold++; } } // if (nDStopCount > 1) // { // return null; // } nThreshold += nPlus5PercentCount; nThreshold += nDStopCount; if (dsh.UpShadow(1) > 0.04 && dsh.Ref(Info.ZF, 1) < 0 && dsh.Ref(Info.ZF) > -0.08) { ++nThreshold; } // nThreshold += (int)Math.Ceiling(nPlus5PercentCount*0.5); if (nMeetMinus5PercentCount < nThreshold - 1) { return(null); } if (nMeetMinus5PercentCount > nThreshold - 1) { if (dsh.Ref(Info.ZF, iIndex + 1) > 0) { return(null); } } var preZF = dsh.Ref(Info.ZF, iIndex + 1); if (preZF > 0.02) { isTwoDownMode = true; return(null); } if (dsh.AccZF(3, iIndex + 1) > 0.02 && dsh.EveryUp(iIndex + 1) >= 3) { isTwoDownMode = true; } if (bDanger) { return(null); } // if (dsh.Ref(Info.C, iIndex) > dsh.Ref(Info.O, iIndex)) // { // return null; // } var ret = new Dictionary <String, String>(); ret[String.Format("Threshold/{0}", nThreshold)] = ""; ret[String.Format("Meet/{0}", nMeetMinus5PercentCount == nThreshold - 1 ? "1" : "0")] = ""; return(ret); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0.095 || zf < -0.095) { return(null); } if (zf < 0.01) { return(null); } if (dsh.IsLikeSTStop()) { return(null); } var szZF = dsh.SZRef(Info.ZF); if (szZF < 0.01) { return(null); } if (szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03) { return(null); } var recentMaxSZZF = dsh.SZRef(Info.ZF, dsh.SZHH(Info.ZF, 10, 1)); if (recentMaxSZZF < 0.005) { return(null); } var minSZZFIndex = dsh.SZLL(Info.ZF, 8, 1); if (dsh.SZRef(Info.ZF, minSZZFIndex) > -0.005) { return(null); } if (!dsh.IsReal()) { return(null); } if (dsh.UpShadow() > 0.04) { return(null); } if (dsh.DownShadow() < -0.04) { return(null); } var of = dsh.Ref(Info.OF); if (of > 0.02 || of < -0.04) { return(null); } if (dsh.Ref(Info.ZF, 1) > -0.02 || dsh.Ref(Info.ZF, 1) < -0.095) { return(null); } if (dsh.Ref(Info.ZF, 2) < -0.02) { return(null); } if (zf + dsh.Ref(Info.ZF, 1) < 0) { return(null); } if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 1.5) { return(null); } for (int i = 1; i < 8; ++i) { var curZF = dsh.Ref(Info.ZF, i); var curOf = dsh.Ref(Info.OF, i); if (curOf > 0.04 && curZF < 0) { return(null); } if (curOf < -0.02 && curZF < 0) { return(null); } } if (dsh.AccZF(8, 1) < -0.1) { return(null); } if (dsh.Ref(Info.ZF, dsh.HH(Info.CO, 10)) > 0) { return(null); } int iMaxVolIndex = dsh.HH(Info.V, 10); if (dsh.Ref(Info.C, iMaxVolIndex) > dsh.Ref(Info.O, iMaxVolIndex)) { return(null); } if ((dsh.Ref(Info.H, dsh.HH(Info.H, 8)) - dsh.Ref(Info.L, dsh.LL(Info.L, 8))) / dsh.Ref(Info.C, 1) > 0.2) { return(null); } return(EmptyRateItemButSel); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { IStrategy_LF stra = (IStrategy_LF)this; if (!meetBuyChance(dsh, selectMode)) { return(null); } if (dsh.Ref(Info.OF) > 0.04 || dsh.Ref(Info.OF) < -0.015 || dsh.Ref(Info.ZF, 1) < -0.02 || dsh.Ref(Info.OF, 1) < -0.03) { return(null); } if (dsh.Ref(Info.CO, 1) / dsh.Ref(Info.C, 1) < 0.01) { return(null); } int iSigDateIndex = -1; int nUpCount = 0; int nUStopCount = 0; int nDStopCount = 0; bool bMeetTradeSigAllready = false; bool bMeetRealUp = false; float sigDateVol = 0; float otherMaxVol = 0; bool bHasUpShadowTooHight = false; bool bHasDownShadowTooLow = false; float otherMaxZF = 0; float otherMaxC = 0; float otherMaxH = 0; float sumOfSigDateZF = 0; for (int i = 1; i < 8; ++i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curZf = dsh.Ref(Info.ZF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); if (curOf < 0.03 && curZf > 0.03 && curZf < 0.095 && dsh.Ref(Info.OF, i + 1) < 0.03 && dsh.Ref(Info.ZF, i + 1) > 0.03) { for (int j = i + 2; j < i + 5; j++) { if (dsh.Ref(Info.ZF, j) < 0) { break; } if (dsh.Ref(Info.ZF, j) > 0.05) { return(null); } } bool bHasDown = false; for (int j = i + 2; j < i + 7; j++) { if (dsh.Ref(Info.ZF, j) < 0) { bHasDown = true; break; } } if (dsh.AccZF(8, i + 2) < -0.15) { return(null); } float preVol = dsh.Ref(Info.V, i + 1); float chkVol = Math.Max(vol, preVol); for (int j = i + 2; j < i + 6; ++j) { if (dsh.Ref(Info.V, j) > chkVol * 2) { return(null); } } if (!bHasDown) { return(null); } sumOfSigDateZF = curZf + dsh.Ref(Info.ZF, i + 1); if (sumOfSigDateZF > 0.1) { iSigDateIndex = i; sigDateVol = Math.Max(dsh.Ref(Info.V, i + 1), vol); break; } } otherMaxVol = Math.Max(vol, otherMaxVol); if (curZf > 0 && dsh.IsReal(i)) { nUpCount++; } if (curZf > 0.095) { nUStopCount++; } else if (curZf < -0.095) { nDStopCount++; } if (curZf < -0.03) { bMeetTradeSigAllready = true; } else if (curZf > 0.012) { bMeetRealUp = true; } if (dsh.UpShadow(i) > 0.03) { bHasUpShadowTooHight = true; } if (dsh.DownShadow(i) < -0.03) { bHasDownShadowTooLow = true; } otherMaxZF = Math.Max(otherMaxZF, curZf); otherMaxC = Math.Max(dsh.Ref(Info.C, i), otherMaxC); otherMaxH = Math.Max(dsh.Ref(Info.H, i), otherMaxH); } if (iSigDateIndex == -1) { return(null); } sigInfo = dsh.Date(iSigDateIndex).ToString(); int iMaxCOIndex = dsh.HH(Info.CO, 30, 1); if (dsh.Ref(Info.ZF, iMaxCOIndex) < 0) { return(null); } if (nUpCount < 2) { return(null); } if (dsh.Ref(Info.C, 1) * (1 + stra.buyLimit() - 0.01) < dsh.Ref(Info.L, iSigDateIndex)) { return(null); } if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp) { return(null); } if (sigDateVol > otherMaxVol * 2) { return(null); } float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex); if (maxUpF < 0.015 /* || maxUpF > 0.04*/) { return(null); } if (sigDateVol < otherMaxVol * 1.2) { return(null); } if (bHasUpShadowTooHight || bHasDownShadowTooLow) { return(null); } if ( dsh.Ref(Info.ZF, 2) < 0.005 && dsh.Ref(Info.ZF, 3) < 0.005) { return(null); } if (Math.Min(dsh.Ref(Info.ZF, iSigDateIndex), dsh.Ref(Info.ZF, iSigDateIndex + 1)) + dsh.Ref(Info.ZF, iSigDateIndex + 2) < -0.01) { return(null); } if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex)) { return(null); } if (dsh.Ref(Info.C, iSigDateIndex + 1) < dsh.Ref(Info.O, iSigDateIndex + 1)) { return(null); } return(EmptyRateItemButSel); // var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1); // if (delta > -0.01) // { // return null; // } // var ret = new Dictionary<String, String>(); // ret[String.Format("sumSig/{0}", sumOfSigDateZF>0.12 ? "1": "0")] = ""; // ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")] = ""; // ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")] = ""; // ret[String.Format("diffzf/{0}", otherMaxZF + zf > -0.02 ? "1" : "0")] = ""; // return ret; }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0.095 || zf < -0.095) { return(null); } if (zf > 0.002 || zf < -0.002) { return(null); } // if (Math.Abs(dsh.Ref(Info.C) - dsh.Ref(Info.C, 1)) > 0.02*Setting.NormalizeRate) // { // return null; // } if (dsh.Ref(Info.HF) < 0.012) { return(null); } if (dsh.Ref(Info.ZF, 2) < 0.04 || dsh.Ref(Info.ZF, 2) > 0.095) { return(null); } if (dsh.Ref(Info.ZF, 1) < 0.01 || dsh.Ref(Info.ZF, 1) > 0.095) { return(null); } if (dsh.Ref(Info.ZF, 3) < -0.095) { return(null); } if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 1.2 && dsh.Ref(Info.V) > dsh.Ref(Info.V, 2) * 1.2) { return(null); } if (dsh.Ref(Info.OF) < -0.002 || dsh.Ref(Info.OF) > 0.005) { return(null); } if (dsh.AccZF(8, 3) < -0.15) { return(null); } var accZF3 = dsh.AccZF(3, 3); if (accZF3 > 0.02 && accZF3 < 0.05) { return(null); } if (accZF3 > 0.1) { return(null); } if (dsh.Ref(Info.OF, 1) > 0.03) { return(null); } if (dsh.Ref(Info.OF, 2) > 0.03) { return(null); } if (dsh.Ref(Info.HF, 1) > 0.095) { return(null); } int iMaxVolIndex = dsh.HH(Info.V, 20, 3); if (dsh.Ref(Info.C, iMaxVolIndex) < dsh.Ref(Info.O, iMaxVolIndex)) { return(null); } else { if (dsh.Ref(Info.HF, iMaxVolIndex - 1) <= 0 && dsh.Ref(Info.L, iMaxVolIndex - 1) <= dsh.Ref(Info.L, iMaxVolIndex)) { return(null); } if (dsh.UpShadow(iMaxVolIndex) > 0.06) { return(null); } } for (int i = 0; i < 8; ++i) { if (dsh.UpShadow(i) > 0.04) { return(null); } } int iMaxCOIndex = dsh.HH(Info.CO, 30, 1); if (dsh.Ref(Info.C, iMaxCOIndex) > dsh.Ref(Info.O, iMaxCOIndex)) { return(null); } if (!selectBySZ(dsh)) { return(null); } var ret = new Dictionary <String, String>(); ret[String.Format("of/{0}", dsh.Ref(Info.OF) > 0 ? "1" : "-1")] = ""; ret[String.Format("hf/{0}", dsh.Ref(Info.HF) > 0.02 ? "1" : "-1")] = ""; ret[String.Format("zf/{0}", Math.Abs(dsh.Ref(Info.ZF)) > 0.001 ? "1" : "-1")] = ""; return(ret); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0.095 || zf < -0.095) { return(null); } if (zf < 0.02 || zf > 0.03) { return(null); } if (dsh.IsLikeSTStop()) { return(null); } if (dsh.Ref(Info.OF) < -0.015) { return(null); } if (dsh.EveryDown(1) >= 3) { return(null); } if (dsh.Ref(Info.ZF, 1) > -0.02 || dsh.Ref(Info.ZF, 1) < -0.05) { return(null); } if (dsh.UpShadow() > 0.04) { return(null); } if (dsh.Ref(Info.CO) / dsh.Ref(Info.C, 1) < 0.01) { return(null); } if (dsh.AccZF(8) > -0.1) { return(null); } if (dsh.AccZF(2) > 0) { return(null); } if (dsh.HH(Info.V, 8) == 0) { return(null); } if (dsh.DownShadow() < -0.04) { return(null); } if (dsh.Ref(Info.ZF, 2) < -0.01) { return(null); } if (!dsh.IsReal()) { return(null); } for (int i = 1; i < 8; ++i) { var curZF = dsh.Ref(Info.ZF, i); var curOF = dsh.Ref(Info.OF, i); if (curZF < -0.095 || curZF > 0.095) { return(null); } if (curOF > 0.04 && dsh.IsGreen(i)) { return(null); } if (dsh.IsUpStopEveryDay(3, i)) { return(null); } } if (!selectBySZ(dsh)) { return(null); } return(EmptyRateItemButSel); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0.095 || zf < -0.095) { return(null); } if (zf > 0.03 || zf < 0.02) { return(null); } if (!dsh.IsReal()) { return(null); } if (dsh.UpShadow() > 0.04) { return(null); } var of = dsh.Ref(Info.OF); if (of > 0.02 || of < -0.04) { return(null); } if (dsh.Ref(Info.ZF, 1) > -0.005) { return(null); } if (dsh.Ref(Info.ZF, 2) < 0.005 || !dsh.IsReal(2)) { return(null); } if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 1.5) { return(null); } if ((dsh.Ref(Info.C) - dsh.Ref(Info.C, 2)) / dsh.Ref(Info.C, 1) > 0.01) { return(null); } if (dsh.Ref(Info.C) > dsh.Ref(Info.O, 1)) { return(null); } if ((dsh.Ref(Info.L) - dsh.Ref(Info.L, 2)) / dsh.Ref(Info.C, 1) > 0.01) { return(null); } int nTotalDownDays = dsh.EveryDown(3); if (nTotalDownDays < 4) { return(null); } if (dsh.EveryUp(3 + nTotalDownDays) > nTotalDownDays) { return(null); } float totalZF = dsh.AccZF(nTotalDownDays, 3); if (totalZF > -0.1) { return(null); } var szZF = dsh.SZRef(Info.ZF); if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03) { return(null); } if (!selectBySZ(dsh)) { return(null); } return(EmptyRateItemButSel); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { IStrategy_LF stra = (IStrategy_LF)this; if (!meetBuyChance(dsh, selectMode)) { return(null); } if (dsh.Ref(Info.OF) > 0.04 || dsh.Ref(Info.OF) < -0.015 || dsh.Ref(Info.ZF, 1) < -0.02 || dsh.Ref(Info.OF, 1) < -0.03) { return(null); } if (dsh.Ref(Info.CO, 1) / dsh.Ref(Info.C, 1) < 0.01) { return(null); } int iSigDateIndex = -1; int nUpCount = 0; int nDownCount = 0; int nUStopCount = 0; int nDStopCount = 0; bool bMeetTradeSigAllready = false; bool bMeetRealUp = false; bool bHasUpShadowTooHight = false; bool bHasDownShadowTooLow = false; float otherMaxVol = float.MinValue; float otherMaxC = float.MinValue; float otherMaxH = float.MinValue; float otherMaxZF = float.MinValue; float sigDateVol = 0; float sigZF = 0; float minDownShadow = float.MaxValue; float maxUpShadow = float.MinValue; float otherMinZF = float.MaxValue; float totalUp = 0; float totalDown = 0; for (int i = 1; i < 8; ++i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curZf = dsh.Ref(Info.ZF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); if (curZf > 0.095) { return(null); } if (curOf < 0.04 && curHf > 0.095 && curZf < 0.095 && curZf > 0) { iSigDateIndex = i; sigDateVol = vol; sigZF = curZf; for (int j = i + 1; j < i + 5; ++j) { if (dsh.Ref(Info.V, j) > vol * 2) { return(null); } } if (dsh.AccZF(8, i + 1) < -0.15) { return(null); } if (dsh.AccZF(3, i + 1) > 0.095) { return(null); } break; } if (curOf < -0.04) { return(null); } if (curZf > 0 && dsh.IsReal(i)) { nUpCount++; } if (curZf < 0 && dsh.IsReal(i)) { nDownCount++; } if (curZf > 0.095) { nUStopCount++; } else if (curZf < -0.095) { nDStopCount++; } if (curZf < -0.03) { bMeetTradeSigAllready = true; } else if (curZf > 0.012) { bMeetRealUp = true; } float upShadow = dsh.UpShadow(i); float downShadow = dsh.DownShadow(i); if (upShadow > maxUpShadow) { maxUpShadow = upShadow; } if (downShadow < minDownShadow) { minDownShadow = downShadow; } if (curZf > 0) { totalUp += curZf; } else { totalDown += curZf; } otherMaxVol = Math.Max(vol, otherMaxVol); otherMaxC = Math.Max(dsh.Ref(Info.C, i), otherMaxC); otherMaxH = Math.Max(dsh.Ref(Info.H, i), otherMaxH); otherMaxZF = Math.Max(otherMaxZF, curZf); otherMinZF = Math.Min(otherMinZF, curZf); } if (iSigDateIndex == -1) { return(null); } sigInfo = dsh.Date(iSigDateIndex).ToString(); if (dsh.Ref(Info.ZF, iSigDateIndex) + dsh.Ref(Info.ZF, iSigDateIndex + 1) < -0.01) { return(null); } if (sigDateVol > otherMaxVol * 2) { return(null); } if (otherMinZF > 0.03) { return(null); } if (totalDown + totalUp < -0.01) { return(null); } if (otherMaxH < dsh.Ref(Info.H, iSigDateIndex)) { return(null); } if (dsh.Ref(Info.C, 1) * (1 + stra.buyLimit() - 0.01) < dsh.Ref(Info.L, iSigDateIndex)) { return(null); } if (maxUpShadow > 0.03) { bHasUpShadowTooHight = true; } if (minDownShadow < -0.03) { bHasDownShadowTooLow = true; } if (nUpCount < 2) { return(null); } if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp) { return(null); } float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex); if (maxUpF < 0.02 /* || maxUpF > 0.04*/) { return(null); } // if (sigDateVol < otherMaxVol * 1.2) // { // return null; // } // if (dsh.Ref(Info.LF) < -0.06) // { // return null; // } if (bHasUpShadowTooHight || bHasDownShadowTooLow) { return(null); } // if (dsh.Ref(Info.OF) < -0.02) // { // return null; // } if ( dsh.Ref(Info.ZF, 2) < 0.005 && dsh.Ref(Info.ZF, 3) < 0.005) { return(null); } if (dsh.Ref(Info.ZF, iSigDateIndex - 1) < 0 && dsh.IsReal(iSigDateIndex - 1) && dsh.Ref(Info.H, iSigDateIndex - 1) > dsh.Ref(Info.H, iSigDateIndex)) { return(null); } // if (dsh.Ref(Info.ZF, iSigDateIndex-1) < 0 && // dsh.Ref(Info.ZF, iSigDateIndex - 2) < 0) // { // return null; // } if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex)) { return(null); } var delta = (dsh.Ref(Info.C, 1) * (1 + stra.buyLimit() + 0.01) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1); if (delta > -0.01) { return(null); } var ret = new Dictionary <String, String>(); ret[String.Format("vol/{0}", sigDateVol < otherMaxVol * 1.5 ? "1" : "0")] = ""; // ret[String.Format("maxUp/{0}", maxUpF > 0.03 ? "1" : "0")] = ""; return(ret); }
Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo) { var zf = dsh.Ref(Info.ZF); if (zf > 0 || zf < -0.095) { return(null); } if (!dsh.IsReal()) { return(null); } if (dsh.Ref(Info.OF, 1) < -0.03) { return(null); } if (dsh.Ref(Info.LF) < -0.06) { return(null); } int iSigDateIndex = -1; int nUpCount = 0; int nDownCount = 0; int nUStopCount = 0; int nDStopCount = 0; bool bMeetTradeSigAllready = false; bool bMeetRealUp = false; float sigDateVol = 0; float otherMaxVol = 0; bool bHasUpShadowTooHight = false; bool bHasDownShadowTooLow = false; float otherMaxZF = 0; float otherMinZF = float.MaxValue; float otherMaxC = 0; float otherMaxH = 0; float sumOfSigDateZF = 0; float otherMaxDownV = 0; float minSigV = float.MaxValue; float totalUp = 0; float totalDown = 0; for (int i = 1; i < 8; ++i) { var curOf = dsh.Ref(Info.OF, i); var curHf = dsh.Ref(Info.HF, i); var curZf = dsh.Ref(Info.ZF, i); var curPreZf = dsh.Ref(Info.ZF, i + 1); var vol = dsh.Ref(Info.V, i); var preVol = dsh.Ref(Info.V, i + 1); if (dsh.Ref(Info.OF, i) > 0.03 && curZf < 0) { return(null); } float ma5 = dsh.MA(Info.V, 10, i + 2); float hhv = dsh.Ref(Info.V, dsh.HH(Info.V, 5, i + 2)); if (curZf > 0.01 && curPreZf > 0.01 && vol > 1.3 * hhv && preVol > 1.3 * hhv && (vol < vRate_ * preVol && preVol < vRate_ * vol) && vol / ma5 > vRate_ && preVol / ma5 > vRate_ && dsh.Ref(Info.ZF, i + 2) < 0.05 && dsh.Ref(Info.V, i + 2) / dsh.MA(Info.V, 5, i + 3) < vRate_) { for (int j = i + 2; j < i + 7; j++) { if (dsh.Ref(Info.ZF, j) < -0.095) { return(null); } } if (dsh.AccZF(2, i) < 0.05) { return(null); } { iSigDateIndex = i; sigDateVol = Math.Max(dsh.Ref(Info.V, i + 1), vol); minSigV = Math.Min(dsh.Ref(Info.V, i + 1), vol); break; } } otherMaxVol = Math.Max(vol, otherMaxVol); if (curZf > 0.005 && dsh.IsReal(i)) { nUpCount++; } else if (curZf < -0.005 && dsh.IsReal(i)) { nDownCount++; } if (curZf > 0.095) { nUStopCount++; } else if (curZf < -0.095) { nDStopCount++; } if (curZf < -0.03) { bMeetTradeSigAllready = true; } if (curZf > 0) { totalUp += curZf; } else { totalDown += curZf; } if (curZf > 0.012) { bMeetRealUp = true; } if (dsh.UpShadow(i) > 0.03) { bHasUpShadowTooHight = true; } if (dsh.DownShadow(i) < -0.03) { bHasDownShadowTooLow = true; } otherMaxZF = Math.Max(otherMaxZF, curZf); otherMinZF = Math.Min(otherMinZF, curZf); otherMaxC = Math.Max(dsh.Ref(Info.C, i), otherMaxC); otherMaxH = Math.Max(dsh.Ref(Info.H, i), otherMaxH); if (curZf < 0) { otherMaxDownV = Math.Max(otherMaxDownV, vol); } } if (iSigDateIndex == -1) { return(null); } // sigInfo = dsh.Date(iSigDateIndex).ToString(); if (totalDown + totalUp < -0.01) { return(null); } if (nUpCount < 2) { return(null); } if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp) { return(null); } float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex); if (maxUpF < 0.015 /* || maxUpF > 0.04*/) { return(null); } if (sigDateVol < otherMaxVol * 1.2) { return(null); } if (otherMaxZF + zf > 0) { return(null); } sigInfo = (otherMaxZF + zf).ToString("F4"); if (otherMaxZF + zf < -0.02) { return(null); } if (bHasUpShadowTooHight || bHasDownShadowTooLow) { return(null); } if ( dsh.Ref(Info.ZF, 2) < 0.005 && dsh.Ref(Info.ZF, 3) < 0.005) { return(null); } if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex)) { return(null); } if (dsh.Ref(Info.C, iSigDateIndex + 1) < dsh.Ref(Info.O, iSigDateIndex + 1)) { return(null); } if (Math.Min(dsh.Ref(Info.ZF, iSigDateIndex), dsh.Ref(Info.ZF, iSigDateIndex + 1)) + dsh.Ref(Info.ZF, iSigDateIndex + 2) < -0.01) { return(null); } var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1); if (delta > -0.01) { return(null); } var szZF = dsh.SZRef(Info.ZF); if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03) { return(null); } if (!selectBySZ(dsh)) { return(null); } var ret = new Dictionary <String, String>(); ret[String.Format("sumSig/{0}", sumOfSigDateZF > 0.12 ? "1" : "0")] = ""; ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")] = ""; ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")] = ""; ret[String.Format("maxZF/{0}", otherMaxZF + zf > -0.01 ? "1" : "0")] = ""; ret[String.Format("diffzf/{0}", otherMaxZF + zf > -0.02 ? "1" : "0")] = ""; return(ret); }