Black_Flag cloud to watchlist


Category:
0
0

Hello Pete      Is it possible to add the blackflag indicator to a watchlist…If the cloud is green have a green column and if the cloud is red have a red column…I’m trying to get multiple time frames in agreement…

Attachments:
Marked as spam
Posted by (Questions: 49, Answers: 42)
Asked on May 28, 2020 4:12 pm
82 views
0
Private answer

There are three different conditions which produced a green or red cloud in this code. I can only provide a solution for the first as I am running out of time to complete this. The code uses an ATR Trailing stop. So I gutted that code and installed a reference to the built-in study named ATRTRailingStop in it's place. This make the code less complex but I do not do this unless the space requires a short solution (short meaning fewest lines of code).

input trailType = {default modified, unmodified};
input ATRPeriod = 28;
input ATRFactor = 5;
input firstTrade = {default long, short};
input averageType = AverageType.WILDERS;
input fib1Level = 61.8;
input fib2Level = 78.6;
input fib3Level = 88.6;
Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);
def trail = ATRTrailingStop(trailType, ATRPeriod, ATRFactor, firstTrade, averageType);
def stateLong = low > trail[1];
def stateShort = high < trail[1];
def BuySignal = Crosses(stateLong, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(stateShort, 0, CrossingDirection.ABOVE);
def ex = if BuySignal then high else if SellSignal then low else if stateLong then Max(ex[1], high) else if stateShort then Min(ex[1], low) else ex[1];
def TrailingStop = trail;
def Extremum = ex;
def f1 = ex + (trail - ex) * fib1Level / 100;
def f2 = ex + (trail - ex) * fib2Level / 100;
def f3 = ex + (trail - ex) * fib3Level / 100;
def l100 = trail + 0;
def Fib1 = f1;
def Fib2 = f2; def Fib3 = f3;
plot data = f1 > f2;
AssignBackgroundColor(if f1 > f2 then Color.GREEN else Color.RED);

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 29, 2020 7:37 am