I have been using this Bid/Ask spread lines code for day trading code for the past year from Mobius and all of a sudden this week it is not working where price will move but the lines are not keeping up with the Bid/Ask in real time. If someone can please help or have another current Bid/Ask with lines on chart code that works would be great. Thank you
Here is the code:
# Bid / Ask Dynamic Line
# Mobius
# Chatroom 09.20.2013
input LineLimit = 200;
input SizeLabels = yes;
def bid = close(priceType = "Bid");
def ask = close(priceType = "Ask");
def barNumber = BarNumber();
def Mark = close(priceType = "Mark");
def Last = close(priceType = "Last");
#Dynamic_Line
script dynamic {
input LineLimit = 200;
input c = close;
def bar = if IsNaN(c)
then bar[1]
else BarNumber();
def ThisBar = HighestAll(bar);
def cLine = if bar == ThisBar
then c
else Double.NaN;
plot P = if ThisBar - LineLimit <= bar
then HighestAll(cLine)
else Double.NaN;
}
plot B = dynamic(linelimit = LineLimit, c = bid);
B .SetDefaultColor(Color.GREEN);
B.SetStyle(Curve.FIRM);
B .SetLineWeight(1);
plot A = dynamic(linelimit = LineLimit, c = ask);
A .SetDefaultColor(Color.MAGENTA);
A.SetStyle(Curve.FIRM);
A .SetLineWeight(1);
def Dir = if Last == bid then 1 else 0;
def NotDir = if (Last != bid) or (Last != ask) then 1 else 0;
AddCloud(if Dir then A else Double.NaN, if Dir then B else Double.NaN, Color.GREEN, Color.CURRENT);
AddCloud(if !Dir then A else Double.NaN, if !Dir then B else Double.NaN, Color.RED, Color.CURRENT);
AddCloud(if NotDir then A else Double.NaN, B, Color.GRAY, Color.CURRENT);
AddLabel(no, Concat("ASK: ", AsDollars(close(priceType = "ASK"))), if Dir then Color.GREEN else Color.ORANGE );
AddLabel(no, Concat("BID: ", AsDollars(close(priceType = "BID"))), if Dir then Color.ORANGE else Color.GREEN);
def spread = close(priceType = PriceType.ASK) - close(priceType = PriceType.BID);
def spread_l1 = 0.05;
def spread_l2 = 0.15;
AddLabel(1, "Spread: " + spread, if spread <= spread_l1 then Color.GREEN else if spread_l1 < spread <= spread_l2 then Color.YELLOW else COLOR.RED);
# End Code Bid Ask Lines
Thank you
J