Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding up/down arrows to Sto chart.

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

    Adding up/down arrows to Sto chart.

    I have stochastics as panel 2 on my charts. I would like to have a down arrow drawn on the sto chart when it crosses below 80 and an up arrow drawn when crosses above 20. this seams simple enough and may have been discussed before but I can't seem to get it to work.

    Thanks.

    #2
    Hello TraderThor, and thank you for your question. All the below code will go into your OnBarUpdate routine. I will assume the following settings :

    Code:
    [FONT=Courier New]int DPeriod = 3;
    int KPeriod = 14;
    int smoothing = 7;
    int lookbackPeriod = 3;
    int upperBound = 80;
    int lowerBound = 20;[/FONT]
    [FONT=Courier New]bool autoScale = false;
    Color upArrowColor = Color.Green;
    Color downArrowColor = Color.Red;
    [/FONT]
    I will also assume that you are interested in your Stochastics K series. If you are interested in the D series you will need to change the code on your end.

    First, we need to see if the Stochastics indicator crossed our barriers. That code is

    Code:
    [FONT=Courier New]// Stochastics indicator documented here
    // http://ninjatrader.com/support/helpGuides/nt7/stochastics.htm[/FONT]
    
    [FONT=Courier New]// http://ninjatrader.com/support/helpGuides/nt7/crossbelow.htm[/FONT]
    [FONT=Courier New]if (CrossBelow(Stochastics(DPeriod, KPeriod, smoothing).K, upperBound, lookbackPeriod))
    {
        // Draw our down arrow
    }
    // http://ninjatrader.com/support/helpGuides/nt7/crossabove.htm
    if (CrossAbove(Stochastics(DPeriod, KPeriod, smoothing).K, lowerBound, lookbackPeriod))
    {
        // Draw our up arrow
    }
    [/FONT]
    As far as drawing the arrows, you will need to review the code sample here and replace the two appropriate commented out lines with your code :

    Code:
    [FONT=Courier New]// http://ninjatrader.com/support/helpGuides/nt7/drawarrowup.htm
    DrawArrowUp("UpArrow" + CurrentBar, autoscale, 0, lowerBound, upArrowColor);
    [/FONT]


    Code:
    [FONT=Courier New]// http://ninjatrader.com/support/helpGuides/nt7/drawarrowdown.htm
    DrawArrowDown("DownArrow" + CurrentBar, autoscale, 0, upperBound, downArrowColor);
    [/FONT]



    Please let us know if there are any other ways we may help.
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    160 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    307 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    348 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    178 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X