Professional Documents
Culture Documents
demabot_indicator_KSM_2H
demabot_indicator_KSM_2H
demabot_indicator_KSM_2H
0 at
https://mozilla.org/MPL/2.0/
// © zeguela
//@version=4
strategy(title="[BOT] KSM 2H 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="KSMFTX(KSM-PERP) { cancel(which=all); wait(3s);
market(side=buy, amount=90%); wait(10s); limit(position=0, postOnly=false,
offset=@" + tostring(longTPEntrada) + "); stopMarket(position=0, offset=@" +
tostring(longStopEntrada) + ")}"
_alertMessageCloseLong="KSMFTX(KSM-PERP) { cancel(which=all);
continue(if=positionLong); market(position=0);}"
_alertmessageExitLong="KSMFTX(KSM-PERP) { wait(3s);
cancel(which=all);trailingLimit(position=0, minOffset=0.01%, maxOffset=0.03%,
reduceOnly=true);}"
_alertMessageOpenShort="KSMFTX(KSM-PERP) {cancel(which=all); wait(3s);
market(side=sell, amount=90%); wait(10s); limit(position=0, postOnly=false,
offset=@" + tostring(shortTPEntrada) + "); stopMarket(position=0, offset=@" +
tostring(shortStopEntrada) + ")}"
_alertMessageCloseShort="KSMFTX(KSM-PERP) { cancel(which=all);
continue(if=positionShort); market(position=0);}"
_alertMessageExitShort="KSMFTX(KSM-PERP) { wait(3s);
cancel(which=all);trailingLimit(position=0, minOffset=0.01%, maxOffset=0.03%,
reduceOnly=true);}"
if strategy.position_size < 0