Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

sell prior high

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

    sell prior high

    Hi,
    I'm trying to buy a specific percentage point below the high of the day, using current day OHL indicator which works fine, but I'm also trying to sell at the high of day that occured prior to my entry. I've tried setting the prior high as a variable (priorHigh = CurrentDayOHL1.CurrentHigh[0]) but this doesn't work, presumably since that value is always changing as new highs happen. What's a good way to save the high prior to my entry and use it as an exit point?
    thanks,
    David

    #2
    Hello trader3000a,

    Is this variable being assigned from the same condition set that submits the order?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      no, it's in it's own set

      PriorHIgh = 0;
      }
      else if (State == State.Configure)
      {
      }
      else if (State == State.DataLoaded)
      {
      CurrentDayOHL1 = CurrentDayOHL(Close);
      SetStopLoss("", CalculationMode.Ticks, StopTicks, false);
      }
      }

      protected override void OnBarUpdate()
      {
      if (BarsInProgress != 0)
      return;

      // Set 1
      if (Position.MarketPosition == MarketPosition.Flat)
      {
      PriorHIgh = 0;
      }

      if (CurrentBars[0] < 1)
      return;

      // Set 2
      if (Position.MarketPosition == MarketPosition.Long)
      {
      PriorHIgh = CurrentDayOHL1.CurrentHigh[0];
      }

      // Set 3
      if (Position.MarketPosition == MarketPosition.Long)
      {
      ExitLongLimit(Convert.ToInt32(DefaultQuantity), PriorHIgh, "", "");
      }

      // Set 4
      if (Times[0][0].TimeOfDay >= new TimeSpan(10, 0, 0))
      {
      EnterLong(Convert.ToInt32(DefaultQuantity), "");
      }

      Comment


        #4
        Hello trader3000a,

        You want to save the value when the entry is submitted, correct?

        Set the variable from the condition set that submits the entry.

        Print the variable and the time of the bar to confirm the value.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          got it, thx Chelsea, I'll give it a go

          Comment


            #6
            still can't get it happening. weird results. have a look if you can ?
            Attached Files

            Comment


              #7
              Hello trader3000a,

              Are wanting to put multiple entries in a direction? Are you checking the position is flat before placing a new entry and saving this value?

              Please save the output from the prints and trace orders in the NinjaScript Output window to a text file and include this with your reply.

              I am happy to assist with analyzing the debugging output.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Without boring you with too many parameters, I simply want to buy a close below the HOD and sell at the HOD. Is there an easier way? It seems like the variable won't stick once price rises above it.
                Attached Files
                Last edited by trader3000a; 05-16-2022, 02:44 PM.

                Comment


                  #9
                  Hello trader3000a,

                  It is very helpful to put a label before each value printed to know what is being printed and how this is being compared.

                  What are you printing? Are you printing the variable only?

                  Is this the output?
                  3887.25
                  3917.75

                  Is the variable being printed, then being changed, then being printed again?

                  Previously you were attempting to save the current day high at the moment an entry is being submitted. Is this no longer what you are wanting to achieve? Is this a new script?
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CarlTrading, 05-11-2026, 05:56 AM
                  0 responses
                  58 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 05-10-2026, 08:12 PM
                  0 responses
                  34 views
                  0 likes
                  Last Post CarlTrading  
                  Started by Hwop38, 05-04-2026, 07:02 PM
                  0 responses
                  195 views
                  0 likes
                  Last Post Hwop38
                  by Hwop38
                   
                  Started by CaptainJack, 04-24-2026, 11:07 PM
                  0 responses
                  359 views
                  0 likes
                  Last Post CaptainJack  
                  Started by Mindset, 04-21-2026, 06:46 AM
                  0 responses
                  281 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X