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

Variables

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

    Variables

    Hello,
    I created a variable (impulseL) within OnBarUpdate () to do a calculation. The result must update the variable initial (private double rangelong = 1), I will need to define the Exit. The problem is that the variable (rangelong) is always 1, is not updated.
    Here's an example:
    # Region Variables
    private double rangelong = 1; // default
    # Endregion

    # Region OrderRouting // Region to define the Exit and Stop
    private void ManagerOrder ()
    {
    if (Position.MarketPosition == MarketPosition.Long)

    {
    if (High [0]> (Position.AvgPrice + (Rangelong * (1-0.50))//Problem, Rangelong remains1
    SetStopLoss .....etc.
    # Endregion

    protected override void OnBarUpdate ()
    {
    ManagerOrder ();

    double impulseL = (MIN (Low, 10) [5] - MAX (High, 5) [0]) *- 1, / / Local Variable
    Rangelong impulseL = / / Rangelong why not take the value of impulseL

    you know, please advise me.
    Thanks.
    Roberto

    #2
    Please try defining the impulseL variable also globally in your Variables section, right now it's local only to the OnBarUpdate().
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hello Bertrand,
      I tried to do as I have suggested, the problem remains, the variable is always one, is not updated.
      Ciao.
      Roberto

      Comment


        #4
        You will need to debug your code Roberto, add prints to the calcs to see if the condition you use to update the variable is hitting at all.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Of course, I did F5. then, I added the Print command and on the 'Output window the value is 1.
          How can I do?

          Comment


            #6
            Please attach the full script you're using so I can give it quick run here for you.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I've attached the file.
              Through 1000
              Ciao
              Attached Files

              Comment


                #8
                This will not even compile on my end - do I need any other scripts to run it here?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  I'm sorry but I do not know what to do. I have to copy the text into a file world, or do I export the code from the platform?

                  Comment


                    #10
                    Please export the file through File > Utitlies > Export NinjaScript and then attach it here.

                    Thanks
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      ok, here is the file
                      Attached Files

                      Comment


                        #12
                        Here's your strategy stripped to the bare essentials plotting your variables, I can't see any fault, you need to inspect it carefully and you may need to add more prints to understand what is not working as you would expect.
                        Attached Files
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          ok, now I try.
                          Thanks
                          Roberto

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by arvidvanstaey, Today, 02:19 PM
                          4 responses
                          11 views
                          0 likes
                          Last Post arvidvanstaey  
                          Started by samish18, 04-17-2024, 08:57 AM
                          16 responses
                          60 views
                          0 likes
                          Last Post samish18  
                          Started by jordanq2, Today, 03:10 PM
                          2 responses
                          9 views
                          0 likes
                          Last Post jordanq2  
                          Started by traderqz, Today, 12:06 AM
                          10 responses
                          18 views
                          0 likes
                          Last Post traderqz  
                          Started by algospoke, 04-17-2024, 06:40 PM
                          5 responses
                          47 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Working...
                          X