DAS Trader Pro Advanced Hotkeys part 32
Automated trades posting to a discord channel
If you want to go full transparency with your fellow traders, this post will show you how to post all your trades to a discord channel.
The objective
post all trades to a discord channel
post the direction of the trades
Requirements
a Discord server
a Discord channel with a webhook
DAS Trader Pro 3.8.0.x
named chart window (MY1MIN in my case)
named montage window (MONTAGE1 in my case)
If you are going to post to your own discord server, you can retrieve the webhook URL of the channel yourself, otherwise ask the server administrator to provide you with the webhook URL from the Integrations section of the channel where you are allowed to post the trades.
Logical Steps
prepare the external script to post to the Discord channel
read the current position
determine if we are opening or closing the position
assemble the trade data to a variable
post the variable to an external script as a parameter
The external script
I am using PowerShell as it is an integral part of any windows operating system.
# Define a parameter block
param (
[string]$Tradeparams
)
# Output the parameter value (for testing/debugging)
#Write-Host "Tradeparams: $Tradeparams"
# Example use of the parameter
$webhookUrl = "https://discord.com/api/webhooks/1373328296/wJSz6U12gf2tNpv4gavYS-2o26PGrnQSqKF3Yh222M4sPLxsWnC545RG0uSwbV5MZcD"
$headers = @{ "Content-Type" = "application/json" }
$body = '{"content":"Peter: '+$Tradeparams +'"}'
$body | Out-File -FilePath "C:\temp\Output.txt" -Append
try {
Invoke-WebRequest -Uri $webhookUrl -Method Post -Headers $headers -Body $body
} catch {
Write-Host "Failed to send the message: $($_.Exception.Message)" -ForegroundColor Red | Out-File -FilePath "C:\temp\Output.txt" -Append
exit 1
}
edit the name in the file - replace Peter: with anything you like and save the file in C:\temp\discord2.ps1
edit the webhookUrl and change it for your own URL
If you want another path for storing the thing, you need to edit the path both in the powershell script above and the hotkey below
The hotkey
the hotkey will be called in an alert, so you need to create the montage object variable. I do it in a chart update script in my 1-min chart window like this together with other variables
$MYMONTAGE=GetWindowObj("MONTAGE1");
$MY1MINWINDOW=GetWindowObj("MY1MIN");
$MYSYMB=$MY1MINWINDOW.SYMBOL; $MYPOS=GetAccountObj($MYACCOUNT).getposition($MYSYMB).share;
$MYACCOUNT is the account name you trade.
Save the below hotkey and name it discrodpost.
Keep reading with a 7-day free trial
Subscribe to Peter’s Substack to keep reading this post and get 7 days of free access to the full post archives.