Demabot Indicator
Demabot Indicator
0 at
https://mozilla.org/MPL/2.0/
// © zeguela
//@version=4
strategy(title="ZEGUELA DEMABOT", commission_value=0.063,
commission_type=strategy.commission.percent, initial_capital=100,
default_qty_value=90, default_qty_type=strategy.percent_of_equity, overlay=true,
process_orders_on_close=true)
// Input options
srcData = input(title="Source Data", type=input.source, defval=close)
// Length settings
len1 = input(title="Length DEMA #1", type=input.integer, defval=8, minval=1)
len2 = input(title="Length DEMA #2", type=input.integer, defval=24, minval=0)
len3 = input(title="Length DEMA #3", type=input.integer, defval=0, minval=0)
longStopPriceTrail = 0.0
price_entryL = 0.0
price_entryL := na(price_entryL) ? na : price_entryL[1]
price_entryS = 0.0
price_entryS := na(price_entryS) ? na : price_entryS[1]
stopL = 0.0
stopL := na(stopL) ? na : stopL[1]
stopS = 0.0
stopS := na(stopS) ? na : stopS[1]
takeL = 0.0
takeL := na(takeL) ? na : takeL[1]
takeS = 0.0
takeS := na(takeS) ? na : takeS[1]
if (demaCrossover)
price_entryL := close
stopL := close * (1 - stopPerlong)
takeL := close * (1 + take1Perlong)
if (demaCrossunder)
price_entryS := close
stopS := close * (1 + stopPershort)
takeS := close * (1 - take1Pershort)
//Alert configuration
_alertMessageOpenLong="OpenLong"
_alertMessageCloseLong="CloseLong"
_alertmessageExitLong="ExitLong"
_alertmessageTPLong="TakeProfitLong"
_alertMessageOpenShort="OpenShort"
_alertMessageCloseShort="CloseShort"
_alertMessageTPShort="TakeProfitShort"
_alertMessageExitShort="ExitShort"
// Step 7. Strategy Execution
if (_inDateRange)
//ENTER SOME SETUP TRADES FOR TSL EXAMPLE
if (demaCrossover)
strategy.entry("LONG", strategy.long, comment = "OPEN LONG",
alert_message=_alertMessageOpenLong)
strategy.exit(id="Close Long TP1", stop=stopL, limit=takeL, comment="CLOSE
LONG", alert_message=_alertmessageExitLong)
if (demaCrossunder)
strategy.entry("SHORT", strategy.short, comment = "OPEN SHORT",
alert_message=_alertMessageOpenShort)
strategy.exit(id="Close Short TP1", stop=stopS, limit=takeS, comment="CLOSE
SHORT", alert_message=_alertMessageExitShort)
//EXIT TRADE @ TSL
if strategy.position_size > 0
strategy.exit("TP/SL", "LONG", stop=longStop, limit=longTake1Price,
comment="EXIT LONG", alert_message=_alertmessageExitLong)
if strategy.position_size < 0
strategy.exit("TP/SL", "SHORT", stop=shortStop, limit=shortTake1Price,
comment ="EXIT SHORT", alert_message=_alertMessageExitShort)
if strategy.position_size < 0