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

plot last ask/bid

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

    plot last ask/bid

    this is my first indicator i am trying to do. i could use some help here.
    i want to plot the last ask and bid so i canplce my stops without getting hit quickly.
    hereis my attempt and following are the issues i have
    1. it seems to plot at every bar. i want to plot it as 4 dots identifying the last BID and 4 dots identifying the last ASK price only
    2. i only see one of them. its the Bid or ASk. i dunno which one is being displayed. maybe i made a mistake in my plot but cannot figure out.
    3. i used the wizard to state i want 1 plot but changed the code to add another. how do i get back to the wizard to modify the indicator.
    /// plot the ask bar
    ///</summary>
    [Description("plot the ask bar")]
    publicclass PlotAsk : Indicator
    {
    #region Variables
    // Wizard generated variables
    privateint myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion
    ///<summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.Blue, PlotStyle.Dot, "Bid line"));
    Add(
    new Plot(Color.Red, PlotStyle.Dot, "Ask line"));
    ChartOnly =
    true;
    AutoScale =
    false;
    CalculateOnBarClose =
    false;
    DisplayInDataBox =
    false;
    Overlay =
    true;
    PriceTypeSupported =
    false;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Plot0.Set(GetCurrentBid());
    Plot0.Set(GetCurrentAsk());
    }
    #region Properties
    [Browsable(
    false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }
    [Description(
    "")]
    [Category(
    "Parameters")]
    publicint MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    hey junkone,

    If you export this indicator I will take a look. Its too sloppy to do things this way.
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      i realise it now that thee is a different way of sharing NT indicators. i got the indicator that i wanted in the library so i am not going to pursue this any more. thanks for your time.

      Comment


        #4
        Hello,

        To determine which is plotting you can always go to Tools>Output window, then include a Print(GetCurrentBid); etc. and see which is matching the plot.

        However the source of your issue is that you have two Plot0's. You will need to name the second one something else like Plot1 or AskPlot, etc. Next, you will need to go into your Properties and include code to manage the new plot like you already have for Plot0.

        I suggest looking at the code of an indicator that plots two lines for an example.
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        11 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        7 views
        0 likes
        Last Post elirion
        by elirion
         
        Working...
        X