Announcement

Collapse
No announcement yet.

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().

    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.

        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.

            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?

                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

                    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

                        Comment


                          #13
                          ok, now I try.
                          Thanks
                          Roberto

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          670 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          379 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          111 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          575 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          582 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X