📄 reaction trend system.afl
字号:
if (L[ i ] <= LBOP[ i ]) {
// take a short position in trend mode
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
} else
// entry of Area 4
if (H[ i ] >= HBOP[ i ]) {
// take a long position in the trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
// open in Area 3
if (O[ i ] <= LBOP[ i ]) {
// take a short position in the trend mode
Short[ i ] = 1;
ShortPrice[ i ] = O[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
} else
// open in Area 2
if (O[ i ] >= HBOP[ i ]) {
// take a long position in the trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = O[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
/* "S" day + no position. 4 areas of entry may be defined
1) open between LBOP and S1 (area 1)
2) open between S1 and HBOP (area 2)
3) open higher than HBOP (area 3)
4) open lower than LBOP (area 4)
*/
if (phase_arr[ i ] == 3 AND reaction_position_buy == 0 AND trend_position_buy == 0 AND
reaction_position_short == 0 AND trend_position_short == 0) {
// open in area 1
if (O[ i ] > LBOP[ i ] AND O[ i ] < S1[ i ]) {
// check for entry of Area 2
if (H[ i ] >= S1[ i ]) {
Short[ i ] = 1;
ShortPrice[ i ] = S1[ i ];
reaction_position_short = 1;
// check for entry of Area 3 (breakout)
if (H[ i ] >= HBOP[ i ]) {
// cover position first
Cover[ i ] = 1;
CoverPrice[ i ] = HBOP[ i ];
reaction_position_short = 0;
// take a long position in the trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
} else
// check for enrty of Area 4 (breakout)
if (L[ i ] <= LBOP[ i ]) {
// only change the mode since we are already short
reaction_position_short = 0;
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
// check for entry of Area 4
if (L[ i ] <= LBOP[ i ]) {
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
// open in area 2
if (O[ i ] >= S1[ i ] AND O[ i ] < HBOP[ i ]) {
Short[ i ] = 1;
ShortPrice[ i ] = O[ i ];
reaction_position_short = 1;
// check for entry of Area 3 (breakout)
if (H[ i ] >= HBOP[ i ]) {
// cover the reaction mode short position you just entered
Cover[ i ] = 1;
CoverPrice[ i ] = HBOP[ i ];
reaction_position_short = 0;
// take a long position in the trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
} else
// check for enrty of Area 4 (breakout)
if (L[ i ] <= LBOP[ i ]) {
// only change the mode since we are already short
reaction_position_short = 0;
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
// open in Area 4
if (O[ i ] <= LBOP[ i ]) {
// take a short position in the trend mode
Short[ i ] = 1;
ShortPrice[ i ] = O[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
} else
// open in Area 3
if (O[ i ] >= HBOP[ i ]) {
// take a long position in the trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = O[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
/* "B" day PLUS short reaction mode position. 4 Entry areas of interest
1) open between B1 and HBOP (area 1)
2) open between LBOP and B1 (area 2)
3) open below LBOP (area 3)
4) open above HBOP (area 4)
*/
if (phase_arr[ i ] == 1 AND reaction_position_buy == 0 AND trend_position_buy == 0 AND
reaction_position_short == 1 AND trend_position_short == 0) {
// open in area 1
if (O[ i ] > B1[ i ] AND O[ i ] < HBOP[ i ]) {
// enter area 2
if (L[ i ] <= B1[ i ]) {
// cover short position
Cover[ i ] = 1;
CoverPrice[ i ] = B1[ i ];
reaction_position_short = 0;
// reverse short into a long
Buy[ i ] = 1;
BuyPrice[ i ] = B1[ i ];
reaction_position_buy = 1;
// price enters area 3
if (L[ i ] <= LBOP[ i ]) {
// close long position
Sell[ i ] = 1;
SellPrice[ i ] = LBOP[ i ];
reaction_position_buy = 0;
// open short trend mode position
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
} else
// price enters area 4
if (H[ i ] >= HBOP[ i ]) {
// just change the mode
reaction_position_buy = 0;
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
// stay in area 1 and cover position at the close
if (L[ i ] > B1[ i ] AND H[ i ] < HBOP[ i ] AND timebar[ i ] == 1) {
// cover at close
Cover[ i ] = 1;
CoverPrice[ i ] = C[ i ];
reaction_position_short = 0;
} else
// price enters area 4
if (H[ i ] >= HBOP[ i ]) {
// cover short position
Cover[ i ] = 1;
CoverPrice[ i ] = HBOP[ i ];
reaction_position_short = 0;
// go long in trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
// open in area 2
if (O[ i ] > LBOP[ i ] AND O[ i ] <= B1[ i ]) {
// cover the short position
Cover[ i ] = 1;
CoverPrice[ i ] = O[ i ];
reaction_position_short = 0;
// reverse position
Buy[ i ] = 1;
BuyPrice[ i ] = O[ i ];
reaction_position_buy = 1;
// price enters area 3
if (L[ i ] <= LBOP[ i ]) {
// close long position
Sell[ i ] = 1;
SellPrice[ i ] = LBOP[ i ];
reaction_position_buy = 0;
// open short trend mode position
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
} else
// price enters area 4
if (H[ i ] > HBOP[ i ]) {
// just change the mode
reaction_position_buy = 0;
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
// open in area 3
if (O[ i ] <= LBOP[ i ]) {
// position is already short, just change the mode
reaction_position_short = 0;
trend_position_short = 1;
tpss[ i ] = 1;
} else
// open in area 4
if (O[ i ] >= HBOP[ i ]) {
// close the short position
Cover[ i ] = 1;
CoverPrice[ i ] = O[ i ];
reaction_position_short = 0;
// and go long in trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = O[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
}
} else
/* "O" day PLUS long reaction mode position, 4 areas of interest
1) open between LBOP and S1 (area 1)
2) open between S1 and HBOP (area 2)
3) open above HBOP (area 3)
4) open below LBOP ( area 4)
*/
if (phase_arr[ i ] == 2 AND reaction_position_buy == 1 AND trend_position_buy == 0 AND
reaction_position_short == 0 AND trend_position_short == 0) {
// open in area 1
if (O[ i ] > LBOP[ i ] AND O[ i ] < S1[ i ]) {
// entry of area 2
if (H[ i ] >= S1[ i ]) {
Sell[ i ] = 1;
SellPrice[ i ] = S1[ i ];
reaction_position_buy = 0;
// enter area 3
if (H[ i ] >= HBOP[ i ]) {
// go long in trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
} else
// enter area 4
if (L[i ] <= LBOP[ i ]) {
// go short in trend mode
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
// entry of area 4
if (L[ i ] <= LBOP[ i ]) {
// sell currect position
Sell[ i ] = 1;
SellPrice[ i ] = LBOP[ i ];
reaction_position_buy = 0;
// enter the short trend mode
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
// open in area 2
if (O[ i ] >= S1[ i ] AND O[ i ] < HBOP[ i ]) {
// sell position straight away
Sell[ i ] = 1;
SellPrice[ i ] = O[ i ];
reaction_position_buy = 0;
// enter area 3
if (H[ i ] >= HBOP[ i ]) {
// go long in trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
} else
// enter area 4
if (L[i ] <= LBOP[ i ]) {
// go short in trend mode
Short[ i ] = 1;
ShortPrice[ i ] = LBOP[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
// open in area 3
if (O[ i ] >= HBOP[ i ]) {
// position is already long, just change the mode
reaction_position_buy = 0;
trend_position_buy = 1;
tpsl[ i ] = 1;
} else
// open in area 4
if (O[ i ] <= LBOP[ i ]) {
// close the long position
Sell[ i ] = 1;
SellPrice[ i ] = O[ i ];
reaction_position_buy = 0;
// and go short in trend mode
Short[ i ] = 1;
ShortPrice[ i ] = O[ i ];
trend_position_short = 1;
tpss[ i ] = 1;
}
} else
/* "S" day + long reaction mode position, 4 areas of interest
1) open between LBOP and S1 (area 1)
2) open between S1 and HBOP
3) open above HBOP (area 3)
4) open below LBOP (area 4)
*/
if (phase_arr[ i ] == 3 AND reaction_position_buy == 1 AND trend_position_buy == 0 AND
reaction_position_short == 0 AND trend_position_short == 0) {
// open in area 1
if (O[ i ] > LBOP[ i ] AND O[ i ] < S1[ i ]) {
// entry of area 2
if (H[ i ] >= S1[ i ]) {
// sell position
Sell[ i ] = 1;
SellPrice[ i ] = S1[ i ];
reaction_position_buy = 0;
// reverse position
Short[ i ] = 1;
ShortPrice[ i ] = S1[ i ];
reaction_position_short = 1;
// enter area 3
if (H[ i ] >= HBOP[ i ]) {
// close out short position
Cover[ i ] = 1;
CoverPrice[ i ] = HBOP[ i ];
reaction_position_short = 0;
// go long in trend mode
Buy[ i ] = 1;
BuyPrice[ i ] = HBOP[ i ];
trend_position_buy = 1;
tpsl[ i ] = 1;
} else
// enter area 4
if (L[i ] <= LBOP[ i ]) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -