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

safe trading

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

    safe trading

    Hello,

    for being on the safe side when trading I have added now (a programmer has added the few lines for me) to my scripts a bool that sets false when connection is broken. In my exit conditions I coded that they will only trigger when bool connected is true. This way I hope to avoid that NT exits a position when getting back to connection, a position that might not exist anymore because stopped or closed during the outage. This is done with

    protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
    {if (priceStatus==ConnectionStatus.ConnectionLost || priceStatus==ConnectionStatus.Disconnected)
    connLost = true; }

    Does NT verify connection lost and set bool to false? Does this work when NT has no more connection to verify the status without "working by connection". Or could do NT this only when connected maybe (then it would not make sense). I hope I could translate what I mean.

    Thank you
    Tony

    #2
    Hello tonynt,

    Thanks for your post.

    The bool "connLost" will be set to true when your price connection is lost. You can test this by adding a print statement and observing in the output window.

    Code:
    protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
    {
    if (priceStatus==ConnectionStatus.ConnectionLost || priceStatus==ConnectionStatus.Disconnected)
    connLost = true;
    if (connLost) Print ("Lost Connection");
    }
    An example you would see in the output window is:

    **NT** Strategy 'Tony1/4643708b39e44749aa78af1bc94808cd' lost order connection but will keep running.
    **NT** Strategy 'Tony1/4643708b39e44749aa78af1bc94808cd' lost price connection but will keep running.
    Lost Connection
    Lost Connection

    So if you are using connLost bool as an exit condition note that it will be false until you have lost connection.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul,

      thank you for your reply. This was the first step. Let me please add now:

      Is it also possible to check not only for "connectionlost" but also for "freezing": is there a possibility to add this to my idea here above? I mean is it possible to have a bool “freeze” and when NT freezes then it sets “freeze” true and then so I can use this also in my conditions in the script?

      Counting speed of data or anything to measure and see that its frozen, any idea?

      Thanks
      Tony

      Comment


        #4
        Hello tonynt,

        Thanks for your reply.

        If NT is frozen then that means the code will not be executing and it would not make sense to set a bool when frozen if the code cannot execute.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello Paul,

          thank you for your reply.

          How do I answer now polite in english.... If something makes sense or not depends from different point of view and purposes. What might make sense for you must not for me and vv. Yes, it makes sense! When NT comes back to work after freezing and in the meantime the trade is cancelled, stopped.... then I´m happy with my idea having working - as all the others I had and could resolve in over 1200 posts already in this great forum and you all great guys! (to understand me right). Why am I happy? Because I dont want that NT does an exit by conditions to bring me in a naked position (when the trade is closed or stopped in the meantime). So it makes really sense when I have in my exit conditions ....&& freeze = false && then exitshort...

          So, please dont let us be philosophically if it makes sense or not but only to discuss the technical aspect. Is it possible?

          Thank you for all your support!

          Best
          Tony

          Comment


            #6
            Hello tonynt,

            Thanks for your reply and I appreciate your thoughts.

            All I can advise then is that there is no means to run any code if NinjaTrader is locked, in a memory loop, or "frozen".
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mongo, Today, 11:05 AM
            0 responses
            1 view
            0 likes
            Last Post Mongo
            by Mongo
             
            Started by Tim-c, Today, 10:58 AM
            0 responses
            1 view
            0 likes
            Last Post Tim-c
            by Tim-c
             
            Started by traderqz, Yesterday, 09:06 AM
            3 responses
            22 views
            0 likes
            Last Post NinjaTrader_ThomasC  
            Started by f.saeidi, Today, 10:19 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by kujista, Today, 06:23 AM
            5 responses
            18 views
            0 likes
            Last Post kujista
            by kujista
             
            Working...
            X