Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High/Low of a spezific Candle

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

    High/Low of a spezific Candle

    Hey guys, i want to creat a stop loss method for my entry signals. but therefore i need to get the high/low of a spezific candle.
    i have the following code:

    //Draws a Diamond on the previous candle if the current close is not greater then the previous high and the current close is greater than the previous low
    if (Close[0]<High[1]&&Close[0]>Low[1])
    {
    DrawDiamond("Down Diamond" + CurrentBar, false, 1, High[1], Color.Blue);
    DrawDiamond("Up Diamond" + CurrentBar, false, 1, Low[1], Color.Blue);
    }


    now i want to work with that high/low of the candle with the first Diamond up/down. but i don´t know how to do that...
    i want to code now:
    if (Close[0]<High[candle with first diamond up/down]&&Close>Low[Candle with first damond up/down]
    Sorry for my englisch...do you guys understand what i want to do?

    #2
    mko1983, it looks like you would need to work with bool flag to be able to save the barnumber / high / low of the first candle where the conditions for the diamond evaluated as reference then. A similiar concept is shown in this sample - http://www.ninjatrader.com/support/f...ad.php?t=15417

    Comment


      #3
      Thanks Bertrand for your quick reply.
      Now i get the Diamonds only on the Candle i want. But my Question is now, how can i work with the high/low of that candle?
      i want to code:
      if (Close[0]>High[of that spezific Candle])
      {
      do something;
      }


      {
      if (Position.MarketPosition == MarketPosition.Flat)
      {
      SetStopLoss(CalculationMode.Ticks, stoplossticks);
      controlone = true;
      }
      i
      else if (Position.MarketPosition == MarketPosition.Long)
      {

      if (BarsSinceEntry()<1)
      {
      SetStopLoss(CalculationMode.Price, Low[1]-5*TickSize);
      }

      if (Close[0]<Position.AvgPrice+10*TickSize)
      {
      return;
      }

      if (Close[0]<High[1]&&Close[0]>Low[1]&&controlone&&Close[0]>Position.AvgPrice+10*TickSize)
      {
      SetStopLoss(CalculationMode.Price, Low[2]-5*TickSize);
      DrawDiamond("Up Diamond" + CurrentBar, false, 1, Low[1], Color.Green);
      DrawDiamond("Down Diamond" + CurrentBar, false, 1, High[1], Color.Green);
      controlone=false;
      }

      if (Close[0]>High[1]&&!controlone)
      {
      SetStopLoss(CalculationMode.Price, Low[0]-5*TickSize);
      DrawDiamond("Up Diamond" + CurrentBar, false, 0, Low[0], Color.Cyan);
      DrawDiamond("Down Diamond" + CurrentBar, false, 0, High[0], Color.Cyan);

      }
      }

      Comment


        #4
        mko1983, great - I would then also save the barnumber of your 'signal' candle, so you would then in turn how many bars to reference back from the current bar to get to this candle. Another way is simply storing the High value of this candle and then reference it directly in your condition : if (Close[x] > myHighValue)...

        Comment


          #5
          Hey Bertrand, i tried to work with HighValue and i think i get it to work. Now i have another question. When you look at the picture, where the black arrow down is. i want to check the same conditions here. i tried it with another bool flag, but i didn´t work.


          if (Position.MarketPosition == MarketPosition.Flat)
          {
          SetStopLoss(CalculationMode.Ticks, stoplossticks);
          controlone = true;
          controltwo = false;
          }

          else if (Position.MarketPosition == MarketPosition.Long)
          {

          if (BarsSinceEntry()<1)
          {
          SetStopLoss(CalculationMode.Price, Low[1]-5*TickSize);
          }

          if (Close[0]<Position.AvgPrice+10*TickSize)
          {
          return;
          }

          if (Close[0]<High[1]&&Close[0]>Low[1]&&controlone&&Close[0]>Position.AvgPrice+10*TickSize)
          {
          SetStopLoss(CalculationMode.Price, Low[2]-5*TickSize);
          DrawDiamond("Up Diamond" + CurrentBar, false, 1, Low[1], Color.Green);
          DrawDiamond("Down Diamond" + CurrentBar, false, 1, High[1], Color.Green);
          controlone=false;
          myHighValue= MAX(High, 1)[1];
          }

          if (Close[0]>myHighValue&&!controlone)
          {
          SetStopLoss(CalculationMode.Price, Low[0]-5*TickSize);
          DrawDiamond("Up Diamond1" + CurrentBar, false, 0, Low[0], Color.Cyan);
          DrawDiamond("Down Diamond1" + CurrentBar, false, 0, High[0], Color.Cyan);
          }

          Comment


            #6
            So that would be basically a candle after the first boolflag condition triggered then, correct? You could work this in the script using the same bool flag technique but you would need to take proper care to not reset the flag then too early so the sequence fits.

            Comment


              #7
              hey bertrand, thanks for your help. i got it to work :-)
              now i want to add a 1 Min. Period to ONLY for my Entry Strategie. I came up with the following Code (Entry Signal is bold) and it works correctly. But then my exit strategy is not working. Is it possible to only add the 1 min. period to the entry signal? cause i dont want to add any period to my exit strategie...


              Add (PeriodType.Minute, 1); //Bars in Progress [1]

              {

              if (Position.MarketPosition == MarketPosition.Flat)
              {
              SetStopLoss(CalculationMode.Ticks, stoplossticks);
              controlone = true;
              controltwo = true;
              controlthree = true;
              controlfour = true;
              controlfive = true;
              controlsix = true;
              controlseven = true;
              controleight = true;
              controlnine = true;
              controlten = true;
              controleleven = true;
              controltwelve = true;
              controlthirteen = true;
              controlfourteen = true;
              controlfifteen = true;
              controlsixteen = true;
              controlseventeen = true;
              controleighteen = true;
              controlnineteen = true;
              controltwenty = true;
              }

              else if (Position.MarketPosition == MarketPosition.Long)
              {

              if (BarsSinceEntry()<1)
              {
              SetStopLoss(CalculationMode.Price, Low[1]-5*TickSize);
              }

              if (Close[0]<Position.AvgPrice+10*TickSize)
              {
              return;
              }

              if (Close[0]<High[1]&&Close[0]>Low[1]&&controlone&&Close[0]>Position.AvgPrice+10*TickSize)
              {
              SetStopLoss(CalculationMode.Price, Low[2]-5*TickSize);
              DrawDiamond("Up Diamond" + CurrentBar, false, 1, Low[1], Color.Green);
              DrawDiamond("Down Diamond" + CurrentBar, false, 1, High[1], Color.Green);
              controlone=false;
              HochAußenkerze= MAX(High, 1)[1];
              TiefAußenkerze= MIN(Low, 1) [1];

              }

              if (Close[0]>HochAußenkerze&&!controlone&&controltwo)
              {
              SetStopLoss(CalculationMode.Price, Low[0]-5*TickSize);
              DrawDiamond("Up Diamond1" + CurrentBar, false, 0, Low[0], Color.Cyan);
              DrawDiamond("Down Diamond1" + CurrentBar, false, 0, High[0], Color.Cyan);
              controltwo=false;
              }

              if (Close[0]<High[1]&&Close[0]>Low[1]&&!controlone&&!controltwo&&controlthree&&Close[0]>Position.AvgPrice+10*TickSize)
              {
              SetStopLoss(CalculationMode.Price, Low[2]-5*TickSize);
              DrawDiamond("Up Diamond2" + CurrentBar, false, 1, Low[1], Color.Green);
              DrawDiamond("Down Diamond2" + CurrentBar, false, 1, High[1], Color.Green);
              HochAußenkerze1= MAX(High, 1)[1];
              TiefAußenkerze1= MIN(Low, 1) [1];
              controlthree=false;
              }
              if (Close[0]>HochAußenkerze1&&!controlone&&!controltwo&&!contr olthree&&controlfour)
              {
              SetStopLoss(CalculationMode.Price, Low[0]-5*TickSize);
              DrawDiamond("Up Diamond3" + CurrentBar, false, 0, Low[0], Color.Cyan);
              DrawDiamond("Down Diamond3" + CurrentBar, false, 0, High[0], Color.Cyan);
              controlfour=false;
              }

              if (Close[0]<High[1]&&Close[0]>Low[1]&&!controlone&&!controltwo&&!controlthree&&!contro lfour&&controlfive&&Close[0]>Position.AvgPrice+10*TickSize)
              {
              SetStopLoss(CalculationMode.Price, Low[2]-5*TickSize);
              DrawDiamond("Up Diamond4" + CurrentBar, false, 1, Low[1], Color.Green);
              DrawDiamond("Down Diamond4" + CurrentBar, false, 1, High[1], Color.Green);
              HochAußenkerze2= MAX(High, 1)[1];
              TiefAußenkerze2= MIN(Low, 1) [1];
              controlfive=false;
              }
              if (Close[0]>HochAußenkerze2&&!controlone&&!controltwo&&!contr olthree&&!controlfour&&!controlfive&&controlsix)
              {
              SetStopLoss(CalculationMode.Price, Low[0]-5*TickSize);
              DrawDiamond("Up Diamond5" + CurrentBar, false, 0, Low[0], Color.Cyan);
              DrawDiamond("Down Diamond5" + CurrentBar, false, 0, High[0], Color.Cyan);
              controlsix=false;
              }

              if (Close[0]<High[1]&&Close[0]>Low[1]&&!controlone&&!controltwo&&!controlthree&&!contro lfour&&!controlfive&&!controlsix&&controlseven&&Cl ose[0]>Position.AvgPrice+10*TickSize)
              {
              SetStopLoss(CalculationMode.Price, Low[2]-5*TickSize);
              DrawDiamond("Up Diamond6" + CurrentBar, false, 1, Low[1], Color.Green);
              DrawDiamond("Down Diamond6" + CurrentBar, false, 1, High[1], Color.Green);
              HochAußenkerze3= MAX(High, 1)[1];
              TiefAußenkerze3= MIN(Low, 1) [1];
              controlseven=false;
              }
              if (Close[0]>HochAußenkerze3&&!controlone&&!controltwo&&!contr olthree&&!controlfour&&!controlfive&&!controlsix&& !controlseven&&controleight)
              {
              SetStopLoss(CalculationMode.Price, Low[0]-5*TickSize);
              DrawDiamond("Up Diamond7" + CurrentBar, false, 0, Low[0], Color.Cyan);
              DrawDiamond("Down Diamond7" + CurrentBar, false, 0, High[0], Color.Cyan);
              controleight=false;
              }










              }


              if (BarsInProgress==1)
              {
              if (Opens[0][1]>Closes[0][0]&&Closes[0][0]>Opens[0][0]&&Opens[0][0]>Lows[0][0]+15*TickSize&&Highs[0][0]<Closes[0][0]+15*TickSize&&Lows[0][0]<MIN(Low,10)[1])
              {
              if (Highs[1][0]>Highs[0][0])
              EnterLong();
              }
              }




              }

              Comment


                #8
                Glad to hear that mko1983 - good work! I would then not use the Set methods but work with the Exit methods instead for your stops and targets, they would allow specifying a BarsInProgress to submit to as well :

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                672 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                379 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                111 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                577 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                582 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X