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 funk10101, Today, 09:43 PM
    0 responses
    2 views
    0 likes
    Last Post funk10101  
    Started by pkefal, 04-11-2024, 07:39 AM
    11 responses
    36 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Yesterday, 08:51 AM
    8 responses
    44 views
    0 likes
    Last Post bill2023  
    Started by yertle, Today, 08:38 AM
    6 responses
    25 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by algospoke, Yesterday, 06:40 PM
    2 responses
    24 views
    0 likes
    Last Post algospoke  
    Working...
    X