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

Don't plot on chart - Need help

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

    Don't plot on chart - Need help

    Hi, my name is Wiktor and I come from Poland ) my grammar english is not really impressive. i'm begginer trader and i try write my first indicator.

    When i write :

    protected override void Initialize()
    {

    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    CalculateOnBarClose = false;
    Overlay = true;
    PriceTypeSupported = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    // Condition set 1 kupuj
    if ( Close[0] > MAX(High, 2)[0] )

    {
    DrawArrowUp("My up arrow" + CurrentBar, 0, Low[0] +- 5 * TickSize, Color.Blue);
    DrawLine("My line" + CurrentBar, 0, Low[0],35, Low[0], Color.Blue);
    }



    I would like trade Long when price breakout MAX from 2 bars, but that indicator don't plot on chart, where is bug ?? What I write wrong ?? Help me

    #2
    Yek shamash! (my spelling is probably bad as well but hopefully you know what I mean)

    The problem is with your logic. Your condition will !never be true since the close will !never be greater than the highest highest high of the last two bars. At best, it may equal. What you likely want to check for is if the current bar close is greater than the highest high of the past two bars excluding the current bar.

    if (Close[0] > MAX(High, 2)[1])
    // Do something

    is what you want. You will also want to add a check like this before hand.

    if (CurrentBar < 1)
    return;

    See this link for more info - http://www.ninjatrader-support.com/v...ead.php?t=3170
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Max238, Today, 01:28 AM
    2 responses
    26 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by Shansen, 08-30-2019, 10:18 PM
    25 responses
    949 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by JonesJoker, 04-22-2024, 12:23 PM
    8 responses
    41 views
    0 likes
    Last Post JonesJoker  
    Started by timko, Today, 06:45 AM
    0 responses
    3 views
    0 likes
    Last Post timko
    by timko
     
    Started by Waxavi, 04-19-2024, 02:10 AM
    2 responses
    39 views
    0 likes
    Last Post poeds
    by poeds
     
    Working...
    X