I have written a code that is almost doing what I want. The only thing I would like to do but can't figure out, is to remove all previously drawn arrows, 2 of them, when I click on a new bar, while drawing the first new arrow. Right now, all old arrows remain on the chart. I tried with Arw_Delete but I couldn't get it to work. I have removed some of the math calculations. Any help is appreciated.
Code: Select all
Inputs: Mins_Add(60), iSquare(2), TL_Colour(green), Txt_Colour(green), Arrow_Size(8);
[ProcessMouseEvents = true];
[RecoverDrawings = false];
switch (getappinfo(aicalcreason)) begin
case CalcReason_MouseLClick : if MouseClickCtrlPressed and not MouseClickShiftPressed then begin
var : recalcpersist iPrice(0),
recalcpersist iBar1(0),
recalcpersist iBar2(0),
recalcpersist dt1(0),
recalcpersist dt2(0),
recalcpersist dt3(0),
recalcpersist Step1(0),
recalcpersist Step2(0),
recalcpersist Step3(0),
recalcpersist Step4(0),
recalcpersist Step5(0),
recalcpersist Step6(0),
recalcpersist beginPrice(0),
recalcpersist arrowID1(0),
recalcpersist arrowID2(0);
repeat
if 0 = iBar1 then begin
iBar1 = MouseClickDateTime;
dt1 = MouseClickBarNumber;
arrowID1 = Arw_New_BN(dt1, MouseClickPrice, true);
Arw_SetSize(arrowID1, Arrow_Size);
Arw_SetColor(arrowID1, TL_Colour);
break;
end;
if 0 = iBar2 then begin
iBar2 = MouseClickDateTime;
dt2 = MouseClickBarNumber;
arrowID2 = Arw_New_BN(dt2, MouseClickPrice, true);
Arw_SetSize(arrowID2, Arrow_Size);
Arw_SetColor(arrowID2, TL_Colour);
break;
end;
if 0 = iPrice then begin
iPrice = MouseClickDateTime;
dt3 = MouseClickPrice;
break;
end;
until (False);
if 0 <> iPrice and 0 <> iBar1 and 0 <> iBar2 then begin
Step1 = ---------------------------------
Step2 = --------------------------------
Step3 = --------------------------------
Step4 = Step3 - Step2;
Step5 = --------------------------------
Step6 = Round(Step5, 2);
draw_hor_line(Step6, iPrice, TL_Colour, Txt_Colour, " Buy Projection ");
iBar1 = 0;
iBar2 = 0;
iPrice = 0;
end;
end;
end;