Comments (11)
- Margin trade (define margin level) with the order
in actions.py, you change the order line to:
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']), { 'leverage': data["leverage"] })
from tradingview-webhooks-bot.
- Stop loss order
This works and also with margin.
This is how I used it in "Tradingview alert message:
{"type": "stop-loss", "side": "sell", "amount": "100", "symbol": "BCH/EUR", "price": "321", "leverage": "2", "key": "yourkeyhere"}
from tradingview-webhooks-bot.
@JDJoe https://github.com/Robswc/tradingview-webhooks-bot/tree/lda/webhook-bot
from tradingview-webhooks-bot.
Interesting. BTW, I can barely read code (I am not a programmer) but do I understand it correctly, you have moved the stop loss calculation to the bot side?
Not sure, if this is a good idea because this information should come from the strategy running on TradingView and it can be different for trading pairs. For example, I use volatility to calculate the possible SL and it's not a % percentage from last price.
I personally hope this bot remains as dumb as possible - only facilitate outside commands.
Maybe, in the future, it should be able to check did your limit order get filled and if not, do something about it.
from tradingview-webhooks-bot.
@JDJoe At the time I wrote it PineScript was still very limited in what info it can pass on (variables). If you look closely you'll see a file called talib.py which I never got around to. Had some personal issues to deal with the past 3 months. Ideally you'd want to calculate stop losses server-side, as even a few seconds can make a huge difference. The hard part is getting a constant stream of reliable data without any downtime, which TV is particularly good at. There's many ways to approach this I guess
from tradingview-webhooks-bot.
Most of the requests here can be done within the bot's "send order" action (as it was intended) BUT I am working on a branch that will allow for "blueprints" of sorts. It's been awhile since I worked with this bot, so I might get it wrong but for the following:
Stop Loss & Take Profit:
Should be possible by setting it to "StopLimit" or "StopMarket". Take profit can be done with a limit order, set to POST only, or "ParticipateDoNotInitiate" in the custom parameters. It should be possible, something like this:
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']), params={'execInst': 'ParticipateDoNotInitiate'})
The bot is basically a ccxt trigger that runs when it gets a TV alert.
I could add the ability to cancel orders made by the bot, I would say this might not be totally efficient though, as it would have to grab the order ID from the exchange, then there would also have to be a way for the alert to know which order you're trying to cancel. It could be "last order" or "3rd from last" etc. Beyond that though would be a bit difficult.
You could do multiple orders even, if you want. Getting price:
exchange.fetch_ticker('XBTUSD')) for example. Then just run your stop/profit formula, and copy the "order = exchange..." to create 3 orders, essentially a bracket order.
Let me know how it works out!
from tradingview-webhooks-bot.
- Take profit
You can do this right now if you use limit order. This will give you a little kickback on fees too.
So, When going short, place limit buy order at what ever level below the current market and opposite for the long position - limit sell at something above the market.
To keep it simple:
When entering a new order:
- Cancel all open orders for the symbol XYZ (get rid of your previously placed SL, TP etc)
- Place your new order for symbol XYZ (market, limit, stop)
- Place new take profit ((stop) limit sell or buy) for XYZ at some price level.
What is really important is to execute all this in one single TradingView message so it can be processed in correct order.
Because the "key" is really long, TV wont be able to handle 3 x key + orders in one message.
from tradingview-webhooks-bot.
Ah, I see. I'm currently working on a new version that allows for placing a take profit and stop with one alert, it might only work with market orders to start though.
In the mean time, try seeing if this works:
order1 = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']))
order2 = exchange.create_order(data['symbol'], 'stopLoss', ('sell' if data['side'] == 'buy' else 'buy'), data['amount'], data['takeProfitPrice']))
order3 = exchange.create_order(data['symbol'], 'takeProfit', ('sell' if data['side'] == 'buy' else 'buy'), data['amount'], data['stopLossPrice']))
Off the top of my head, so it might not work.
Just add the "takeProfitPrice": "{{something}}"
In the tradingview alert to get that data to the bot.
from tradingview-webhooks-bot.
I'm currently working on a new version that allows for placing a take profit and stop with one alert
Sounds good. I'll be waiting. I'll be more than happy to help you test it.
Stop and take profit already works but there is no way to submit multiple orders at once.
from tradingview-webhooks-bot.
How's the new version looking? :)
from tradingview-webhooks-bot.
Any news about the new version?
from tradingview-webhooks-bot.
Related Issues (20)
- I checked ccxt predefined Brokers, all for Crypto. I will try out if it will still work for Ampfutures, a Question! HOT 7
- Warning: Python 3.7 was not found on your system… HOT 3
- flask issue
- Bitmex testnet HOT 2
- File "<unknown>", line 1 HOT 3
- Use % of available funds HOT 2
- COMPLETE INSTRUCTIONS ON SET UP HOT 5
- Wiki Content and Guides HOT 4
- How to get reduce_only to work on bybit HOT 1
- Worker timeout HOT 9
- Add password protection/authentication/key to home page/GUI HOT 1
- Specify that the key contains the name of the event
- Add ability to start/stop events
- Add models for events/actions
- Add more "community actions"
- Default configuration doesn't run on Docker for Windows
- TradingView bot
- Wondering if this can handle multiple requests at once? HOT 3
- Conflict Jinga vs flask in requirements HOT 2
- How to contact you?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tradingview-webhooks-bot.