Reputation: 31
I have the below script to send a market order and I am logged into my broker in tradingview but when I attach the script to the chart I do not see any positions opened in my broker. Any help is appreciated.
strategy(title="Positions", overlay=true)
// Calculate moving averages
fastSMA = sma(close, 50)
slowSMA = sma(close, 200)
price=input(title="price", defval=3205.25, minval=1)
strategy.entry(id="EL", long=true)
Thank you in advance.
Upvotes: 3
Views: 6730
Reputation: 11
its so easy if you want to paper trading or real trade with automation and dynamic pine script with syntax then you can use NextLevelBOT platform. I share below dynamic script according to NextLevelBot Platform and now you can easily fully automation paper trading with below pine script.
if you want to know more about automation paper trading pls watch this video click here!
strategy("cci Strategy", overlay=true)
length = input( 14 )
overSold = input( 100 )
overBought = input( -100 )
_1 = input(true,"══════════ ADD Value ══════════")
// long_syntax = input("", "ADD LONG SYNTAX", input.string)
// Short_syntax = input("", "ADD SHORT SYNTAX", input.string)
ts = input("ADD SYMBOL INPUT", "TRADE SYMBOL", input.string)
exchange = input("NSE", "EXCHANGE", options=["NSE","NFO","MCX","OTHER"])
qty = input("25", "Quantity Value", input.string)
longEntry = '[{"E":"'+ exchange +'","TS":"'+ ts +'","PRICE":"' +tostring(close)+ '","CLOSE":"CLOSE","AT":"TRADINGVIEW"},{"E":"'+ exchange +'","TS":"'+ ts +'","PRICE":"' +tostring(close)+ '","Q":"'+ qty +'","TT":"BUY","AT":"TRADINGVIEW"}]'
shortEntry = '[{"E":"'+ exchange +'","TS":"'+ ts +'","PRICE":"' +tostring(close)+ '","CLOSE":"CLOSE","AT":"TRADINGVIEW"},{"E":"'+ exchange +'","TS":"'+ ts +'","PRICE":"' +tostring(close)+ '","Q":"'+ qty +'","TT":"SELL","AT":"TRADINGVIEW"}]'
price = close
vrsi = cci(price, length)
co = crossover(vrsi, overSold)
cu = crossunder(vrsi, overBought)
if (not na(vrsi))
if (co)
strategy.entry("RsiLE", strategy.long, alert_message=longEntry)
if (cu)
strategy.entry("RsiSE", strategy.short, alert_message=shortEntry)
// plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
// {{strategy.order.alert_message}}
makesure add this in alert message {{strategy.order.alert_message}}
Upvotes: 0
Reputation: 6905
This is currently not possible in TradingView.
The brokers with integration to TradingView can only be used for manual trading.
Exerpt from How to autotrade using Pine Script strategies:
Strategy trading is limited to the backtesting mode only. Automated strategy trading with a brokerage account is not available on TradingView yet. We are considering implementing this in the future.
There is a workaround though, but you'll need a 3rd party execution engine:
From PineCoders.com - Can my strategy generate orders through exchanges or brokers? :
No, because:
If you have a Pine strategy and want to automate it to place orders on markets, you will have to:
alertcondition()
calls in your indicator using your buy/sell conditions.alertcondition()
calls in your study using TV’s alert creation feature from charts (ALT-A).Points to consider
strategy.*()
calls which is implemented by the broker emulator used in TV backtesting, that logic will need to be handled in the conversion process, either through custom Pine code in your study or through delegation of the logic to the execution engine, if it supports those features, in which case you will need to use the appropriate syntax in your alert messages so the particular execution engine you are using understands how to execute your orders.The complexity of the conversion process between strategies and studies is the reason why we have developed our Backtesting and Trading Engine. Be sure to have a look at it.
Upvotes: 3