Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Problems with live trading using Forex.com

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problems with live trading using Forex.com

    I have been trying to do live trading using Forex.com (form the NT 8 platform) for some time time. I keep getting errors that shut down my trading. The log:

    2021-09-02 11:44:30:053|2|4|Session Break (Version 8.0.24.3)
    2021-09-02 11:44:31:263|1|4|Verifying license at primary server...
    2021-09-02 11:44:31:368|1|4|Type=Regular State=Verified Start Date=7/11/2021 End Date=12/30/2099
    2021-09-02 11:44:32:759|1|4|Global simulation mode disabled
    2021-09-02 11:44:33:603|1|2|Using IS (is-us-nt-001.ninjatrader.com/31658)
    2021-09-02 11:44:33:618|1|4|Automated trading disabled
    2021-09-02 11:44:33:619|1|4|Auto connecting 'My FOREX.com'...
    2021-09-02 11:44:33:635|1|2|My FOREX.com: Primary connection=Connecting, Price feed=Connecting
    2021-09-02 11:44:33:733|1|32|Order entry hot keys disabled
    2021-09-02 11:44:33:734|1|4|Auto close enabled=False
    2021-09-02 11:44:34:277|1|4|Restoring workspace 'Untitled'...
    2021-09-02 11:44:37:070|1|2|My FOREX.com: Primary connection=Connected, Price feed=Connected
    2021-09-02 11:44:37:090|1|2|Time to auto close position='12:00:00 AM', Enabled=False
    2021-09-02 11:45:34:949|1|2|My FOREX.com: Primary connection=Disconnecting, Price feed=Disconnecting
    2021-09-02 11:45:35:735|1|2|My FOREX.com: Primary connection=Disconnected, Price feed=Disconnected
    2021-09-02 13:46:25:440|1|4|Global simulation mode enabled
    2021-09-02 13:50:10:772|1|2|My NinjaTrader FXCM: Primary connection=Connecting, Price feed=Connecting
    2021-09-02 13:50:13:206|0|2|My NinjaTrader FXCM: Login failed. (Panic)
    2021-09-02 13:50:13:206|1|2|My NinjaTrader FXCM: Primary connection=Disconnected, Price feed=Disconnected
    2021-09-02 13:51:23:698|1|2|My NinjaTrader FXCM: Primary connection=Connecting, Price feed=Connecting
    2021-09-02 13:51:24:220|0|2|My NinjaTrader FXCM: Login failed. (Panic)
    2021-09-02 13:51:24:220|1|2|My NinjaTrader FXCM: Primary connection=Disconnected, Price feed=Disconnected
    2021-09-02 13:53:21:362|1|2|TestFX: Primary connection=Connecting, Price feed=Connecting
    2021-09-02 13:53:21:796|0|2|TestFX: Login failed. (Panic)
    2021-09-02 13:53:21:796|1|2|TestFX: Primary connection=Disconnected, Price feed=Disconnected
    2021-09-02 13:53:37:786|1|2|My FOREX.com: Primary connection=Connecting, Price feed=Connecting
    2021-09-02 13:53:41:436|1|2|My FOREX.com: Primary connection=Connected, Price feed=Connected
    2021-09-02 13:53:41:440|1|2|Time to auto close position='12:00:00 AM', Enabled=False
    2021-09-02 13:54:32:938|3|4|Strategy 'SFSHELLMIN': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2021-09-02 13:54:51:437|3|4|Strategy 'SFSHELLMIN': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2021-09-02 13:54:51:498|3|4|Strategy 'SFSHELLMIN': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2021-09-02 13:54:51:541|3|4|Strategy 'SFSHELLMIN': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2021-09-02 13:54:51:554|3|4|Strategy 'SFSHELLMIN': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2021-09-02 13:54:51:586|3|4|Strategy 'SFSHELLMIN': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2021-09-02 13:54:52:469|1|4|Enabling NinjaScript strategy 'SFSHELLMIN/241566613' : On starting a real-time strategy - StartBehavior=WaitUntilFlat


    (The log is incomplete due to space restrictions)

    I have submitted this problem to the platform help and they very very helpful in trying to track it down. That came to the conclusion that the problem is at Forex.com. Forex.com in turn has no advice and says it is an NT problem or a problem in my algorithm.

    To make sure the problem is not in my code in ran an unaltered built in strategy (Sample MA crossover) and got the same problem.

    I have tested my algorithms and the built in ones on simulated data from Forec.com and had no problems. I have a live account with NT and I have a funded Forex.com account.

    A few weeks ago I decided I could not work with this combination. I started using cTrader. After mastering that, I discovered that I can use it in the US with any of their brokers. cTrader seems to be pretty good, no use to me.

    I liek Ninjatrader and have invested time in learning it and developing my C# algos. I think If I could use NT 8 with a different forex broker that it would meet my needs. Forex.com seems to be the "default" for NT 8. What I need is help finding a different good forex broker that will reliably work with NT8.

    I would greatly appreciate any ideas that you might have.

    #2
    Hello CHEII,

    Thanks for your post.

    We checked your email address and saw that you were working with me previously on a ticket involving reversals with FOREX.com. Standard reversals preformed with NinjaTrader are not always friendly with FOREX.com, but this is not a show stopping matter. As the topic of this message involves strategy issues, and a solution would be taken from the strategy code, I am moving this topic to our Strategy Development forum.

    We gave the following suggestion:

    Something to consider, would be to do the following when you want to reverse to be more compliant with FOREX.com:
    1. Set a bool "WaitingForExit" (or any name really) to true when you want to reverse
    2. Call ExitLong/ExitShort, using a specific signal name
    3. Look for the execution of this order in OnExecutionUpdate, and check your bool
    4. If the bool WaitingForExit is true and you see the execution in OnExecutionUpdate, then call EnterLong/EnterShort to enter in the opposite direction, and set the bool to false.
    An example that demonstrates working with OnOrderUpdate and OnExecutionUpdate can be found below.

    https://ninjatrader.com/support/help...and_onexec.htm

    FXCM can be used outside of the US, but cannot be used inside the US. It is possible to trade FOREX with Interactive Brokers, but I am not certain on their ability to open FOREX accounts in the US. Inquiring with Interactive Brokers could shed light on being able to open a FOREX enabled account with them in the US.

    The OnStateChange errors here would not be related to reversal behaviors and would be specific to the strategy. I would suggest using debug prints throughout the OnStateChange method to see which lines throw the "Object reference not set to an instance of an object." errors. You can share the lines of code here for us to further comment on the error. Essentially, it would mean that you are referencing something on that line that is null.

    I look forward to assigning.
    JimNinjaTrader Customer Service

    Comment


      #3
      NT_Jim,

      Thanks for your response. I am working on using OnExecutionUpdate per your instructions. It is a bit complicated. In the NT manual, it says for experienced programmers only. I am that, so I should be able to work it out.

      I was bit hesitant at first because it seems like an awkward workaround - only because I was put off by the fact that your own built in strategy SampleMaCrossover does not work on live trades through your recommend broker. It works fine in simulation mode.

      Thanks for your help,

      CHEIII

      Comment


        #4
        Hello CHEIII,

        The Managed Approach makes programming strategies easier, but there are going to be nuances between different brokers where we have to keep things in mind. FOREX.com is strict with reversals, and this is not limited to NinjaScript. Manually performing reversals with a Reverse button can incur the same issues.

        So we are left to make our code work with the broker we are using by understanding that specific nuance and working through it.

        We understand that it would be ideal if reversals work better out of box with FOREX.com, but with the current way NinjaTrader is programmed, this can be considered a limitation. When you were working with my colleague ChrisL, he submitted a vote for our enhancement request to improve this situation. At this time we are tracking the impact before making internal changes, and advising work around solutions to get through this particular matter.

        If any one else on the forum is experiencing the same issue with reversals with FOREX.com, they may follow the advise here, and share their impact/interest to have this improved internally. We are currently tracking feedback behind the internal enhancement ticket SFT-5324. When changes and new features/enhancements are applied, they will be listed in the Release Notes page of the Help Guide. The id will be different, but you may reference a list of descriptions to see if changes were applied to address that matter.

        Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

        Please keep in mind that we can never offer ETA's on new features, enhancements, or release schedules.
        Last edited by NinjaTrader_Jim; 09-08-2021, 08:41 AM.
        JimNinjaTrader Customer Service

        Comment


          #5
          NT_Jim,

          I have been trying to implement the
          1. Set a bool "WaitingForExit" (or any name really) to true when you want to reverse
          2. Etc.
          that you suggested. When I implement your suggestions, it works fine in simulation mode, but throws the same error when you go live. should I send the source code I am using?

          Thanks,
          CHEIII

          Comment


            #6
            Hello CHEIII,

            I have attached an modification of the SampleMACrossover strategy that uses OnExecutionUpdate and includes logic to exit a position in OnBarUpdate, set the bool we are discussing and then re-enter in the opposite direction when the execution of the exit order is seen (when we are back to flat) and the bool is true. I gave this a test for several order submissions on a FOREX.com test account with the fast period set to 1 and the slow period set to 2, using a 1 second data series to get some quick trades simulated. I did not experience any issue with this test.

            Please let me know if you have issues with this particular test script. It may then be used to model your own logic.
            Attached Files
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks you. I tried the strategy you sent, but it crashed in live trading. I sent email with log file and screen shots. It worked fine in simulated.

              CHEIII

              Comment


                #8
                NT_Jim,

                Thanks for all your help so far. Still working on the Red Card.

                Does NT8 work with OANDA? It seems to have a pretty good USA base.

                Thanks,

                CHEIII

                Comment


                  #9
                  Hello CHEII,

                  Oanda is no longer a supported broker. Supported brokers will be listed below:

                  NinjaTrader supports multiple futures market data and brokers providing access to trade futures, stocks, and more. Download NinjaTrader for FREE to get started!


                  As for the Red Card error in the test script, you would have to set the Default Quantity to a unit/lot size that is supported by FOREX.com.

                  What values have you tried for the Default Quantity? Below is a screenshot of what I tested on my FOREX.com test account.

                  Click image for larger version

