PennyFlipper101
New member
I'm having trouble getting accurate alerts with my scanner, I want my scanner to alert me when a symbol is added.
Here is my code, I want the alert to happen only exactly after the total crosses above zero I use it on the 1hr chart but typically get the alert too late is there something I should change to make it more accurate
Here is my code, I want the alert to happen only exactly after the total crosses above zero I use it on the 1hr chart but typically get the alert too late is there something I should change to make it more accurate
Code:
def ema1 = ExpAverage(close, 20);
def ema2 = ExpAverage(close, 50);
def ema3 = ExpAverage(close, 50);
def ema4 = ExpAverage(close, 200);
def distance1 = (ema1 - ema2);
def distance2 = (ema3 - ema4);
def zeroline = 0;
def total = (distance2 - distance1) * 100 / 2;
def BuySignal = total[1]crosses above 0;
def SellSignal = (EntryPrice() / 4) + EntryPrice();
def StopLoss = EntryPrice() - (EntryPrice() / 4);
AddOrder(OrderType.BUY_AUTO, BuySignal, open[1], 100, Color.LIGHT_GREEN, Color.LIGHT_GREEN,"BUY");
AddOrder(OrderType.SELL_AUTO, close is greater than SellSignal, SellSignal, 100, Color.YELLOW, Color.YELLOW,"25%");
AddOrder(OrderType.SELL_AUTO, close is less than StopLoss, StopLoss, 100, Color.WHITE, Color.WHITE,"SELL");
plot buy = total[1] crosses above 0 within 3 bars;