Oanda TDesk Drone - Artificial Hedging for U.S. Traders

Jonah
Trader
Posts: 46
Joined: Sat May 11, 2013 4:13 pm
Location: Las Vegas

Oanda TDesk Drone - Artificial Hedging for U.S. Traders

Post by Jonah »

What is this?
A trading dashboard that, by using two separate Oanda FXTrade trading accounts, provides U.S. TDesk traders the ability to use hedging in their trading strategies. This EA takes trades from TDesk and places them through the Oanda V20 API via a custom Python script. Although it does not have all of the features of Desky integrated yet, it is based on the same trade logic and shares some of the same code.

How does this work?
When a trade is triggered a file is written in the Empty4’s file folder. A separate Python script reads the file, performs the trade operation and returns a file that Empty4 can read.

What are the advantages of this EA?
  1. Provides traders the ability to trade any size. Trades can be as small as 1 unit. This would be the equivalent of 0.00001 within Empty4. This allows systems that trade a large number of pairs or trades to be run on a small account.
  2. Using 2 accounts, one for short trades and one for long trades, gives U.S. traders the ability to use a form of hedging. Since the accounts would vary in size over time, occasional rebalancing of accounts by transferring funds from one account to the other would be necessary.
  3. In the U.S. there are different margin requirements for each pair. This EA has the ability to automatically calculate lot sizes based on this and other variables.
Current features (In addition to Desky’s already great features):
  • Manages data from two separate accounts
  • Sends notifications via Empty4’s notification system
  • Monitors TDesk and the Python script to make sure both are running. If one stops, trading activity ceases.
  • Pause opening of new trades or all trading activity using the “AutoTrading” button.
  • Can use a set lot size or let the EA auto calculate lot sizes based on U.S. margin requirements using a risk based or max margin utilization method.
  • Can pause or manually trade any pair.
  • Displays current and past system messages on the dash
Features not yet implemented:
  • Basket trading
  • Grid trading
  • Recovery
  • Dollop lot sizes
  • Anything else I forgot to add
Dashboard.png
Python.png
FAQ

Is this usable on Oanda accounts outside the U.S.?
I have not verified this, but if the V20 API is the same I see no reason why it wouldn’t work.

This EA / Python Script / etc. does not work.
RTFM! I have spent a lot of time working on the attached manual. Follow everything exactly and it will work. I have used this setup on multiple computers and currently run it on an AWS cloud server without issue. If it doesn’t work for you, you have likely skipped a step or didn’t follow the instructions. Please check, and check again before asking for help.

Can you add ‘X’ feature?
I will gladly accept feature requests. If they are useful to myself and others and are possible to code without doing a complete rewrite, I would be happy to add them. Time permitting.

The Dashboard display is squished
You are likely on a high-resolution display. This is caused by Windows 10 scaling. Here is how to make it display correctly:
  1. Right click the Empty4 icon on your desktop
  2. Choose Properties
  3. Select the Compatibility tab
  4. Press “Change high DPI settings”
  5. Select “Override high DPI scaling behavior.”
  6. Change the dropdown to “System”
  7. Select “OK”
  8. Select “Apply”
  9. Close Property window and restart Empty4.
Notifications are not working correctly
The EA simply passes the message to Empty4’s notification system. So, if it is not working correctly the issue lies with Empty4 and cannot be fixed.

Changelog:

Version 1.01
BUG FIXED: Automatic trades were still being placed when a pair was set to manual mode
BUG FIXED: Automatic / Manual mode setting not being remembered on reload
BUG FIXED: New trades continued to be opened while AutoTrade button was not pressed

Version 1.02
BUG FIXED: Code to wait 10 seconds for TDesk was commented out
BUG FIXED: Incorrect logic when calculating time between hedge trades
You do not have the required permissions to view the files attached to this post.
Last edited by Jonah on Fri Feb 01, 2019 2:27 pm, edited 6 times in total.
-- Lonnie.

"Give a man a program, frustrate him for a day. Teach a man to program, frustrate him for a lifetime." (Muhammad Waseem)
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

Oanda TDesk Drone - Hedging for U.S. Traders

Post by tomele »

Hi Jonah.

A very astonishing piece of work. I am speechless.

Cheers
Thomas
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Oanda TDesk Drone - Hedging for U.S. Traders

Post by SteveHopwood »

Ditto. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

Jonah, you have no idea how good it makes me to see work of such brilliant quality happening at SHF. We really are an extraordinary bunch.

:xm: :rocket:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Jonah
Trader
Posts: 46
Joined: Sat May 11, 2013 4:13 pm
Location: Las Vegas

Oanda TDesk Drone - Hedging for U.S. Traders

Post by Jonah »

Thank you both so much for the kind words. I will enjoy it for now, but I am sure the bugs reports and installation issues will start rolling in after Christmas. :D

Now I just have to find a system to use with this for further testing. While developing I was using Wavegarrick's system and it performed very well. May have to stick with this one.

Have a Merry Christmas,
Lonnie.
-- Lonnie.

