Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Variable0 as a stop loss value.

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

    Using Variable0 as a stop loss value.

    Click image for larger version

Name:	Forum_Example_100722.png
Views:	1
Size:	6.6 KB
ID:	894639

    Click image for larger version

Name:	Forum_Example_100722B.png
Views:	1
Size:	22.5 KB
ID:	894640I am using the wizard to try and establish a stop loss at the time of an order in the same group of commands. I've attached a screen shot of the commands in the wizard I am using. I don't have any other stop or trail loss implemented so there shouldn't be any interference from multiple stops. My problem is it just doesn't work when I later reference it in a different set of commands. As an example, I test for position long, and if true, set a stop at the MIN Low -1 tick. When I run this on a chart it is clear that the stop loss is not executing. Does the value that Variable0 takes on it's command persist through multiple bars or is it only good for the bar it executes on? If it persists, does it update as the MIN low changes bar to bar?
    I've attached an image of the command I am using to set the variable, and one of the command I am using to execute the stop.

    #2
    Hi daven,

    Several things could be happening here. At this point you may need to unlock the code and start debugging:


    Frankly it's hard to say exactly why you may not get the behavior you expect without doing so.

    To answer your question, the Variable that uses MIN should update with each new bar, since the period would shift.
    TimNinjaTrader Customer Service

    Comment


      #3
      Okay, I will unlock it and start debugging. with respect to Variable0, Variable1...etc., Will I accomplish the same thing by simply declaring a variable and then setting it to the value I want to use as a stop? is there something special or unique about the numbered variables (variable0, etc.) that makes them different than other dynamic variables which are created when using real code instead of the wizard? I suspect they are just variables available in the wizard for dynamic value allocation but I don't really know.
      Thanks
      DaveN

      Comment


        #4
        Hi daven,

        I'm not 100% what you mean by dynamic variables but to answer your question, no, having a number associated with the name does not make a difference. You can see how the variable is declared in the Variables region near the top of the script, then see how it is used in the OnBarUpdate(), then how it is exposed in the Properties region.
        TimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        630 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        566 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X