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

Strategy coss below Ray

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

    Strategy coss below Ray

    Hello, i want code in my strategy that if the price crossBelow a Ray then my longposition should be closed.

    i can draw the Ray but i know not the code to close the position if the price crosses down the ray .
    myRay = Draw.Ray(this, Close[0].ToString() + @" Ray_1", false, 6, (Low[0] - 0.1) , 0, Low[0], Brushes.Red, DashStyleHelper.Solid, 2);

    if ( (CrossBelow(Close, myRay, 0)))
    {

    ExitLong(Convert.ToInt32(DefaultQuantity), "", ""); // exit longposition
    }
    The code in red is wrong because i dont know the righr code for this action .

    #2
    Hello aktrader,

    Thank you for your note.

    You are checking if the price crossed myRay, however I see no such variable or object defined.

    I would suggest defining myRay as a variable, for example,

    double myRay = 50.50;

    That would be the static price of 50.50, since you are using a ray, it would be more complicated as their is a slope between point 1 and point 2, on each bar the price level changes. For example, I might use slope to find the slope value of the ray, which would be the change between point 1 and 2. Then say the current bar is half way between the point of 1 and 2, say 5 bars, you would add the slope*5 to point 1, and assign this value to myRay. If you wanted to project slope into the future past point 2, you would add 1 slope value per each bar past point 2.

    Please see,




    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by zstheorist, Today, 07:52 PM
    0 responses
    3 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    149 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Working...
    X