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

Risk Reward Indicator , convert to seperate plots

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

    Risk Reward Indicator , convert to seperate plots

    I have created a risk reward indicator that uses rays to draw price areas where my stops and target will be entered if i want to take a trade there. I would like to convert all my rays into separate plots due to do the chart wont render about half the time when I restart Ninja trader. Plus I would like to customize it a little more efficiently. I will paste what the code looks like that I am using. I someone can just convert 2 of the rays to plots for me I should be able to finish the rest

    Thanks
    Quantismo
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class CenTexRiskReward : Indicator
    {
    #region Variables

    private Brush lineColorPrice = Brushes.Chartreuse;
    private Brush lineColorStop= Brushes.Red;
    private Brush lineColorTarget = Brushes.Yellow;
    private int lineWidthStops = 2;
    private int lineWidth = 10;
    private int lineWidthPrice = 1;
    private DashStyleHelper lineStyle = DashStyleHelper.Solid;
    private int rayLength = 0;
    private double Stops = 12; // The amout of ticks risked
    private double TargetRatio = 3;
    private double Target = 0.0; // will be the reward computed in the OnstateChange area




    #endregion


    private void Initialize()
    {
    Calculate = Calculate.OnEachTick;
    IsOverlay = true;

    IsAutoScale = false;

    }

    protected override void OnStateChange()
    {
    switch (State)
    {
    case State.SetDefaults:
    Name = "CenTexRiskReward";
    Description = "Risk Reward Markers will keep your focus on R&R";

    Target = Stops * TargetRatio;
    //################################################## ################################################## ###






    //################################################## ################################################## ###



    Initialize();
    break;
    }
    }

    protected override void OnBarUpdate()
    {


    if (Close[0] > 0)
    {


    if (CurrentBar > 12)

    //################################################## ################################################## ########
    //test area

    Draw.Ray(this,"CurrRay #1", false, rayLength, Close[0] - (Stops) * TickSize, 0, Close[0] - (Stops) * TickSize, lineColorTarget, lineStyle, lineWidthStops);

    Draw.Ray(this,"CurrRay #2", false, rayLength, Close[0] + (Stops) * TickSize, 0, Close[0] + (Stops) * TickSize, lineColorStop, lineStyle, lineWidthStops);

    Draw.Ray(this,"CurrRay #3", false, rayLength, Close[0], 0, Close[0], lineColorPrice, lineStyle, lineWidthPrice);

    Draw.Ray(this,"CurrRay #4", false, rayLength, Close[0] + (Target) * TickSize, 0, Close[0] + (Target) * TickSize, lineColorTarget, lineStyle, lineWidth);

    Draw.Ray(this,"CurrRay #5", false, rayLength, Close[0] - (Target) * TickSize, 0, Close[0] - (Target) * TickSize, lineColorStop, lineStyle, lineWidth);

    #2
    Hello quantismo,

    Thanks for opening the thread.

    While it is against our policy to create/modify code for our clients at request, I could provide you some direction for you to create the plots in a new indicator and add them to your current indicator.

    In the attached video I have created an indicator that assigns the plot's value to a user defined input. The same approach can be used to create plots and assign a value other than the user defined PriceLevel.

    Demo: https://www.screencast.com/t/xJZAnbmb

    I also suggest creating a blank indicator and then an indicator that only implements one plot. The resulting code can then be compared to see how the Indicator wizard creates plot syntax.

    Documentation items that can be referenced for further understanding and usage can be found below. This documentation is publicly available.


    Also, if it interests you, we can have a representative of our EcoSystem reach out with additional information on NinjaScript consultants who would be happy to create this indicator for you at your request. If that is the case, please let us know.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    27 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 04-23-2024, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    193 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,235 views
    0 likes
    Last Post xiinteractive  
    Working...
    X