mark.917
Member
The code below is my approximation of Advanced GETs XTL indicator. When a buy or sell condition is met, I would like to plot a horizontal line at the entry price beginning on the setup bar and going to the right. The entry price is one-half the length of the setup bar added to the high for a long and subtracted from the low for a short. The setup bar is when there is a change in bar color from gray to blue/red. Sample chart and description from the GET manual shown below.
The first bar that changes the color is called the FIRST BREAK OUT BAR. Add half the length of this Break Out Bar to obtain a BUY LEVEL.
Buy (go long) when the market penetrates the BUY LEVEL provided the following holds true: a) XTL does not detect and display a bar with the opposite Trend color. In the above illustration, the buy was generated with an Up Trend signal. Therefore, you should not see any Red color bars prior to the prices penetrating the BUY LEVEL. Neutral (Black) bars are okay and does not alter the strategy.
Code:
#
# Approximation of the Advanced GET XTL Indicator
# by Mark.917
input length = 20;
input strength = 35;
DefineGlobalColor("Bullish", Color.BLUE);
DefineGlobalColor("Bearish", Color.RED);
DefineGlobalColor("Sideways", Color.GRAY);
def cci = CCI(length);
def trendUp = cci > strength;
def trendDn = cci < -strength;
def noTrend = cci <= strength and cci >= -strength;
AssignPriceColor(if trendUp then globalColor("Bullish")
else if trendDn then globalColor("Bearish")
else globalColor("Sideways"));
def longSetup = noTrend[1] and trendUp;
def shortSetup = noTrend[1] and trendDn;
def longEP = high+((high-low)/2);
def longST = low-(high-low);
def shortEP = low-((high-low)/2);
def shortST = high+(high-low);
plot longEntry = if longSetup then longEP else Double.NaN;
plot longStop = if longSetup then longST else Double.NaN;
plot shortEntry = if shortSetup then shortEP else Double.NaN;
plot shortStop = if shortSetup then shortST else Double.NaN;
longEntry.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
longEntry.SetDefaultColor(Color.CYAN);
longStop.SetPaintingStrategy(PaintingStrategy.DASHES);
longStop.SetDefaultColor(Color.RED);
shortEntry.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
shortEntry.SetDefaultColor(Color.CYAN);
shortStop.SetPaintingStrategy(PaintingStrategy.DASHES);
shortStop.SetDefaultColor(Color.RED);
#
# end
#
The first bar that changes the color is called the FIRST BREAK OUT BAR. Add half the length of this Break Out Bar to obtain a BUY LEVEL.
Buy (go long) when the market penetrates the BUY LEVEL provided the following holds true: a) XTL does not detect and display a bar with the opposite Trend color. In the above illustration, the buy was generated with an Up Trend signal. Therefore, you should not see any Red color bars prior to the prices penetrating the BUY LEVEL. Neutral (Black) bars are okay and does not alter the strategy.
Last edited: