junta / tradingview-alert-connector

Integrating TradingView strategy alert and executing automated trading for futures DEXes
https://tv-connector.gitbook.io/docs/
MIT License
76 stars 42 forks source link

strategydata undefined #6

Closed adrien44 closed 1 year ago

adrien44 commented 1 year ago

Hi, Thank a lot for your work.

I tried your web service but I can not make it works perfectly. It follows my alert but sometimes I get this error which break my strategy :

strategyData undefined /app/dist/services/validateAlert.js:5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ^ TypeError: Cannot read properties of undefined (reading 'isFirstOrder') at /app/dist/services/validateAlert.js:92:41 at Generator.next (<anonymous>) at fulfilled (/app/dist/services/validateAlert.js:5:58) at processTicksAndRejections (node:internal/process/task_queues:96:5) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. yarn run v1.22.18 $ tsc && NODE_ENV=production ts-node dist/index.js TV-Connector web server listening on port 10000

Can you help me understand it ? Thanks for your time

junta commented 1 year ago

Hi, At where are you hosting this tool? Render.com?

adrien44 commented 1 year ago

Yes. I followed your tuto and did exactly the same.

adrien44 commented 1 year ago

the tradingview strategy is fairly simple. Only long position. Only one trade at a time. Buy then sell and so on.

junta commented 1 year ago

I see, Have you set up the Disk feature on Render.com? https://tv-connector.gitbook.io/docs/setuup/run-on-cloud-service

Screen Shot 2023-02-10 at 11 18 32
adrien44 commented 1 year ago

Yes Screenshot_20230210-034447_Chrome

junta commented 1 year ago
  1. What is your strategy name?
  2. Can you redeploy the code to your web service?

at your web service page of Render.com, go to Manual deploy -> deploy latest commit

Screen Shot 2023-02-10 at 11 52 57
adrien44 commented 1 year ago

Do the strategy name must match something ? My strategy name on trading view was BOT ETH/USD, I gave the alert the same name. I already redeployed the code and even recreated a web service from scratch. (Yesterday)

junta commented 1 year ago

No, the strategy name does not need to be matched something. Could you try changing your strategy name to "BOT ETHUSD", for example? remove "/" from your strategy name.

adrien44 commented 1 year ago

I will try that and get back to you. Thanks

adrien44 commented 1 year ago

Hi Junta, I just re-start a strategy after removing "/" in the name as you suggested. So far, it's working (following correctly the orders from tradingview strategy). I will let it run for a few days and keep you posted on the results.

adrien44 commented 1 year ago

Hi, 4 days and everything works great. Thanks for your time on this !

adrien44 commented 1 year ago

I just run into another error probably because i don't use correctly your system. Is it possible to set alert of 2 differents currency on the same service ?

I created an alert for ETH and another for AVAX using the same webhook. The first trade has been trigger at the same time for my 2 strategies.
It worked great.

But just now, an alert for one of the two strategy was triggered but the order didn't executed. The log indicate that it has been identify as a first order whereas it isn't.

Feb 23 04:00:10 PM Recieved Tradingview strategy alert: { Feb 23 04:00:10 PM exchange: 'dydx', Feb 23 04:00:10 PM strategy: 'Bot AVAXUSD', Feb 23 04:00:10 PM market: 'AVAX_USD', Feb 23 04:00:10 PM size: '99.393', Feb 23 04:00:10 PM reverse: false, Feb 23 04:00:10 PM order: 'sell', Feb 23 04:00:10 PM position: 'flat', Feb 23 04:00:10 PM price: '19.96', Feb 23 04:00:10 PM passphrase: '' Feb 23 04:00:10 PM } Feb 23 04:00:11 PM strategyData { reverse: false, isFirstOrder: 'true' } Feb 23 04:00:11 PM this alert is first and close order, so does not create a new order.

Thanks for your time

junta commented 1 year ago

Yes, you can set alert of 2 different currencies on the same service.

Do you give a different strategy name to ETH and AVAX bot?

adrien44 commented 1 year ago

I used the same script name "Bot crypto" but created 2 alerts.

First one name : Bot AVAX with this message : { "exchange": "dydx", "strategy": "Bot AVAXUSD", "market": "AVAX_USD", "size": "{{strategy.order.contracts}}", "reverse": false, "order": "{{strategy.order.action}}", "position": "{{strategy.market_position}}", "price": "{{strategy.order.price}}", "passphrase": "" }

Second one : Bot ETH with this message { "exchange": "dydx", "strategy": "Bot ETHUSD", "market": "ETH_USD", "size": "{{strategy.order.contracts}}", "reverse": false, "order": "{{strategy.order.action}}", "position": "{{strategy.market_position}}", "price": "{{strategy.order.price}}", "passphrase": "" }

junta commented 1 year ago

Hmm, I don't get why this happens. Could you try several other alerts triggered with a minimum amount and check whether the same error happens?

adrien44 commented 1 year ago

Ok, I will test it and get back to you