Skip to content

Commit 286d50b

Browse files
author
root
committed
update
1 parent c8182b2 commit 286d50b

File tree

1,091 files changed

+215726
-7933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,091 files changed

+215726
-7933
lines changed
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
2+
> Name
3+
4+
1-3-1-红绿K线反转策略1-3-1-Red-Green-Candlestick-Reversal-Strategy
5+
6+
> Author
7+
8+
ChaoZhang
9+
10+
> Strategy Description
11+
12+
![IMG](https://www.fmz.com/upload/asset/491225d47e40fa480f.png)
13+
14+
[trans]
15+
16+
## 概述
17+
18+
1-3-1 红绿K线反转策略是一种根据K线形态进行买卖信号判断的策略。该策略通过观察1根红色K线是否被3根绿色K线反转来寻找买入机会。
19+
20+
## 原理
21+
22+
该策略的核心逻辑是:
23+
24+
1. 判断当前K线是否为红色K线,即收盘价低于开盘价
25+
2. 判断之前3根K线是否都是绿色K线,即收盘价高于开盘价
26+
3. 判断最后1根绿色K线的收盘价是否高于前2根绿色K线
27+
4. 如果满足上述条件,则在红色K线收盘时以市价买入
28+
5. 止损价设为红色K线的最低价
29+
6. 止盈价设为入场价加上入场价到止损价的距离
30+
31+
通过这个策略,我们可以在红色K线被反转的情况下买入,因为之后的趋势很可能是上涨的。同时设置止损和止盈来控制风险和锁定盈利。
32+
33+
## 优势分析
34+
35+
1-3-1 红绿K线反转策略具有以下优势:
36+
37+
1. 策略逻辑简单清晰,容易理解和实现
38+
2. 利用K线形态特征,不依赖任何指标,避免因过度优化产生的问题
39+
3. 有明确的入场和出场规则,可以客观执行
40+
4. 设置止损和止盈,可以控制每单交易的风险收益比
41+
5. 回测结果良好,具有较强的实盘调整可能性
42+
43+
## 风险分析
44+
45+
该策略也存在一些风险需要注意:
46+
47+
1. K线形态无法百分百预测未来趋势,存在一定的不确定性
48+
2. 只买入一次,容易因个股特殊性导致胜率不高
49+
3. 没有考虑大盘走势,在大盘持续下跌时持有风险较大
50+
4. 没有设置交易费用和滑点,实盘效果可能会差一些
51+
52+
对策:
53+
54+
1. 可以考虑结合均线等指标过滤信号,提高买入的成功率
55+
2. 调整仓位管理,分批建仓
56+
3. 根据大盘情况动态调整止损位置或暂停交易
57+
4. 测试不同的止损止盈比例设置
58+
5. 测试加入交易成本后的实盘效果
59+
60+
## 优化方向
61+
62+
该策略可以从以下几个方面进行优化:
63+
64+
1. 基于大盘指数的过滤。可以根据大盘的短期和中期趋势来过滤交易信号,在大盘上涨时买入,大盘下跌时停止交易。
65+
66+
2. 考虑成交量的确认。增加对绿色K线成交量的判断,仅在成交量有所放大时才买入。
67+
68+
3. 优化止损止盈比例。可以测试不同的止损止盈比例,找到最优参数组合。也可以设置动态止损或移动止损。
69+
70+
4. 仓位管理优化。可以分批建仓,后续在条件满足时加仓,降低单次交易的风险。
71+
72+
5. 加入更多过滤条件。比如考虑均线、波动率等指标,确保在趋势更加明确时买入。
73+
74+
6. 大数据训练寻找最优参数。收集大量历史数据,使用机器学习等技术训练最优的参数阈值。
75+
76+
## 总结
77+
78+
1-3-1 红绿K线反转策略整体来说是一个简单实用的短线交易策略。它有明确的入场退出规则,回测效果良好。我们可以通过一些优化措施来提高它的实盘效果,使之成为一个可靠的量化交易策略。同时也需要注意风险控制,妥善管理资金。
79+
80+
||
81+
82+
## Overview
83+
84+
The 1-3-1 red green candlestick reversal strategy is a strategy that generates buy and sell signals based on candlestick patterns. It looks for buying opportunities when 1 red candlestick is reversed by 3 subsequent green candlesticks.
85+
86+
## Principles
87+
88+
The core logic of this strategy is:
89+
90+
1. Check if the current candlestick is a red candle, i.e. the close price is lower than the open price
91+
2. Check if the previous 3 candlesticks are green candles, i.e. close price is higher than open price
92+
3. Check if the last green candle's close price is higher than the previous 2 green candles
93+
4. If the above conditions are met, go long at the close of the red candle
94+
5. Set stop loss at the lowest price of the red candle
95+
6. Set take profit at entry price plus the distance from entry to stop loss
96+
97+
With this strategy, we can buy when the red candle is reversed, because the subsequent trend is likely to be upwards. Stop loss and take profit are set to control risk and lock in profits.
98+
99+
## Advantage Analysis
100+
101+
The 1-3-1 red green reversal strategy has the following advantages:
102+
103+
1. Simple and clear logic, easy to understand and implement
104+
2. Utilizes candlestick pattern features without reliance on indicators, avoiding overoptimization problems
105+
3. Has clear entry and exit rules for objective execution
106+
4. Sets stop loss and take profit to control risk/reward of each trade
107+
5. Good backtest results, likely to translate well to live trading
108+
109+
## Risk Analysis
110+
111+
Some risks to note for this strategy:
112+
113+
1. Candlestick patterns cannot perfectly predict future moves, some uncertainty exists
114+
2. Only one entry, may have lower win rate due to stock specifics
115+
3. No consideration of market trend, risk holding during sustained downtrend
116+
4. Does not account for trading costs and slippage, actual performance may be worse
117+
118+
Solutions:
119+
120+
1. Consider combining with MA etc to filter signals and improve entry success rate
121+
2. Adjust position sizing, scale in across multiple entries
122+
3. Dynamically adjust stop loss based on market conditions or pause trading
123+
4. Test different stop loss/take profit ratios
124+
5. Test actual performance including trading costs
125+
126+
## Optimization Directions
127+
128+
Some ways this strategy can be optimized:
129+
130+
1. Market index filtering - filter signals based on short/medium term market trend, go long in uptrend and stop trading in downtrend
131+
132+
2. Volume confirmation - only go long if green candle volumes increase
133+
134+
3. Optimize stop loss/take profit ratios - test different ratios to find optimal parameters
135+
136+
4. Position sizing optimization - scale in across multiple entries to reduce single trade risk
137+
138+
5. Add more filters - e.g. MA, volatility etc to ensure high probability entry
139+
140+
6. Machine learning on big data - collect lots of historical data and train optimal parameter thresholds via ML
141+
142+
## Conclusion
143+
144+
The 1-3-1 red green reversal strategy is overall a simple and practical short term trading strategy. It has clear entry and exit rules and good backtest results. With some optimization measures, it can become a reliable quant trading strategy. Risk management is also important to manage capital properly.
145+
146+
[/trans]
147+
148+
149+
150+
> Source (PineScript)
151+
152+
``` javascript
153+
/*backtest
154+
start: 2023-09-26 00:00:00
155+
end: 2023-10-26 00:00:00
156+
period: 1h
157+
basePeriod: 15m
158+
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
159+
*/
160+
161+
//@version=5
162+
//by Genma01
163+
strategy("Stratégie tradosaure 1 Bougie Rouge suivi de 3 Bougies Vertes", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
164+
165+
// Définir les paramètres
166+
var float stopLossPrice = na
167+
var float takeProfitPrice = na
168+
var float stopLossPriceD = na
169+
var float takeProfitPriceD = na
170+
171+
// Vérifier les conditions
172+
redCandle = close[3] < open[3] and low[3] < low[2] and low[3] < low[1] and low[3] < low[0]
173+
greenCandles = close > open and close[1] > open[1] and close[2] > open[2]
174+
higherClose = close > close[1] and close[1] > close[2]
175+
176+
// Calcul du stop-loss
177+
if (redCandle and greenCandles and higherClose) and strategy.position_size == 0
178+
stopLossPrice := low[3]
179+
180+
// Calcul du take-profit
181+
if (not na(stopLossPrice)) and strategy.position_size == 0
182+
takeProfitPrice := close + (close - stopLossPrice)
183+
184+
// Entrée en position long
185+
if (redCandle and greenCandles and higherClose) and strategy.position_size == 0
186+
strategy.entry("Long", strategy.long)
187+
188+
// Sortie de la position
189+
if (not na(stopLossPrice)) and strategy.position_size > 0
190+
strategy.exit("Take Profit/Stop Loss", stop=stopLossPrice, limit=takeProfitPrice)
191+
192+
if strategy.position_size == 0
193+
stopLossPriceD := na
194+
takeProfitPriceD := na
195+
else
196+
stopLossPriceD := stopLossPrice
197+
takeProfitPriceD := takeProfitPrice
198+
199+
200+
// Tracer le stop-loss et le take-profit sur le graphique
201+
plotshape(series=redCandle and greenCandles and higherClose and strategy.position_size == 0, title="Conditions Remplies", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
202+
plotshape(series=redCandle and greenCandles and higherClose and strategy.position_size == 0, title="Conditions Remplies", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
203+
204+
205+
// Afficher les prix du stop-loss et du take-profit
206+
plot(stopLossPriceD, color=color.red, title="Stop Loss Price", linewidth=2, style = plot.style_linebr)
207+
plot(takeProfitPriceD, color=color.green, title="Take Profit Price", linewidth=2, style = plot.style_linebr)
208+
209+
```
210+
211+
> Detail
212+
213+
https://www.fmz.com/strategy/430364
214+
215+
> Last Modified
216+
217+
2023-10-27 16:00:41
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
2+
> Name
3+
4+
123反转与费希尔变换指标组合策略123-Reversal-and-Fisher-Transform-Indicator-Combo-Strategy
5+
6+
> Author
7+
8+
ChaoZhang
9+
10+
> Strategy Description
11+
12+
13+
[trans]
14+
本策略名称为“123反转与费希尔变换指标组合策略”。该策略集成应用123反转形态判定和费希尔变换指标,在两者发出共同信号时进行买入或卖出。
15+
16+
123反转形态指价格连续三日形成高低缺口,第三日收盘反转前两日趋势的形态。根据统计,123反转的交易获利率较高。
17+
18+
费希尔变换指标对价格作正态化处理,当变换曲线出现突破极值点时,可以有效识别价格反转点。
19+
20+
交易逻辑如下:
21+
22+
1. 123反转形态显示买入信号或卖出信号。
23+
24+
2. 费希尔变换曲线显示买入或卖出信号。
25+
26+
3. 当两者发出同向信号时,进行相应的买入或卖出交易。
27+
28+
4. 当两者发出反向信号时,保持空仓。
29+
30+
该策略的优势在于指标组合可以提高对价格反转时点的判断准确性。但参数优化仍然关键,需要严格的资金管理。
31+
32+
总体来看,指标集成应用可以形成更全面的分析角度。但交易者仍需保持足够的灵活性,根据市场情况进行策略调整。
33+
34+
35+
||
36+
37+
This strategy is named “123 Reversal and Fisher Transform Indicator Combo Strategy”. It incorporates the 123 reversal pattern and Fisher transform indicator, entering trades when both give concurring signals.
38+
39+
The 123 reversal pattern refers to prices gaping significantly over three consecutive days with the third day closing in the opposite direction of the previous two days. Statistically, 123 reversals have higher win rates.
40+
41+
The Fisher transform indicator normalizes prices into a Gaussian-like curve, and its extreme swing turning points can effectively identify price reversals.
42+
43+
The trading logic is:
44+
45+
1. The 123 reversal pattern shows buy or sell signals.
46+
47+
2. The Fisher transform curve shows buy or sell signals.
48+
49+
3. When the two give concurring signals, the corresponding buy or sell trades are taken.
50+
51+
4. When the two give opposing signals, positions are kept flat.
52+
53+
The advantage of this strategy is the indicator combo can improve judgment accuracy of reversal timing. But parameter optimization is still crucial, and rigorous money management is a must.
54+
55+
In conclusion, indicator integration forms a more comprehensive analytical perspective. But traders still need sufficient discretion to adjust strategies based on market conditions.
56+
57+
[/trans]
58+
59+
> Strategy Arguments
60+
61+
62+
63+
|Argument|Default|Description|
64+
|----|----|----|
65+
|v_input_1|15|Length|
66+
|v_input_2|true|KSmoothing|
67+
|v_input_3|3|DLength|
68+
|v_input_4|50|Level|
69+
|v_input_5|10|LengthFTI|
70+
|v_input_6|false|Trade reverse|
71+
72+
73+
> Source (PineScript)
74+
75+
``` javascript
76+
/*backtest
77+
start: 2023-08-13 00:00:00
78+
end: 2023-09-12 00:00:00
79+
period: 4h
80+
basePeriod: 15m
81+
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
82+
*/
83+
84+
//@version=4
85+
////////////////////////////////////////////////////////////
86+
// Copyright by HPotter v1.0 28/08/2020
87+
// This is combo strategies for get a cumulative signal.
88+
//
89+
// First strategy
90+
// This System was created from the Book "How I Tripled My Money In The
91+
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
92+
// The strategy buys at market, if close price is higher than the previous close
93+
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
94+
// The strategy sells at market, if close price is lower than the previous close price
95+
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
96+
//
97+
// Second strategy
98+
// Market prices do not have a Gaussian probability density function
99+
// as many traders think. Their probability curve is not bell-shaped.
100+
// But trader can create a nearly Gaussian PDF for prices by normalizing
101+
// them or creating a normalized indicator such as the relative strength
102+
// index and applying the Fisher transform. Such a transformed output
103+
// creates the peak swings as relatively rare events.
104+
// Fisher transform formula is: y = 0.5 * ln ((1+x)/(1-x))
105+
// The sharp turning points of these peak swings clearly and unambiguously
106+
// identify price reversals in a timely manner.
107+
//
108+
// WARNING:
109+
// - For purpose educate only
110+
// - This script to change bars colors.
111+
////////////////////////////////////////////////////////////
112+
Reversal123(Length, KSmoothing, DLength, Level) =>
113+
vFast = sma(stoch(close, high, low, Length), KSmoothing)
114+
vSlow = sma(vFast, DLength)
115+
pos = 0.0
116+
pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
117+
iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0)))
118+
pos
119+
120+
121+
FTI(Length) =>
122+
pos = 0
123+
nValue1 =0.0
124+
nFish = 0.0
125+
xHL2 = hl2
126+
xMaxH = highest(xHL2, Length)
127+
xMinL = lowest(xHL2,Length)
128+
nValue1 := 0.33 * 2 * ((xHL2 - xMinL) / (xMaxH - xMinL) - 0.5) + 0.67 * nz(nValue1[1])
129+
nValue2 = iff(nValue1 > .99, .999,
130+
iff(nValue1 < -.99, -.999, nValue1))
131+
nFish := 0.5 * log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
132+
pos := iff(nFish > nz(nFish[1]), 1,
133+
iff(nFish < nz(nFish[1]), -1, nz(pos[1], 0)))
134+
pos
135+
136+
strategy(title="Combo Backtest 123 Reversal & Fisher Transform Indicator", shorttitle="Combo", overlay = true)
137+
Length = input(15, minval=1)
138+
KSmoothing = input(1, minval=1)
139+
DLength = input(3, minval=1)
140+
Level = input(50, minval=1)
141+
//-------------------------
142+
LengthFTI = input(10, minval=1)
143+
reverse = input(false, title="Trade reverse")
144+
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
145+
posFTI = FTI(LengthFTI)
146+
pos = iff(posReversal123 == 1 and posFTI == 1 , 1,
147+
iff(posReversal123 == -1 and posFTI == -1, -1, 0))
148+
possig = iff(reverse and pos == 1, -1,
149+
iff(reverse and pos == -1 , 1, pos))
150+
if (possig == 1)
151+
strategy.entry("Long", strategy.long)
152+
if (possig == -1)
153+
strategy.entry("Short", strategy.short)
154+
if (possig == 0)
155+
strategy.close_all()
156+
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )
157+
```
158+
159+
> Detail
160+
161+
https://www.fmz.com/strategy/426618
162+
163+
> Last Modified
164+
165+
2023-09-13 17:35:36

15MIN-BTCUSDTPERP-BOT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
> Author
77
8-
张超
8+
ChaoZhang
99

1010
> Strategy Description
1111

0 commit comments

Comments
 (0)