set column background based on VWAP and ema crossover


Category:
0
0

Hello

please can you help me with creating custom column for watchlist. Looking for 2 column

  1.  if the current price is over the Vwap then background color to be green else red include pre market.
  2.  if EMA 8 crossover 20SMA then background color to green and if 20 Sma crossover to 8 EMA then red color ( include premarket).

Please help me with this trying from a long time still cant figure it out

 

Marked as spam
Posted by (Questions: 12, Answers: 5)
Asked on March 1, 2019 9:49 pm
232 views
0

Hi, I notice here that is says resolved but I don’t see the resolution……can you point me in the right direction?

( at March 15, 2019 9:24 am)
0
Private answer

Your original question title “watchlist column” was to vague and did not describe your request for other viewers. I have updated the title to better reflect the context of your request.

Here is the code for the VWAP column.

def data = reference VWAP().VWAP;
AssignBackgroundColor(if close > data then Color.GREEN else Color.RED);

Here is the code for the ema cross. (this has already been asked and posted elsewhere in the forum)

input lengthOne = 8;
input lengthTwo = 20;
input maTypeOne = AverageType.EXPONENTIAL;
input maTypeTwo = AverageType.EXPONENTIAL;
input priceOne = close;
input priceTwo = close;
def maOne = MovingAverage(maTypeOne, priceOne, lengthOne);
def maTwo = MovingAverage(maTypeTwo, priceTwo, lengthTwo);
AssignBackgroundColor(if maOne > maTwo then Color.GREEN else Color.RED);

Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on April 5, 2019 7:34 am
0
Hello Pete. When I try to add the EMA code you provided above I receive a message stating "at least 1 plot should be defined" The column in the watchlist just says "loading"
( at June 15, 2019 11:02 am)
0

Add this line to the very bottom of the code I provided in my answer above:

plot data = maOne > maTwo;

( at June 15, 2019 2:01 pm)
0
Thank you Pete. The EMA works now after adding that last line of code. I tried using the code for the VWAP listed above but I'm getting the message stating "At least one plot should be defined" I tried adding "plot data = VWAP;" to the end of the code but that didn't work. Is there another line of code that should be used? Thank you!
( at June 16, 2019 7:26 am)
0

Change this:

def data = reference VWAP().VWAP;

To this:

plot data = reference VWAP().VWAP;

( at June 16, 2019 8:38 am)
0
Thank you Pete, it worked. I really appreciate your help.
( at June 16, 2019 8:57 am)