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

How to code enter and exit position message during manual trading

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

    How to code enter and exit position message during manual trading

    Dear AlgoTraders,

    I'm developing the script which draws objects when I trade manualy. The story started here



    and now I have another issue. I'd like that the script shows me whether I enter position or exit it.

    I code the case when I enter Long or Short, but I do not have any ideas how to code exit Long or Short.

    Please, help! I'm not good in programming and realy appreciate any help. The method which do all drawingns is below

    private void OnExecution(object sender, ExecutionUpdateEventArgs e)
    {

    if (e.Execution.Order != null)
    {
    if (e.Execution.Order.OrderState == OrderState.Filled)
    {

    double price = e.Price;
    double ts = TickSize;

    if(e.Execution.Order.OrderAction == OrderAction.Buy)
    {

    DrawArrowLine("k"+n,false,10,price+50*ts,0,price,C olor.Crimson,DashStyle.Solid, 3);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.ArrowLine)
    draw.Locked = false;
    }
    DrawText("n"+k,false, "Enter Long"+ "\n" +price, 10,price+50*ts,10,Color.Black,new Font("Calibri",14,FontStyle.Bold),StringAlignment. Center,Color.Transparent ,Color.Transparent,1);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.Text)
    draw.Locked = false;
    }
    n=n+1;
    k=k+1;
    return;
    }
    }

    }

    if (e.Execution.Order != null)
    {
    if (e.Execution.Order.OrderState == OrderState.Filled)
    {

    double price = e.Price;
    double ts = TickSize;

    if(e.Execution.Order.OrderAction == OrderAction.Buy)
    {

    DrawArrowLine("k"+n,false,10,price+50*ts,0,price,C olor.Crimson,DashStyle.Solid, 3);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.ArrowLine)
    draw.Locked = false;
    }
    DrawText("n"+k,false, "Exit Short"+ "\n" +price, 10,price+50*ts,10,Color.Black,new Font("Calibri",14,FontStyle.Bold),StringAlignment. Center,Color.Transparent ,Color.Transparent,1);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.Text)
    draw.Locked = false;
    }
    n=n+1;
    k=k+1;
    return;

    }
    }
    }

    if (e.Execution.Order != null)
    {
    if (e.Execution.Order.OrderState == OrderState.Filled)
    {

    double price = e.Price;
    double ts = TickSize;

    if(e.Execution.Order.OrderAction == OrderAction.Sell)
    {

    DrawArrowLine("k"+n,false,10,price+50*ts,0,price,C olor.Crimson,DashStyle.Solid, 3);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.ArrowLine)
    draw.Locked = false;
    }
    DrawText("n"+k,false, "Enter Short"+ "\n" +price, 10,price+50*ts,10,Color.Black,new Font("Calibri",14,FontStyle.Bold),StringAlignment. Center,Color.Transparent ,Color.Transparent,1);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.Text)
    draw.Locked = false;
    }
    n=n+1;
    k=k+1;
    return;

    }
    }
    }

    if (e.Execution.Order != null)
    {
    if (e.Execution.Order.OrderState == OrderState.Filled)
    {

    double price = e.Price;
    double ts = TickSize;

    if(e.Execution.Order.OrderAction == OrderAction.Sell)
    {

    DrawArrowLine("k"+n,false,10,price+50*ts,0,price,C olor.Crimson,DashStyle.Solid, 3);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.ArrowLine)
    draw.Locked = false;
    }
    DrawText("n"+k,false, "Exit Long"+ "\n" +price, 10,price+50*ts,10,Color.Black,new Font("Calibri",14,FontStyle.Bold),StringAlignment. Center,Color.Transparent ,Color.Transparent,1);
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.Text)
    draw.Locked = false;
    }
    n=n+1;
    k=k+1;
    return;

    }
    }
    }



    }

    #2
    Hello alex_bbfg,

    Thank you for your post.

    Are you speaking of manual exits that you have placed? Or drawing objects you wish to place to indicate it is time to exit?

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    10 responses
    71 views
    0 likes
    Last Post ETFVoyageur  
    Started by Zeezee, Today, 12:45 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by ldanenberg, Today, 03:19 PM
    0 responses
    2 views
    0 likes
    Last Post ldanenberg  
    Started by TheTradingMantis, 01-19-2023, 02:05 AM
    42 responses
    914 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by _Zero_, 04-10-2020, 03:21 PM
    144 responses
    7,896 views
    6 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X