• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator proprieties

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

  • frankduc
    started a topic indicator proprieties

    indicator proprieties

    In my indicator i use a <, if i change it for > it will modified the result of the calculation.
    Is it possible to add a check box in the indicator proprieties of my indicator so i dont have to get into the ninjascript editor to change the sign to compile?

    TY

  • NinjaTrader_PaulH
    replied
    Hello frankduc,

    Thanks for your reply.

    C# syntax is capitalization sensitive, GetValueAt and Getvalueat are two different things.



    Leave a comment:


  • frankduc
    replied
    sorry i solve that problem and got another one but the message was delete before you answer.
    I am having an error for a second bool.
    it says something like bool dont have a definition for Getvalueat?

    is also link to "local" variable?




    the problem is a got 2 fibo

    double lowestclose = Low.GetValueAt(ChartBars.GetBarIdxByX(chartControl , cursorPointX));
    double highestclose = High.GetValueAt(ChartBars.GetBarIdxByX(chartContro l, cursorPointX));


    double fibo = ((Close.GetValueAt(CurrentBar) - lowestclose)) / (cmaave - lowestclose);

    if(High)
    {
    fibo = ((Close.GetValueAt(CurrentBar) - lowestclose)) / (cmaave - lowestclose);
    }
    else
    {
    fibo = ((Close.GetValueAt(CurrentBar) - highestclose)) / (cmaave - highestclose);
    }

    Seems i cant switch to highestclose without creating a new fibo1 and it will affect where i used fibo elsewhere.
    the only solution seems to create another indicator with highestclose instead.

    ty
    Last edited by frankduc; 06-19-2019, 08:23 AM.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello frankduc,

    Thanks for your reply.

    In the code you have posted, you are defining fibo as a "local" variable used within the High { } context so if you are using fibo elsewhere then it would advise it does not exist.

    In general, it is a better idea to define your variables at the class level so that you don't have to define them locally unless you intend to use them within that { } local context.

    Leave a comment:


  • frankduc
    replied
    I am having an error for a second bool.

    it says something like bool dont have a definition for Getvalueat?
    what does it mean?

    ty

    Last edited by frankduc; 06-19-2019, 07:09 AM.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello Frankduc,

    Thanks for your reply.

    If I understand correctly, based on your comment of "looks better now", the issue is resolved.

    Leave a comment:


  • frankduc
    replied
    The problem comes from the fact that it was already an if statement before making it a bool. If i remove the ";" ill get an error.

    Before:

    if(closePrice > cma)
    {

    counter++;

    sumOfVolumesx += Bars.GetVolume(barIndex);
    }


    After:

    if (Reverse)
    {
    if(closePrice > cma);
    }
    else
    {
    if(closePrice < cma);
    }

    {

    counter++;

    sumOfVolumesx += Bars.GetVolume(barIndex);
    }



    now i modified for :

    if (Reverse)
    {
    if(closePrice > cma)
    {

    counter++;

    sumOfVolumesx += Bars.GetVolume(barIndex);
    }

    }
    else
    {
    if(closePrice < cma)

    {

    counter++;

    sumOfVolumesx += Bars.GetVolume(barIndex);
    }

    }


    looks better now
    Last edited by frankduc; 06-17-2019, 10:05 AM.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello frankduc,

    Thanks for your reply.

    You have terminated both if statements with a ";" so I don't see how they perform any action.

    The use of the bool is correct assuming you are saying that Reverse = true; is done in state.SetDefault and not directly ahead of the if statements.

    Leave a comment:


  • frankduc
    replied
    Simply put:

    Reverse = true;

    if (Reverse)
    {
    if(closePrice > cma);
    }
    else
    {
    if(closePrice < cma);
    }


    #region Properties
    [NinjaScriptProperty]
    [Display(Name="Reverse", Order=1, GroupName="Parameters")]
    public bool Reverse
    { get; set; }
    #endregion


    It looks like its returning the same result in one case or the other. Can you confirm that is what you told me.
    Last edited by frankduc; 06-17-2019, 09:33 AM.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello frankduc,

    Thanks for your reply.

    Based on your reply I suspect that you went into the section that says, "#region NinjaScript generated code. Neither change nor remove." and would advise to never do anything in this area.

    I recommend that you delete that script and start over as I have no idea what the consequences are of the deleting action.

    All you need is the example I provided for your bool, the other information was an attempt to provide you with source code you could use but I did not think you would do anything in the region that advises neither change nor remove as this is not advised.

    In State.SetDefaults, you would need to set the default state like: MyBoolInput = true;

    The following code would be outside of OnBarUpdate but would be within the public class

    .[NinjaScriptProperty]
    [Display(Name="MyBoolInput", Order=1, GroupName="Parameters")]
    public bool MyBoolInput
    { get; set; }




    Leave a comment:


  • frankduc
    replied
    I did what you said. Gave the bool the name Reverse. It created
    bool Reverse = true; in the new indicator in
    if (State == State.SetDefaults)
    Created also 3 type of properties one for the indicator
    : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    , one for
    MarketAnalyzerColumn : MarketAnalyzerColumnBase
    and the last for Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase,.

    Do i need the last 2. I mean i only need it for the indicator so i dropped the last 2.

    When compile it says Reverse do not exist in the context in my copy/paste indicator. Does it have to do with the 2 last properties i dropped? Unless Reverse need to be define. Like bool Reverse = ??? but is that part going above Reverse = true or below?

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello frankduc,

    Thanks for your reply.

    You would need to create a Public bool for the input. You can name the bool as you wish.

    If I may suggest, an easier path here is to use the Ninjascript wizard process and use the indicator wizard (accessed by the "+" in the Ninjascript editor to create an indicator (for keep example source code) and through that process you can create inputs of types bool, int, double, string and brush (and I suggest one of each) and then create through that process one plot and one line and when you click finish the wizard will create all of the structures for the inputs, plot and line and then you can copy/use these as needed in your code. Here is a reference to help: https://ninjatrader.com/support/help...?ns_wizard.htm

    Here is an example of a public bool input as found in #region Properties:

    [NinjaScriptProperty]
    [Display(Name="MyBoolInput", Order=1, GroupName="Parameters")]
    public bool MyBoolInput
    { get; set; }


    In State.SetDefaults, you would need to set the default state like: MyBoolInput = true;

    Leave a comment:


  • frankduc
    replied
    If i do this there's nothing in the proprieties indicator like mybool

    bool myBool = true;

    if (myBool)
    {
    if(closePrice > cma);
    }
    else
    {
    if(closePrice < cma);
    }

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello frankduc,

    Thanks for your post.

    Yes, you can create a public bool (or other variable) that you can use to change behavior within the script.
    The bool would choose between the two sets of calculations (one with < and the other with >).

    if (myBool)
    {
    // this path/calculation if myBool is true
    }
    else
    // this path/calculation if myBool is false
    }

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by chartish, Today, 04:43 PM
0 responses
7 views
0 likes
Last Post chartish  
Started by Trader17, Today, 04:07 PM
0 responses
4 views
0 likes
Last Post Trader17  
Started by GussJ, Today, 01:30 PM
2 responses
18 views
0 likes
Last Post GussJ
by GussJ
 
Started by GARZONJ, Today, 12:25 PM
3 responses
17 views
0 likes
Last Post NinjaTrader_PaulH  
Started by RandanAL, Today, 11:53 AM
1 response
13 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X