Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

need to stop calc and keep the actual parameters

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

    need to stop calc and keep the actual parameters

    Hello

    for the last days i been conding a strategy based in breack a level and after trow an fibo from the previously high till the second low swing anfter cross the level

    the problem is the strategy never stop the calc once there is a 3rt min the strategy uses the new min and never stop

    do you know how can i make the strategy use just the 2nd min after the break?(then i will place the order in the fivo level, etc..) and do not calculate more untill the price breack again the level?

    protected override void OnBarUpdate()
    {

    if (CurrentBar < BarsRequiredToTrade)
    return;
    if (CurrentBars[2] < BarsRequiredToTrade)
    return;
    if (BarsInProgress != 0)
    return;


    if (CurrentBars[0] < 5
    || CurrentBars[2] < 1)
    return;



    // Set 1 i set a level once is cros below
    if (CrossBelow(Closes[2], ConstantLines1.Line1, 1))
    {
    K1 = Line1;
    }



    // starst counting to know how many bars are after cros the level and after usit for refer the previous swing high
    if (CrossBelow(Close, K1, 1))
    {
    startbar = CurrentBar;

    }



    // Set 2 i set the 2 swing lows after the breack level and the swing ghig before ad i draw a fibo
    if ((Close[0] <= K1)
    && (Swing1.SwingLow[4] < Swing1.SwingLow[5]) && (Swing1.SwingLow[5] != FirstMin))
    {
    FirstMin = Swing1.SwingLow[4];
    SecondMin = FirstMin;
    FirstMin = Swing1.SwingLow[5];

    FirstHigh = Swing1.SwingHigh[(CurrentBar - startbar +2)];

    if (FirstMin <= K1)
    {
    Draw.FibonacciRetracements(this, @"kai2 Fibonacci extensions_1", false, 0, FirstHigh, 0, SecondMin);

    if (FirstMin != 0) ;
    Draw.Dot(this, @"diferentsTemps Dot_1", false, 0, FirstMin, Brushes.CornflowerBlue);

    if (SecondMin != 0)
    Draw.Dot(this, @"diferentsTemps Dot_2", true, 0, SecondMin, Brushes.GreenYellow);

    if (FirstHigh != 0)
    Draw.Diamond(this, @"diferentsTemps Diamond_1", true, 0, FirstHigh, Brushes.Red);
    }
    Attached Files

    #2
    Hello ernest93,

    It's a little difficult from the description to understand what you are asking for. Are you asking that once a condition becomes true that you prevent future conditions from becoming true? If so you would need to use a variable for that, likely a bool variable.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello ernest93,

      It's a little difficult from the description to understand what you are asking for. Are you asking that once a condition becomes true that you prevent future conditions from becoming true? If so you would need to use a variable for that, likely a bool variable.
      yes once i have setted the conditions i want to stop more conditions become true in a future, how can i do it?

      i mean i'm just using the firs 2 lows after breack a level but once i have 3 new mins the strategy take the 3rt min, so i want to stopit when i have the 2 firts min

      how can i use a bolean for this propuse?

      thanks

      Comment


        #4
        Hello ernest93,

        You can add a bool variable for that purpose.

        The condition which sets the value would need to check if the variable is false.

        The action of the condition which sets the value would also set the variable to true.

        That would mean the first time that condition becomes true it sets the bool to true, because the bool is part of the condition and its requirement is that it is false the condition would only become true once.

        You could reset the bool variable at a later time if the original condition should be able to work again.



        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello ernest93,

          You can add a bool variable for that purpose.

          The condition which sets the value would need to check if the variable is false.

          The action of the condition which sets the value would also set the variable to true.

          That would mean the first time that condition becomes true it sets the bool to true, because the bool is part of the condition and its requirement is that it is false the condition would only become true once.

          You could reset the bool variable at a later time if the original condition should be able to work again.


          Hello

          firts of all thanks for all your help



          okey now i setted some boolean value

          now i just need to know how i can reset de boolean after some minutes have passed / or the price crose above the level k1, would be better if i can reset de bool if the price crose avobe the level k1

          // set a boolen once i have 2 lower lows become true

          Boolean prova1 = (SecondMin < FirstMin);



          if (prova1 == false)
          {
          do the logic
          }

          //when i have 2 new mins after de level k1 swich the bool to true, (here i should to use the logic for enter in the market)

          if (prova1 == true)
          {


          Print("FUNCIONA!!");

          }

          afer this i need to reset the boolean once the price crose abobe the level k1


          i have tried ( but is not working...)

          if (CrossAbove(Close, K1, 1))
          {
          prova1 = false

          }



          thanks for your help
          Last edited by ernest93; 04-07-2022, 11:38 PM.

          Comment


            #6
            Hello ernest93,

            What you created is essentially what would work for resetting the variable, you created a condition which sets it to false. With the placement that will be false for the next bar, if you wanted to turn off the conditions then the crossabove condition would need to be the first condition.

            Code:
            if (CrossAbove(Close, K1, 1))
            {
            prova1 = false
            }
            if (prova1 == false)
            {
            do the logic
            }
            if (prova1 == true)
            {
            Print("FUNCIONA!!");
            }

            If you are not seeing the cross condition working I would suggest to print the values you are using:

            Code:
            Print(Time[0] + " " + Close[0] + " " + K1[0] + " " + Close[1] + " " + K1[1] );
            That would help to see what the values are and if a crossing could be possible.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            86 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            150 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            79 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            52 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            59 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X