input OpenTime = 0930;
input DurationHours = 1;
def durationSec = DurationHours * 60 * 60;
def secondsPassed = SecondsFromTime(OpenTime);
def Markethours = if secondsPassed > 10
and secondsPassed < durationSec then 1 else 0;
input length = 12;
input over_Bought = 65;
input over_Sold = 35;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DEF RSI1 = RSI-RSI[1];
DEF RSI2 = RSI-RSI[2];
DEF RSI3 = RSI[1] - RSI[2];
DEF BEAR1 = IF (RSI<35 OR RSI[1]<35) THEN 1 ELSE 0;
DEF BULL1= IF(RSI >= RSI[1]*1.2 OR
RSI >= RSI[1]*1.10 AND RSI[1]>= RSI[2]*1.01 OR
RSI >= RSI[1]*1.05 AND RSI[1]>= RSI[2]*0.95 AND RSI[2]>= RSI[3]*.90 OR
RSI >= RSI[1]*.95 AND RSI[1]>= RSI[2] AND RSI[2]>= RSI[3]*.95 OR RSI>60 AND RSI1 >30)
THEN 1 ELSE 0;
ADDLABEL (Markethours ,
IF BULL1==1
THEN " COMPRAR && HOLD OPTIONS "
ELSE " SALGA Â VENDA TODO Â SALGA Â NO ENTRE Â WAIT Â WAIT ", COLOR.WHITE);
def qty = GetQuantity();
# ADDLABEL (Markethours , IF BULL1==1
##AddOrder(OrderType.Sell_auto, qty>0 && bull1==0, high, 1);
AddOrder(OrderType.BUY_auto , bull1==1, low, 1);
AddOrder(OrderType.Sell_auto, bull1==0, high, 1);
===========
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V*(C-L)/(H-L);
def Selling = V*(H-C)/(H-L);
# Selling Volume
Plot SV = selling;
SV.setPaintingStrategy(PaintingStrategy.Histogram);
SV.SetDefaultColor(Color.white);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);
# Buying Volume
# Plot BV = Buying;
# Note that Selling + Buying Volume = Volume.
Plot BV = volume;
BV.setPaintingStrategy(PaintingStrategy.Histogram);
BV.SetDefaultColor(Color.Dark_Green);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);
input length = 50;
plot Vol = volume;
plot VolAvg = Average(volume, length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);
Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));
Comments
Post a Comment