Trading time during update() with REST API

We have many access to values during connection with the FXCM REST API. But how can I add in the update() function the rule for different trading time?

For example I will trade the EUR/USD only from 8 am until 8 pm, but not over night.

In the update () function I have include my trading rules for enter into a trade and als o exit from a trade but how can I handle the live trading time that the strategy open trades only between 8am and 8 pm?

Any idea?

Thanks for helping Chris

1 Like

@cmstrader looking into this with one of our developers-- will get back to you soon!

Hi @cmstrader

I contacted our developers and we changed the code so it now should do what you are looking for.

We changed the RSI Range Strategy code to include starttime and endtime parameters set to “08:00:00” and “20:00:00” respectively. Using the new isTradingTime() function I also added, we can check whether or not the computer’s current local time falls between starttime and endtime. If current local time is between starttime and endtime, the function returns True, is current local time is outside of starttime and endtime, the function returns False.

You can see how I use the isTradingTime() function inside the Update() function when the strategy looks for trading signals. When it is trading time, we look for trades. When it is not trading time, we do no look for trades and a print message is returned stating that fact.

Hope this helps!