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

Strategy works even when is disabled!

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

    Strategy works even when is disabled!

    I am developing a strategy that makes use of Firebase, I have done the connection tests and everything works fine, the problem comes when disabling the strategy, it continues to work.

    I have tried many ways, the "exec" variable is bool, I have tried with int, I have tried the "IsEnabled" and I have not had results, "ListenerUpdate ()" still works even when the "if # 1" is true. Why does this happen? Why does it enter the "if # 1" conditional even when it works and the strategy is disabled?

    Another problem is that when I re-enable the strategy, it now works double, if I disable and enable the strategy 5 times, I will have 5 processes in parallel, with 5 queries. Ninja does not kill the above process, "ListenerUpdate ()" runs in parallel the number of times you disable and enable the strategy. Why does that happen?

    Click image for larger version

Name:	Captura 16.PNG
Views:	105
Size:	36.0 KB
ID:	1160326

    #2
    Hello GonzalesDevelop,

    Thank you for the post.

    While our support for third party libraries is very limited I can try to make some suggestions based on the details provided.

    You will need to review the documentation for the library you are using to see if there is a subscribe/unsubscribe pattern that you can use. The code you have shown is called in State.Configure however when you stop the strategy State.Terminated will be called and Configure will not be called again.

    If the library you are using can make an event handler subscription then you could use Terminated to unsubscribe from the event and close the client/do any shut down work needed for that library.

    Generally subscribing and unsubscribing to an event looks like:

    Code:
    client.MyEventName += MyEventVoidMethod;
    unsubscribing looks like:

    Code:
    client.MyEventName +- MyEventVoidMethod;
    If the library does not have that type of pattern you would need to instead research their documentation to see if there is a specific way to shut down that client object you have shown. You would need to store a class level variable for that and then use State.Terminated to shut down the client.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by RideMe, 04-07-2024, 04:54 PM
    5 responses
    28 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by f.saeidi, Today, 08:13 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by DavidHP, Today, 07:56 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by kujista, Today, 06:23 AM
    3 responses
    9 views
    0 likes
    Last Post kujista
    by kujista
     
    Started by Mindset, Yesterday, 02:04 AM
    2 responses
    18 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Working...
    X