Professional Documents
Culture Documents
0 at
https://mozilla.org/MPL/2.0/
// © liaodinghai
//@version=5
strategy(title='饥饿者~01', overlay=true,
pyramiding=0, default_qty_type=strategy.cash,
default_qty_value=1, initial_capital=100,
currency=currency.USD, commission_value=0.05,
commission_type=strategy.commission.percent,
process_orders_on_close=true)
//对上面这段话的解释:策略标题(名字)“”,显示在图表(主图),pyramiding=0 只能在同一方向上开
单,......
enterShortComment = ""
exitShortComment = ""
longTPSL = ""
longTP = ""
longSL = ""
shortTPSL = ""
shortTP = ""
shortSL = ""
if long == true
stopLine := kf - (kf * (stopPercent / 100))
else
stopLine := kf + (kf * (stopPercent / 100))
if strategy.position_size < 0
if close < strategy.position_avg_price
isLastProfit := true
else if strategy.position_size == 0
if strategy.wintrades > winCounter //strategy.wintrades[ barindex ]
isLastProfit := true
else
isLastProfit := false
if strategy.position_size > 0
if close > strategy.position_avg_price
isLastProfit := true
else if strategy.position_size == 0
if strategy.wintrades > winCounter //strategy.wintrades[ barindex ]
isLastProfit := true
else
isLastProfit := false
else if longEntry
if sellSignall
winCounterBuffer := winCounter
if buySignall
if winCounter > winCounterBuffer
isLastProfit := true
else
isLastProfit := false
else if shortEntry
if buySignall
winCounterBuffer := winCounter
if sellSignall
if winCounter > winCounterBuffer
isLastProfit := true
else
isLastProfit := false
if buySignall or sellSignall
if isLastProfit == false
else
orderQty := baseOrderQty
tp1 := baseTP1
tp2 := baseTP2
tp3 := baseTP3
if long
strategy.close_all( when = buySignall, comment = exitShortComment)
strategy.entry("LONG", strategy.long, when = buySignall,
qty=math.min(orderQty, maxOrderQty), comment = enterLongComment)
stoppedOutLong := true
stoppedOutShort := false
else
strategy.close_all(when=sellSignall, comment = exitLongComment)
strategy.entry("SHORT", strategy.short, when = sellSignall,
qty=math.min(orderQty, maxOrderQty), comment = enterShortComment)
stoppedOutLong := false
stoppedOutShort := true
else if(longEntry)
strategy.entry("LONG", strategy.long, when = buySignall,
qty=math.min(orderQty, maxOrderQty), comment = enterLongComment)
strategy.close("LONG", when = sellSignall, comment = exitLongComment)
if long
stoppedOutLong := true
stoppedOutShort := false
else
stoppedOutLong := false
stoppedOutShort := true
else if(shortEntry)
strategy.entry("SHORT", strategy.short, when = sellSignall,
qty=math.min(orderQty, maxOrderQty), comment = enterShortComment)
strategy.close("SHORT", when = buySignall, comment = exitShortComment)
if not long
stoppedOutShort := true
stoppedOutLong := false
else
stoppedOutShort := false
stoppedOutLong := true
longSafeStopPrice1 = stopLine
shortSafeStopPrice1 = stopLine
if strategy.position_size < 0
if(initialStopLoss>0.0)
if ( strategy.position_size > 0 )
strategy.exit(id="LONG", stop=longStopPrice, comment = "Long Stop Loss")
if buySignall or sellSignall
isTakeTP1 := false
isTakeTP2 := false
isTakeTP3 := false
winCounter := strategy.wintrades