• 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

Order rejected

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

    Order rejected

    https://gyazo.com/f9d2dc5b890af8ef47a7ae707116f8d7



    if (Position.MarketPosition!=MarketPosition.Flat && BarsSinceEntryExecution() > 4)
    {
    ExitLong();
    ExitShort();
    }
    if (LucaCongestionBox().SPlot[0] == 1)
    {
    EnterLong();
    SetStopLoss(CalculationMode.Price, Low[1]);

    }
    else if (LucaCongestionBox().SPlot[0] == -1)
    {
    EnterShort();
    SetStopLoss(CalculationMode.Price, High[1]);

    }

    i don't understand what is the problem

    #2
    Hello esignal,

    Thank you for your note.

    Without the full code I’m unable to test on our end.

    The issue likely is related High[1], which is the high of the last bar, being lower or too close to the last price. I would suggest,

    1) Working your stops further from the current price, at least 3 ticks from current price.

    2) Adding a check to make sure the stop price is valid, for example, an if statement making sure your buy stop price is above the ask price, for example,

    Code:
    if(High[1] < GetCurrentAsk())
    {
    SetStopLoss(CalculationMode.Price, High[1]);
    }
    3) Adding print statements to confirm you are submitting your stops at valid levels. I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:

    https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

    I’ve provided a link covering debugging which you may find helpful.
    Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      you write :


      if(High[1] < GetCurrentAsk())
      {
      SetStopLoss(CalculationMode.Price, High[1]);
      }
      ok i understand.....
      i want this:

      if(High[1] < GetCurrentAsk())
      {
      SetStopLoss(CalculationMode.Price, High[1]);
      }
      else StopLossNExtCandle; =====> how i do it?
      StopLossNextCandle how i code it? thank

      Comment


        #4
        Hello Esignal,

        You could try under your else statement, saving the current bar to a variable, adding 1, then on the next bar checking if the current bar is equal to that value, if so, submit a stop loss.

        So create a global variable,

        Code:
        private double xCurrentBar;
        Then your else statement,

        Code:
        else
        {
        xCurrentBar = CurrentBar+1;
        }
        Then add another if statement to your code,

        Code:
        if(xCurrentBar == CurrentBar)
        {
        SetStopLoss(CalculationMode.Price, High[1]);}
        }
        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          🙁..i dont uderstand your code

          how do i code it if i want to cover position next candle ?
          Last edited by esignal; 03-21-2017, 05:08 PM.

          Comment


            #6
            Hello esignal,

            Saving the current bar to a variable and adding one, would then make the if statement,

            Code:
            if(xCurrentBar == CurrentBar)
            true on the next bar. I would suggest adding print statements to the code I provided to understand the logic. For example,
            Code:
            Print(CurrentBar.ToString());
            Print(xCurrentBar.ToString());
            I’ve provided a link to a youtube video which covers an example of using prints to understand behavior: https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

            Regarding how to convert the code I provided you to exit your position on the next bar rather than set a stop loss, you would want to use ExitLong/ExitShort methods for which are covered in the following section of our helpguide.

            https://ninjatrader.com/support/help...?exitshort.htm
            https://ninjatrader.com/support/help.../?exitlong.htm

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by scfnkysx, Today, 12:30 AM
            0 responses
            4 views
            0 likes
            Last Post scfnkysx  
            Started by jimloforkocv, Today, 12:16 AM
            0 responses
            4 views
            0 likes
            Last Post jimloforkocv  
            Started by claxxical, Yesterday, 10:00 PM
            0 responses
            8 views
            0 likes
            Last Post claxxical  
            Started by ct, Yesterday, 08:13 PM
            0 responses
            8 views
            0 likes
            Last Post ct
            by ct
             
            Started by Lumbeezl, Yesterday, 05:17 PM
            0 responses
            7 views
            0 likes
            Last Post Lumbeezl  
            Working...
            X