Name:	NinjaTrader_2021-09-23_12-14-58.png
Views:	437
Size:	50.3 KB
ID:	1172244
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks NT_Jim. I tried exactly the same settings that you sent lot size = 1000. EURUSD. It did 8 real time trades and then I got the Red Card. It says insufficient funds. But my Forex.com account shows $466. Do you know a "best place" to send to Forex.com. The last few times I have contacted them, they just blame NT.

                    CHEIII

                    Comment


                      #11
                      Hello CHEIII,

                      The Red Card would be a native error from FOREX.com. If that is reported from one of their accounts and the order was rejected for insufficient funds, when it appears there would be sufficient funds, they should be able to elaborate on why they rejected your order.

                      I have just tested about a dozen order submissions with this test strategy without issue.

                      I am only aware of the support [at] forex [dot] com email address for existing customer support. It really should not matter that NinjaTrader is involved here, since we are just talking about an order rejection.

                      All FOREX .com would need to look into is "I had submitted a Buy or Sell Short order for 1000 units on EURUSD, and I received a Red Card for insufficient funds. It looks like I have sufficient funds in my account, so it is unclear to me why you have rejected the order. Could you please elaborate?" NinjaTrader should not be relevant here.

                      If they insist that NinjaTrader does have a part in this, please ask them to elaborate, and forward their response to me at scriptingsupport [at] ninjatrader [dot] com with the text "Attn Jim" and include a link to this thread. I would very much like to understand why an "insufficient funds" rejection occurs on what looks like would be be an allowed trade.
                      JimNinjaTrader Customer Service

                      Comment


                        #12
                        NT_Him,

                        Thanks. I just sent the message to them.


                        CHE III

                        Comment


                          #13
                          NT_Jim,

                          The reply from Forex.com support was that there wee insufficient funds. I had already sent them the error message which included that information. Can't be the reason since I have over $450 in my account. Maybe they will get me more information - so far very unimpressed with the.

                          So, does NT support TS Ameritrade? Google thinks so, but ...

                          Thanks,

                          CHEIII

                          Comment


                            #14
                            Hello CHEIII,

                            Yes TD Ameritrade is supported, but only for trading stocks and stock options with NinjaTrader.

                            TD Ameritrade Connection Guide - https://ninjatrader.com/ConnectionGu...nnection-Guide

                            Data By Provider - https://ninjatrader.com/support/help...y_provider.htm
                            JimNinjaTrader Customer Service

                            Comment


                              #15
                              Thanks NT_Jim

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post love2code2trade  
                              Started by alifarahani, Today, 09:40 AM
                              2 responses
                              13 views
                              0 likes
                              Last Post alifarahani  
                              Started by junkone, Today, 11:37 AM
                              3 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by pickmyonlineclass, Today, 12:23 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post pickmyonlineclass  
                              Started by frankthearm, Yesterday, 09:08 AM
                              12 responses
                              44 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X