- 精华
- 0
- 在线时间
- 2 小时
- UID
- 248239
- 积分
- 3
- 帖子
- 2
- 阅读权限
- 10
- 注册时间
- 2017-3-7
- 最后登录
- 2017-3-10
- 精华
- 0
- UID
- 248239
- 积分
- 3
- 帖子
- 2
- 主题
- 1
- 阅读权限
- 10
- 注册时间
- 2017-3-7
- 最后登录
- 2017-3-10
|
PARAMS
Numeric Direction(0);
Numeric SlipJump(1);
Numeric LotL(0);
Numeric LotS(0);
Numeric EntTimeA(93000);
Numeric EntTimeB(143000);
Numeric CCILength(15);
Numeric CMOLength(37);
Numeric ParAfStep(0.03);
Numeric ParAfLimit(0.19);
Numeric PCLenA1(76);
Numeric PCLenA2(87);
Numeric PCNA(44);
Numeric PCLenC1(76);
Numeric PCLenC2(87);
Numeric PCNC(44);
Numeric ExAbsStopPcL(0.57);
Numeric ExAbsTargPcL(2.99);
Numeric ExDnRanLenL1(4);
Numeric ExDnRanLenL2(35);
Numeric ExDnRanLenL3(77);
Numeric ExDnRanLenL4(93);
Numeric ExAbsStopPcS(0.57);
Numeric ExAbsTargPcS(2.99);
Numeric ExUpRanLenS1(4);
Numeric ExUpRanLenS2(35);
Numeric ExUpRanLenS3(77);
Numeric ExUpRanLenS4(93);
VARS
Numeric Slip;
Bool Cond_Time;
Numeric EntPrice;
Numeric ExtPrice;
NumericSeries CCITmp;
Numeric CCIMean(0);
Numeric CCIAvgDev(0);
Numeric CCICounter(0);
NumericSeries CCI(0);
NumericSeries CMO;
NumericSeries CMOCloseUp;
NumericSeries CMOCloseDown;
Numeric CMOSumCloseUp;
Numeric CMOSumCloseDown;
Numeric ParClose;
Numeric ParOpen;
Numeric ParPosition;
Numeric ParTransition;
BoolSeries ConditionA;
BoolSeries ConditionB;
BoolSeries ConditionC;
BoolSeries ConditionD;
BoolSeries EntMarketCondL;
BoolSeries EntMarketCondS;
Numeric ExAbsStopL;
Numeric ExAbsTargetL;
NumericSeries ExDownRangeL;
Numeric ExAbsStopS;
Numeric ExAbsTargetS;
NumericSeries ExUpRangeS;
BEGIN
Cond_Time = Time >= EntTimeA/1000000 && Time <= EntTimeB/1000000;
Slip = SlipJump * MinMove * PriceScale;
/* Calculate indicator CCI ----------------------------------------- */
CCITmp = High + Low + Close;
CCIMean = AverageFC(CCITmp, CCILength);
CCIAvgDev = 0;
For CCICounter = 0 to CCILength - 1
CCIAvgDev = CCIAvgDev + Abs(CCITmp[CCICounter] - CCIMean);
CCIAvgDev = CCIAvgDev / CCILength;
If ( CCIAvgDev == 0 )
CCI = 0;
Else
CCI = (CCITmp - CCIMean) / (0.015 * CCIAvgDev);
/* Calculate indicator CMO ----------------------------------------- */
If ( Close > Close[1] ) {
CMOCloseUp = Close - Close[1];
CMOCloseDown = 0;
} Else If ( Close < Close[1] ) {
CMOCloseUp = 0;
CMOCloseDown = Close[1] - Close;
} Else {
CMOCloseUp = 0;
CMOCloseDown = 0;
}
CMOSumCloseUp = SummationFC(CMOCloseUp, CMOLength);
CMOSumCloseDown = SummationFC(CMOCloseDown, CMOLength);
If ( CMOSumCloseUp + CMOSumCloseDown <> 0 )
CMO = (CMOSumCloseUp - CMOSumCloseDown) / (CMOSumCloseUp + CMOSumCloseDown) * 100;
/* Calculate indicator ParabolicSAR -------------------------------- */
ParabolicSAR(ParAfStep, ParAfLimit, ParClose, ParOpen, ParPosition, ParTransition);
/* Calculate conditions -------------------------------------------- */
ConditionA = CrossUnder(MidPoint(CMO, PCLenA2), XAverage(CMO[PCNA], PCLenA1));
ConditionB = Max(CCI, CCI) < 0;
ConditionC = CrossOver(MidPoint(CMO, PCLenC2), XAverage(CMO[PCNC], PCLenC1));
ConditionD = Min(CCI, CCI) > 0;
/* Long entry module ----------------------------------------------- */
EntMarketCondL = CrossUnder(ParTransition, 0);
If (Direction >= 0 && MarketPosition == 0 && Cond_Time) {
If (EntMarketCondL[1]) {
EntPrice = IIF(AccountDataExist, 0, Open);
Buy(LotL, EntPrice);
}
}
/* Short entry module ---------------------------------------------- */
EntMarketCondS = CrossOver(ParTransition, 0);
If (Direction <= 0 && MarketPosition == 0 && Cond_Time) {
If (EntMarketCondS[1]) {
EntPrice = IIF(AccountDataExist, 0, Open);
SellShort(LotS, EntPrice);
}
}
/* Long stop loss exit module -------------------------------------- */
ExAbsStopL = EntryPrice * (1 - ExAbsStopPcL/100);
If (Direction >= 0 && MarketPosition == 1 && BarsSinceLastEntry > 0) {
If (Open <= ExAbsStopL) {
ExtPrice = IIF(AccountDataExist, Q_BidPrice-Slip, Open);
Sell(0, ExtPrice);
}
}
/* Long bands exit module ------------------------------------------ */
ExDownRangeL = SAverage(Low, ExDnRanLenL4) - MidPoint(Abs((SMA((Close*2+High+Low)/4, ExDnRanLenL3, ExDnRanLenL1) - TrueHigh)), ExDnRanLenL2);
If (Direction >= 0 && MarketPosition == 1 && BarsSinceLastEntry > 0) {
If (Open <= ExDownRangeL[1] && (ConditionB[1] && ConditionA[1])) {
ExtPrice = IIF(AccountDataExist, Q_BidPrice-Slip, Open);
Sell(0, ExtPrice);
}
}
/* Long stop profit exit module ------------------------------------ */
ExAbsTargetL = EntryPrice * (1 + ExAbsTargPcL/100);
If (Direction >= 0 && MarketPosition == 1 && BarsSinceLastEntry > 0) {
If (Close[1] >= ExAbsTargetL) {
ExtPrice = IIF(AccountDataExist, Q_BidPrice-Slip, Open);
Sell(0, ExtPrice);
}
}
/* Short stop loss exit module ------------------------------------- */
ExAbsStopS = EntryPrice * (1 + ExAbsStopPcS/100);
If (Direction <= 0 && MarketPosition == -1 && BarsSinceLastEntry > 0) {
If (Open >= ExAbsStopS) {
ExtPrice = IIF(AccountDataExist, Q_AskPrice+Slip, Open);
BuyToCover(0, ExtPrice);
}
}
/* Short bands exit module ----------------------------------------- */
ExUpRangeS = SAverage(High, ExUpRanLenS4) + MidPoint(Abs((SMA((Close*2+High+Low)/4, ExUpRanLenS3, ExUpRanLenS1) - TrueLow)), ExUpRanLenS2);
If (Direction <= 0 && MarketPosition == -1 && BarsSinceLastEntry > 0) {
If (Open >= ExUpRangeS[1] && (ConditionD[1] && ConditionC[1])) {
ExtPrice = IIF(AccountDataExist, Q_AskPrice+Slip, Open);
BuyToCover(0, ExtPrice);
}
}
/* Short stop profit exit module ----------------------------------- */
ExAbsTargetS = EntryPrice * (1 - ExAbsTargPcS/100);
If (Direction <= 0 && MarketPosition == -1 && BarsSinceLastEntry > 0) {
If (Close[1] <= ExAbsTargetS) {
ExtPrice = IIF(AccountDataExist, Q_AskPrice+Slip, Open);
BuyToCover(0, ExtPrice);
}
}
END
|
|