PureBytes Links
Trading Reference Links
|
I took the system I posted earlier that allows you to pick buy's and
sell's using the text tool, and added the Chandelier exit to it. The
inputs let you set the ATR lookback period.
/Greg
{==================================================================}
{ SYSTEM: MyEntry }
{ User picks the entry with the text tool, system exits with Chandelier
stop }
{ Note: since systems can't Plot, I am using Trendlines to show where
the stop is on the chart. Thus if more than 360 bars have stops,
subsequent bars won't show where the stop is. }
{
USAGE
Use the text tool to select the bar and place, for this sample, any of
"H", "L", "long", "short" on the chart. The click "Status" twice in
Format Analysis Techniques to cause the indicator to recalculate. This
way, the indicator can find the text you just entered.
You can put as many characters or strings on the chart as you wish. You
might even use "X" to force an exit.
}
input: fac(2.5), len(10);
var: handl(0), lab(""), gotLab(false);;
gotLab = false;
begin { examine all the text strings }
handl = text_getfirst(2);
while handl > 0 begin
lab = text_getstring(handl); { save the item's date, time, value
and handle }
if lab = "H" or lab = "L" or lab = "long" or lab = "short" or lab
= "X" then
{ is the label on this bar? }
if text_gettime(handl) = time then
if text_getdate(handl) = date then begin
gotLab = true;
end;
if gotLab then
handl = 0 { exit the loop }
else
handl = text_getnext(handl,2); { IMPORTANT -- infinite loop if
this is missing! }
end;
end;
if gotLab then begin { note that orders cannot be within loops }
if lab = "H" then buy at h stop
else if lab = "L" then sell at l stop
else if lab = "short" then sell at market
else if lab = "long" then buy at market
else if lab = "X" then begin
exitlong at market;
exitshort at market;
end;
end;
var: LongStop(0), ShortStop(0);
if marketposition <> 1 then
LongStop = -999999;
if marketposition <> -1 then
ShortStop = 999999;
LongStop = MaxList(MaxTradeHigh - fac * average(TrueRange,10),
LongStop);
ShortStop = MinList(MinTradeLow + fac * average(TrueRange,10),
ShortStop);
exitlong at LongStop stop;
exitshort at ShortStop stop;
var: han(0);
if marketposition = -1 then begin
if time <> time[1] then if shortstop[1] < 999999 then if han < 355
then begin
han = tl_new(date[1],time[1],shortstop[1], date,time,shortstop);
tl_setcolor(han,tool_cyan);
tl_setsize(han,0);
tl_setextright(han,false);
tl_setextleft(han,false);
end;
end;
if marketposition = 1 then begin
if time <> time[1] then if longstop[1] > -999999 then if han < 355
then begin
han = tl_new(date[1],time[1],longstop[1], date,time,longstop);
tl_setcolor(han,tool_cyan);
tl_setsize(han,0);
tl_setextright(han,false);
tl_setextleft(han,false);
end;
end;
|