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 f.saeidi, Today, 05:56 AM
    1 response
    3 views
    0 likes
    Last Post Jltarrau  
    Started by Jltarrau, Today, 05:57 AM
    0 responses
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Stanfillirenfro, Yesterday, 09:19 AM
    7 responses
    51 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by TraderCro, 04-12-2024, 11:36 AM
    4 responses
    70 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Mindset, Yesterday, 02:04 AM
    1 response
    15 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X