Announcement

Collapse
No announcement yet.

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,

    https://ninjatrader.com/support/help.../?draw_ray.htm
    https://ninjatrader.com/support/help...-us/?slope.htm

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by JTizz, Today, 01:20 PM
    0 responses
    2 views
    0 likes
    Last Post JTizz
    by JTizz
     
    Started by omermirza, Today, 12:39 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by mballagan, Today, 01:02 PM
    0 responses
    5 views
    0 likes
    Last Post mballagan  
    Started by larkmail, Today, 12:30 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by Danila, Today, 11:08 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X