Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Built-In Variables

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

    Using Built-In Variables

    I am trying to create a dynamic stop condition so that my strategy will be more responsive to market volatility. At the time of an order (I'm entering with a limit order set at the current ask for longs and bid for shorts) I set Variable0 to either a lower band value for a long, or an upper band value for a short. I am using the strategy wizard so that the trailingstop value gets set to variable0 in the initialize portion of the code. My expectation is that for each entry a new value for variable0 is set, and that is good until the next trade is entered. However, when I test the strategy the stop never executs. The only way I can get out of a position is through a profit target exit, or the close of the session. What am I doing wrong?
    DaveN

    #2
    Hello,

    Thanks for your note.

    A Dynamic stop would actually take editing the code manually and cannot be done through the strategy wizard, please let me know if you are confiterable in doing this as once unlocked you will not be able to use the strategy wizard with this strategy again.

    The only way to do it in the strategy wizard is to not to ue the stops and targets page, but to use the Conditions and exit page and add a Do The Following of Exit Long position by a stop order You must call this on every onBarUpdate that you are in the position.

    Let me know if I can be of further assistance.

    Comment


      #3
      Using Variable0 for Dynamic Stops

      I am comfortable programming in NTScript, though I have never been able to get stops using variable0 to work. Do you have some reference code that shows how to do this? For instance say in the code you are running an average of the highs and a separate average of the lows. When a long executes I would like to set the stop to 2 ticks below that average low value, and then udpate it as the price moves up. What would that look like in code, (if you have some example similar to that)?
      Thanks
      DaveN
      Last edited by daven; 01-14-2011, 02:05 PM. Reason: Misspellings

      Comment


        #4
        Hello,

        Sure here is the sample code on how to do this.

        Essentially you have to move it out of Initialize() so it update on each OnBarUpdate().



        Let me know if I can be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        8 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X