I need help
Modify this code so that it gives me a signal and returns the actions that break the maximum or minimum of the breakout in a period of 15 minutes at the market opening. Thank you
If it breaks the breakout high, the candle should end up green and if it breaks the breakout low, the candle should end up red.
Modify this code so that it gives me a signal and returns the actions that break the maximum or minimum of the breakout in a period of 15 minutes at the market opening. Thank you
If it breaks the breakout high, the candle should end up green and if it breaks the breakout low, the candle should end up red.
Code:
input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST = 945;
def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;
def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];
def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];
plot lowCloud = if openingRange then openingRangeLow else Double.NaN;
plot highCloud = if openingRange then openingRangeHigh else Double.NaN;
lowCloud.SetDefaultColor(Color.GRAY);
highCloud.SetDefaultColor(Color.GRAY);
AddCloud(lowCloud, highCloud, Color.GRAY, Color.GRAY);
input tradeEntryStartTimeEST = 945;
input tradeEntryEndTimeEST = 1100;
def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;
plot tradeEntryLowExtension = if tradeEntryRange then openingRangeLow else Double.NaN;
plot tradeEntryHighExtension = if tradeEntryRange then openingRangeHigh else Double.NaN;
tradeEntryLowExtension.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
tradeEntryHighExtension.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
tradeEntryLowExtension.SetStyle(Curve.SHORT_DASH);
tradeEntryHighExtension.SetStyle(Curve.SHORT_DASH);
tradeEntryLowExtension.SetDefaultColor(Color.GRAY);
tradeEntryHighExtension.SetDefaultColor(Color.GRAY);
input entryType = {default wickTouch, closeAbove};
def bearEntryCondition;
def bullEntryCondition;
switch (entryType){
case wickTouch:
bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
case closeAbove:
bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
}
def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];
def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];
def range = openingRangeHigh - openingRangeLow;
def halfRange = range / 2;
def midRange = openingRangeLow + halfRange;
plot midRangePlot = if tradeEntryRange then midRange else Double.NaN;
midRangePlot.SetStyle(Curve.SHORT_DASH);
midRangePlot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
midRangePlot.SetDefaultColor(Color.YELLOW);
def halfwayUpsideProjection = openingRangeHigh + halfRange;
plot halfwayUpsideProjectionPlot = if bullishORB and tradeEntryRange then halfwayUpsideProjection else Double.NaN;
halfwayUpsideProjectionPlot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
halfwayUpsideProjectionPlot.SetDefaultColor(Color.LIGHT_GREEN);
def halfwayDownsideProjection = openingRangeLow - halfRange;
plot halfwayDownsideProjectionPlot = if bearishORB and tradeEntryRange then halfwayDownsideProjection else Double.NaN;
halfwayDownsideProjectionPlot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
halfwayDownsideProjectionPlot.SetDefaultColor(Color.LIGHT_RED);
def fullUpsideProjection = openingRangeHigh + range;
plot fullUpsideProjectionPlot = if bullishORB and tradeEntryRange then fullUpsideProjection else Double.NaN;
fullUpsideProjectionPlot.SetDefaultColor(Color.GREEN);
fullUpsideProjectionPlot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def fullDownsideProjection = openingRangeLow - range;
plot fullDownsideProjectionPlot = if bearishORB and tradeEntryRange then fullDownsideProjection else Double.NaN;
fullDownsideProjectionPlot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fullDownsideProjectionPlot.SetDefaultColor(Color.RED);
alert(bullishORB, "leoBuy", alert.bar, sound.ding);
alert(bullEntryCondition, "leoBuy", alert.bar, sound.ding);
alert(openingRangeHigh, "leoBuy", alert.bar, sound.ding);
Attachments
Last edited: