Announcement

Collapse
No announcement yet.

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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    60 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    148 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    98 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    286 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X