• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

entry price variable not working!!!

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

    entry price variable not working!!!

    how do I set a variable under onbarupdate to set to the price I entered the market at?

    double EntryPrice = Position.AvgPrice;

    this doesnt seem to be working for me as when I added

    double EntryPrice = Position.AvgPrice;
    Print(EntryPrice);

    it printed 0! yes...a load of zeros?!!

    can anybody help me here???

    #2
    Hello James377,

    Yes, it will be zero if you are not in a position. You may want to consider this check.

    if (Position.MarketPosition != MarketPosition.Flat)
    {
    double EntryPrice = Position.AvgPrice;
    Print(EntryPrice);
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      thanks for this but the output window is just returning a load of zeros again?? why is this??help!

      Comment


        #4
        profitfactor = 2;
        EntryPrice = Position.AvgPrice;
        //Print(EntryPrice);
        SetProfitTarget("", CalculationMode.Price,EntryPrice + (profitfactor * TickSize));

        any ideas why this wont work in onbarupdate?

        Comment


          #5
          Make sure you've recompiled, removed any instances of the strategy and try again.

          If you have any issues, please post the most recent OnBarUpdate() block for the code you're working with.
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by aslane, Today, 01:29 PM
          1 response
          6 views
          0 likes
          Last Post aslane
          by aslane
           
          Started by itrader46, Today, 01:09 PM
          0 responses
          5 views
          0 likes
          Last Post itrader46  
          Started by elnoppo, Today, 12:38 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by TradingRocks, Today, 11:44 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Brillo, Today, 11:39 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X