CarlosTrades
New member
First off all credit to the foundation of this code to Mobius.
Could someone please help/walk me through making a strategy out of this? I want to buy long when I get a plotlong signal if the next candle close after the plotlong signal is > than the plotlong signal candle close. For short trades would be the opposite ( the close of the candle after plot short signal candle is < candle close of the plotshort signal)
input AtrMult = .7;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input showsignals = yes;
#def
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
def Vinculum = ST;
def plotlong = if ST crosses below close then 1 else 0;
def plotshort = if ST crosses above close then 1 else 0;
#plots
plot x = plotlong;
Alert (plotlong, Sound.Ring);
x.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
AssignPriceColor(if x then Color.WHITE else Color.CYAN);
plot y = plotshort;
Alert (Vinculum, Sound.Ring);
y.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_DOWN);
AssignPriceColor(if x then Color.CYAN else Color.WHITE);
x.AssignValueColor(if close < ST then Color.RED else Color.CYAN);
AssignPriceColor(if PaintBars and close < ST
then Color.RED
else if PaintBars and close > ST
then Color.GREEN
else Color.CURRENT);
x.SetHiding(!showsignals);
y.SetHiding(!showsignals);
Could someone please help/walk me through making a strategy out of this? I want to buy long when I get a plotlong signal if the next candle close after the plotlong signal is > than the plotlong signal candle close. For short trades would be the opposite ( the close of the candle after plot short signal candle is < candle close of the plotshort signal)
input AtrMult = .7;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input showsignals = yes;
#def
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
def Vinculum = ST;
def plotlong = if ST crosses below close then 1 else 0;
def plotshort = if ST crosses above close then 1 else 0;
#plots
plot x = plotlong;
Alert (plotlong, Sound.Ring);
x.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
AssignPriceColor(if x then Color.WHITE else Color.CYAN);
plot y = plotshort;
Alert (Vinculum, Sound.Ring);
y.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_DOWN);
AssignPriceColor(if x then Color.CYAN else Color.WHITE);
x.AssignValueColor(if close < ST then Color.RED else Color.CYAN);
AssignPriceColor(if PaintBars and close < ST
then Color.RED
else if PaintBars and close > ST
then Color.GREEN
else Color.CURRENT);
x.SetHiding(!showsignals);
y.SetHiding(!showsignals);