Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order rejected

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

  • NinjaTrader_AlanP
    replied
    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.

    Leave a comment:


  • esignal
    replied
    🙁..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, 04:08 PM.

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    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.

    Leave a comment:


  • esignal
    replied
    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

    Leave a comment:


  • NinjaTrader_AlanP
    replied
    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.

    Leave a comment:


  • esignal
    started a topic Order rejected

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by DiverG20, Today, 10:23 AM
0 responses
4 views
0 likes
Last Post DiverG20  
Started by caacapital, Today, 10:10 AM
0 responses
3 views
0 likes
Last Post caacapital  
Started by SuneSorgenfrei, Today, 09:29 AM
0 responses
6 views
0 likes
Last Post SuneSorgenfrei  
Started by dodoei, Today, 07:24 AM
0 responses
8 views
0 likes
Last Post dodoei
by dodoei
 
Started by thecashguys, Today, 06:13 AM
0 responses
10 views
0 likes
Last Post thecashguys  
Working...
X