stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Oanda TDesk Drone - Artificial Hedging for U.S. Traders
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5588
Page 1 of 3
Author:  Jonah [ Sat Dec 22, 2018 7:53 pm ]
Post subject:  Oanda TDesk Drone - Artificial Hedging for U.S. Traders

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
Author:  tomele [ Sat Dec 22, 2018 8:39 pm ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

Hi Jonah.

A very astonishing piece of work. I am speechless.

Cheers
Thomas
Author:  SteveHopwood [ Sat Dec 22, 2018 9:31 pm ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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:
Author:  Jonah [ Sun Dec 23, 2018 12:11 am ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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.
Author:  renexxxx [ Sun Dec 23, 2018 3:59 am ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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:
Author:  Jonah [ Sun Dec 23, 2018 4:09 am ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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.
Author:  zafh [ Sun Dec 23, 2018 10:43 am ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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.
Author:  tomele [ Sun Dec 23, 2018 4:40 pm ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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
Author:  zafh [ Sun Dec 23, 2018 4:52 pm ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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.
Author:  Jonah [ Sun Dec 23, 2018 5:09 pm ]
Post subject:  Oanda TDesk Drone - Hedging for U.S. Traders

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
All times are UTC Page 1 of 3