"Give a man a program, frustrate him for a day. Teach a man to program, frustrate him for a lifetime." (Muhammad Waseem)
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Oanda TDesk Drone - Hedging for U.S. Traders

Post by renexxxx »

Hi Jonah,

I want to congratulate you with a fantastic job of piecing this work together. You truly have an eye for detail and have come up with a solution that allows US traders that are crippled by FIFO rules to make use of TDesk/Desky.

I am curious about one aspect of your implementation: as I understand correctly, you copy trades generated by TDesk/Desky on a MT-4 account (any MT-4 account?), via Python and the Oanda V20 REST Api to two different Oanda V20 FXTrade accounts (one for BUYs and one SELLs).

It would also be possible to use (eg.) FXBlue Personal Trade Copier, where the sender is running on the MT-4 account that generates the trades and have two Oanda MT-4 Accounts (each running on a separate Oanda MT-4 terminal) for receiving the trades from the sender (one for BUYs and one for SELLs). I am not very familiar with Oanda and I would be curious to know if there would be a significant difference between trade execution of the two methods, but you probably have done this before and concluded that the Oanda REST Api is the way to go.

Once again .. bravo and chapeau :hi:
Jonah
Trader
Posts: 46
Joined: Sat May 11, 2013 4:13 pm
Location: Las Vegas

Oanda TDesk Drone - Hedging for U.S. Traders

Post by Jonah »

renexxxx » Sat Dec 22, 2018 7:59 pm wrote:Hi Jonah,

I want to congratulate you with a fantastic job of piecing this work together. You truly have an eye for detail and have come up with a solution that allows US traders that are crippled by FIFO rules to make use of TDesk/Desky.

I am curious about one aspect of your implementation: as I understand correctly, you copy trades generated by TDesk/Desky on a MT-4 account (any MT-4 account?), via Python and the Oanda V20 REST Api to two different Oanda V20 FXTrade accounts (one for BUYs and one SELLs).

It would also be possible to use (eg.) FXBlue Personal Trade Copier, where the sender is running on the MT-4 account that generates the trades and have two Oanda MT-4 Accounts (each running on a separate Oanda MT-4 terminal) for receiving the trades from the sender (one for BUYs and one for SELLs). I am not very familiar with Oanda and I would be curious to know if there would be a significant difference between trade execution of the two methods, but you probably have done this before and concluded that the Oanda REST Api is the way to go.

Once again .. bravo and chapeau :hi:
Thank you so much for your kind words.

You are correct. It would be possible to do it that way, but then you would still be tied to Empty4's trade sizing. In addition to hedging I created this so that I could trade any size no matter how small. Using Oanda's API, trades can be placed as small as 1 unit, or the equivalent of 0.00001 which is not possible in Empty4 world. I prefer to do my long term testing on very small live accounts which this solution allows for.
-- Lonnie.

"Give a man a program, frustrate him for a day. Teach a man to program, frustrate him for a lifetime." (Muhammad Waseem)
zafh
Trader
Posts: 74
Joined: Mon May 22, 2017 12:48 pm

Oanda TDesk Drone - Hedging for U.S. Traders

Post by zafh »

Forget all the other awesome stuff, the fact that you can use 1 unit and it is automated means anyone with any size account can use any of the proven systems without fear of a margin call.
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

Oanda TDesk Drone - Hedging for U.S. Traders

Post by tomele »

Given all this,

wouldn't an universal trade copier Empty4 Demo --> Oanda V20 API be the ultimate tool for trading with order sizes that perfectly fit our postulate #1 of "Never risk money you can't afford to lose"?

:) :) :)

Merry christmas
Thomas
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
zafh
Trader
Posts: 74
Joined: Mon May 22, 2017 12:48 pm

Oanda TDesk Drone - Hedging for U.S. Traders

Post by zafh »

Well you'd need the hedging part as well, IIRC it didn't let me hedge in the UK as it was built into the software, but, yes a great idea.
Jonah
Trader
Posts: 46
Joined: Sat May 11, 2013 4:13 pm
Location: Las Vegas

Oanda TDesk Drone - Hedging for U.S. Traders

Post by Jonah »

tomele » Sun Dec 23, 2018 8:40 am wrote:Given all this,

wouldn't an universal trade copier Empty4 Demo --> Oanda V20 API be the ultimate tool for trading with order sizes that perfectly fit our postulate #1 of "Never risk money you can't afford to lose"?

:) :) :)

Merry christmas
Thomas
Doesn't sound too difficult. The code is already there. If I am understanding correctly this would:
  • Run on a separate chart and monitor for trading activity from Empty4 with a given magic number
  • Duplicate the trading activity via the API with an adjusted trade size
  • Hedge if necessary by using 2 accounts
-- Lonnie.

"Give a man a program, frustrate him for a day. Teach a man to program, frustrate him for a lifetime." (Muhammad Waseem)
Post Reply

Return to “TDesk: A Thomas Special. The greatest trading tool ever.”