Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using built-in variables for price targets

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

    Using built-in variables for price targets

    I am doing something that seems to be quite straight forward using the strategy wizard, but I can't seem to get it to work as I think it should. I'm setting a price target equal to Variable0 or Variable1, (0 for longs, 1 for short). When I enter the order to buy or sell, I set the variable equal to an indicator value, (highest high or lowest low over the last x-periods). I used a named profit target qhich is the same as the name of the entry order. so as near as I can tell, the variable value is correct but I am never getting my price target filled even though it clearly is hit by the price while the order is in effect. Is there something tricky about doing this that I may be overlooking? I am using the price mode for the profit target since the indicator value is at a price. What else should I consider or check? do you have any examples of this actually working?
    DaveN

    #2
    Hi DaveN,

    It sounds like you have most of the steps right. My first suspiciion is that you are setting the user variable to a dynamic indicator value that changes with each bar.

    For this situation, I suggest using ChartTrader to visually monitor the level of the target order. You can't run a strategy and ChartTrader at the same time, but you can create a separate chart with ChartTrader enabled -- It shows orders from strategies. That will at least let you visualize if price actually hits your order. You can get more advanced strategy debugging by working in code, adding TraceOrders = true; to Initialize() method.

    If it is a dynamic value updating, then you need some control on when you set the user variable. This is also done using variables. They initialize as 0, so you can make a check for this value and set to something different in the actions section. Typically you would do this in the same set as your other entry conditions. Attached screenshot showing this. You later need a way to reset Variable2 back to 0, likely when MarketPosition == Flat.
    Attached Files
    Last edited by NinjaTrader_RyanM1; 06-01-2011, 01:31 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Using Variables continued

      Ryan,
      Thanks for the advice. I made some changes as you suggested but it still isn't working. I will post the wizard screens showing what I am doing, perhaps they will point to an oversight or something. Oh, and yes, you are correct the variable is dynamic. It is equal to the highest high over n periods for a long, or the lowest low for a short. I assumed, that once the variable was set in the code, that is the value that it maintains, but perhaps I am incorrect in that assumption. If I am, how do I grab a price to use as a price target which remains fixed, despite the fact that the source of the price, at the time of setting the value is variable over multiple bars?
      Thanks
      The three screen shots attached are the order entry steps, resetting the variable steps, and setting the profit targets.
      Thanks
      DaveN
      Attached Files

      Comment


        #4
        Thanks for the reply. You need to control when you set the user variable to the indicator value. For this you will also use user variables. Instructions for this and an example screenshot were given in my first response. This concept of using user variables for sequences is also expanded upon in this reference sample. You can import and edit the strategy to see how it's setup in the wizard.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by elirion, Today, 01:36 AM
        0 responses
        3 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        391 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        34 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X