Laggy scanner alerts

PennyFlipper101

New member
VIP
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
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;
 
Solution
The scanner only auto-updates roughly every five to eight minutes. Using total[1] will also mean that the previous hour's bar crossed the zero line, which I believe would make the condition an hour late. Try it with just Total.

Joshua

Well-known member
VIP
The scanner only auto-updates roughly every five to eight minutes. Using total[1] will also mean that the previous hour's bar crossed the zero line, which I believe would make the condition an hour late. Try it with just Total.
 
Last edited:
Solution

Similar threads

Top