TradingView
HPotter
19 sept. 2023 11:21

OKX: MA Crossover 

BTCUSDT Perpetual Swap ContractOKX

Description

EXAMPLE Scripte from my stream , how to use OKX webhooks for create strategy on Pine with real\demo trading on your OKX account. This strategy only for test the functional forward orders to OKX. The backtest not included commisions and other.

OKX MA Crossover. This strategy generate JSONs for place orders on the exchange by alerts and webhooks.

In the script 2 function to generate entry and exit orders, and input parameters that needed for setup exchange.

Use it for test this stack and to write you own strategy for trade on the OKX Exchange.
Commentaires
TVQuant
给OKX赚手续费策略,设置0.05手续费后,稳定亏钱,跑起来亏手续费
HPotter
@TVQuant, It is example for learning. I'll post more working ideas soon.
mozbakir
thank you with best wishes! ...working codes..
grcryptotrade
Thanks for the script, and info! I am a user of OKX and TV very helpful, just was not aware that Signal bot can connect TV for auto trading. Will give it a try. Best wishes!
HPotter
@grcryptotrade, You are welcome! See my streams for more details.
facejungle
str := str + '"timestamp": "' + '{{timenow}}' + '", '
this not work, i'm use:
str := str + '"timestamp": "' + str.format_time(time_close, "yyyy-MM-dd'T'HH:mm:ssZ", "UTC+0") + '", '
HPotter
@facejungle, It is not work if you use in the Alert function. For alert yes, you should to use second line. But for alerts from strategy should be like in an example.
facejungle
@HPotter, If you use this example, then the exchange "OKX" will not receive a signal.
Since "JSON" is sent in the header - {timestamp}.
Have you tried testing your code?
facejungle
@facejungle, * Because the header is sending "JSON" - the string {{timenow}}.
HPotter
@facejungle, It is working if alert will be in the order. Then {{timenow}} will changed on the timeshtamp
Plus