Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Bollinger and CalculateOnBarClose = false

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

  • fisagol
    replied
    Thank you very much for the reply, I had not occurred!.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello fisagol,

    Thanks for your post.

    This can be handled by using bool logic in each of the conditions. We can use 2 bool variable to control this. Lets call them upArrowDrawn and downArrowDrawn, they would need to be initialized to true in the variable declarations area.

    Code:
    if ((CrossAbove(Close, Bollinger(stddev,period).Upper, 1)) && downArrowDrawn) 
    {
    
    DrawArrowUp(CurrentBar.ToString(), true, 0, GetCurrentAsk();, Color.DodgerBlue);
    downArrowDrawn = false;  // set to false to prevent any further up arrows
    upArrowDrawn = true;       // set to true so next arrow drawn would be down arrow
    }
    
    if (CrossBelow(Close, Bollinger(stddev,period).Lower, 1) && upArrowDrawn) 
    {
    DrawArrowDown(CurrentBar.ToString(), true, 0, GetCurrentBid(), Color.Fuchsia) ;
    upArrowDrawn = false;     // set to false to prevent further down arrows
    downArrowDrawn = true;  // set to true so next arrow drawn will be up arrow.
    }

    Leave a comment:


  • fisagol
    started a topic Bollinger and CalculateOnBarClose = false

    Bollinger and CalculateOnBarClose = false

    Hello everyone, I 'm trying to do a simple indicator Bollinger Bands and the option of CalculateOnBarClose = false. I want to detect when the price touches the upper band and also detect when the price touches the lower band.

    When the price first touches the upper Bollinger band I want to mark it with an arrow:


    This part I do so:

    if ((CrossAbove(Close, Bollinger(stddev,period).Upper, 1)))
    {

    DrawArrowUp(CurrentBar.ToString(), true, 0, GetCurrentAsk();, Color.DodgerBlue);
    }

    When the price first touches the lower Bollinger band I want to mark it with an arrow:


    This part I do so:

    if (CrossBelow(Close, Bollinger(stddev,period).Lower, 1))
    {
    DrawArrowDown(CurrentBar.ToString(), true, 0, GetCurrentBid(), Color.Fuchsia) ;
    }
    But doing so what I get is that whenever the price hits the upper or lower Bollinger band draws an arrow, and this is not exactly what I want.


    I want exactly, when the price first touches the upper Bollinger band draw an arrow . And not redraw an upward arrow until it has not produced before a downward arrow.

    For example , it is well to understand what I want, An upward arrow and the next arrow is to be drawn can not be bullish must be a downward arrow is drawn.

    ThankYou very much!

Latest Posts

Collapse

Topics Statistics Last Post
Started by cre8able, Yesterday, 04:22 PM
1 response
13 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by stafe, 04-15-2024, 08:34 PM
5 responses
28 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by StrongLikeBull, Yesterday, 04:05 PM
1 response
12 views
0 likes
Last Post NinjaTrader_Gaby  
Started by Mestor, 03-10-2023, 01:50 AM
14 responses
375 views
0 likes
Last Post z.franck  
Started by molecool, 10-09-2017, 10:48 AM
5 responses
1,621 views
0 likes
Last Post trader-ap  
Working...
X