Thought I would post this attempt at an AutoXTL. Maybe the guys at Advanced GET can refine it and improve upon it.
Note: If you are a subscriber of the Advanced GET studies, you can use this formula as a base for accessing the XTL stuff.
It's been a while since I ran this so I'm not sure if it still works. I think there were some bugs with the fib calculations being done... It does demonstrate how to access the XTL study and there are constants for the return values.
Note: If you are a subscriber of the Advanced GET studies, you can use this formula as a base for accessing the XTL stuff.
It's been a while since I ran this so I'm not sure if it still works. I think there were some bugs with the fib calculations being done... It does demonstrate how to access the XTL study and there are constants for the return values.
PHP Code:
function preMain() {
setStudyTitle("Auto XTL");
setPriceStudy(true);
}
var xtl = new GetXTLStudy(35);
var XTL_DOWN = 0
var XTL_UP = 1
var XTL_NEUTRAL = 2
var vLastXTL = null;
function main() {
var nState = getBarState();
if(nState == BARSTATE_CURRENTBAR)
return;
// Syntax is getValue(GetXTLStudy.XTL, 0, -xxx);
var vXTL = xtl.getValue(0);
if(vXTL == null)
return;
if(vLastXTL != null) {
if(vLastXTL == XTL_DOWN && vXTL != XTL_DOWN) {
var vH = high(-1);
var vL = low(-1);
if(vH == null || vL == null)
return;
var vHL50 = (vH - vL) * 0.5;
var vEntry = vL - vHL50;
var vExit = vH + vHL50;
var vStop = vEntry - (vExit - vEntry) * 1.618;
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vH, getCurrentBarIndex() + 5, vH, 2, Color.black, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vL, getCurrentBarIndex() + 5, vL, 2, Color.black, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vEntry, getCurrentBarIndex() + 5, vEntry, 2, Color.red, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vExit, getCurrentBarIndex() + 5, vExit, 2, Color.red, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vStop, getCurrentBarIndex() + 5, vStop, 2, Color.red, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vStop, getCurrentBarIndex()-1, vExit, 1, Color.yellow, "tag");
drawTextRelative(-1, vEntry, "Short@ " + vEntry,
Color.red, null,
Text.BOTTOM | Text.RIGHT | Text.ONTOP | Text.BOLD,
null, null, "BuyEntry" + getValue("rawtime"));
drawTextRelative(-1, vExit, "Cover@ " + vExit,
Color.red, null,
Text.BOTTOM | Text.RIGHT | Text.ONTOP | Text.BOLD,
null, null, "SellEntry" + getValue("rawtime"));
drawTextRelative(-1, vStop, "Stop@ " + vStop,
Color.red, null,
Text.BOTTOM | Text.RIGHT | Text.ONTOP | Text.BOLD,
null, null, "StopEntry" + getValue("rawtime"));
} else if(vLastXTL == XTL_UP && vXTL != XTL_UP) {
var vH = high(-1);
var vL = low(-1);
if(vH == null || vL == null)
return;
var vHL50 = (vH - vL) * 0.5;
var vEntry = vH + vHL50;
var vExit = vL - vHL50;
var vStop = vEntry + (vEntry - vExit) * 1.618;
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vH, getCurrentBarIndex() + 5, vH, 2, Color.black, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vL, getCurrentBarIndex() + 5, vL, 2, Color.black, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vEntry, getCurrentBarIndex() + 5, vEntry, 2, Color.blue, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vExit, getCurrentBarIndex() + 5, vExit, 2, Color.blue, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vStop, getCurrentBarIndex() + 5, vStop, 2, Color.blue, "tag");
addLineTool(LineTool.SEGMENT, getCurrentBarIndex()-1, vStop, getCurrentBarIndex()-1, vExit, 1, Color.yellow, "tag");
drawTextRelative(-1, vEntry, "Buy@ " + vEntry,
Color.blue, null,
Text.BOTTOM | Text.RIGHT | Text.ONTOP | Text.BOLD,
null, null, "BuyEntry" + getValue("rawtime"));
drawTextRelative(-1, vExit, "Sell@ " + vExit,
Color.blue, null,
Text.BOTTOM | Text.RIGHT | Text.ONTOP | Text.BOLD,
null, null, "SellEntry" + getValue("rawtime"));
drawTextRelative(-1, vStop, "Stop@ " + vStop,
Color.blue, null,
Text.BOTTOM | Text.RIGHT | Text.ONTOP | Text.BOLD,
null, null, "StopEntry" + getValue("rawtime"));
}
}
vLastXTL = vXTL;
}