// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CryptoRox
//@version=4
strategy("Bitget - Strategy Alerts", "Bitget", overlay=true, pyramiding=1, precision=2)
market = input(title="Market Type", defval="Contracts - Simulation", options=["Exchange", "Contracts - Real Trading", "Contracts - Simulation"])
testStartYear = input(200 , "Start Year")
testStartMonth = input(6, "Start Month")
testStartDay = input(20, "Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testPeriod() =>
time >= testPeriodStart ? true : false
ticker = syminfo.ticker
sma1Input = input(50, "SMA")
sma2Input = input(200, "SMA")
src = close
sma1 = sma(src, sma1Input)
sma2 = sma(src, sma2Input)
profit = 0.0
loss = 0.0
tp = input(0.1, "Take Profit %")/100
sl = input(0.1, "Stop Loss %")/100
avg = strategy.position_avg_price
size = strategy.position_size
contracts = strategy.equity / 100
// strategy.cancel_all()
longCondition = crossover(sma1, sma2)
shortCondition = crossunder(sma1, sma2)
if testPeriod()
if market == "Exchange"
if (longCondition)
strategy.entry("Buy", 1, alert_message='Exchange | e=bitget s=btc_usdt b=sell c=order | e=bitget s=btc_usdt b=buy q=0.0001 p=-10%')
if (shortCondition)
size := size * -1
strategy.entry("Sell", 0, alert_message='Exchange | e=bitget s=btc_usdt b=buy c=order | e=bitget s=btc_usdt b=sell q=0.0001 p=10%')
if size > 0
profit := avg+avg * tp
loss := avg-avg * sl
strategy.exit("Buy Exit", "Buy", limit=profit, stop=loss, alert_message='Exchange | e=bitget s=btc_usdt b=buy c=order | e=bitget s=btc_usdt b=sell q=0.0001 t=market')
if size < 0
profit := avg-avg * tp
loss := avg+avg * sl
strategy.exit("Sell Exit", "Sell", limit=profit, stop=loss, alert_message='Exchange | e=bitget s=btc_usdt b=sell c=order | e=bitget s=btc_usdt b=buy q=0.0001 t=market')
if market == "Contracts - Real Trading"
if (longCondition)
strategy.entry("Long", 1, alert_message='Real Trading | e=bitget s=cmt_btcusdt b=short c=order | e=bitget s=cmt_btcusdt b=short c=position t=market | e=bitget s=cmt_btcusdt b=long q=1 t=market')
if (shortCondition)
size := size * -1
strategy.entry("Short", 0, alert_message='Real Trading | e=bitget s=cmt_btcusdt b=long c=order | e=bitget s=cmt_btcusdt b=long c=position t=market | e=bitget s=cmt_btcusdt b=short q=1 t=market')
if size > 0
profit := avg+avg * tp
loss := avg-avg * sl
strategy.exit("Long Exit", "Long", limit=profit, stop=loss, alert_message='Real Trading | e=bitget s=cmt_btcusdt b=long c=position ps=position ftp=' + tostring(profit) + ' | e=bitget s=cmt_btcusdt b=long c=position ps=position fsl=' + tostring(loss))
if size < 0
profit := avg-avg * tp
loss := avg+avg * sl
strategy.exit("Short Exit", "Short", limit=profit, stop=loss, alert_message='Real Trading | e=bitget s=cmt_btcusdt b=short c=position ps=position ftp=' + tostring(profit) + ' | e=bitget s=cmt_btcusdt b=short c=position ps=position fsl=' + tostring(loss))
if market == "Contracts - Simulation"
if (longCondition)
strategy.entry("Long", 1, alert_message='Simulated Trading | e=bitget s=sbtcusd b=short c=order | e=bitget s=sbtcusd b=short c=position t=market | e=bitget s=sbtcusd b=long q=100 t=market')
if (shortCondition)
size := size * -1
strategy.entry("Short", 0, alert_message='Simulated Trading | e=bitget s=sbtcusd b=long c=order | e=bitget s=sbtcusd b=long c=position t=market | e=bitget s=sbtcusd b=short q=100 t=market')
if size > 0
profit := avg+avg * tp
loss := avg-avg * sl
strategy.exit("Long Exit", "Long", limit=profit, stop=loss, alert_message='Simulated Trading | e=bitget s=sbtcusd b=long c=position ps=position ftp=' + tostring(profit) + ' | e=bitget s=sbtcusd b=long c=position ps=position fsl=' + tostring(loss))
if size < 0
profit := avg-avg * tp
loss := avg+avg * sl
strategy.exit("Short Exit", "Short", limit=profit, stop=loss, alert_message='Simulated Trading | e=bitget s=sbtcusd b=short c=position ps=position ftp=' + tostring(profit) + ' | e=bitget s=sbtcusd b=short c=position ps=position fsl=' + tostring(loss))
//Put this in your alert message: {{strategy.order.alert_message}}
Comments
0 comments
Article is closed for comments.