Put beginning & ending arrow when signal occurs and ends

C

ChiliPepper

New member
I've been trying to figure out how to put 1 single arrow when the signal occur and 1 arrow when the signal ends and no arrows in between, but I've having a hard time doing it. Can some one help? I tried using the BOOLEAN_ARROW_UP but it puts in a continuous row of arrows when the signal occurs for more than 1 candle. I've included a screen shot of what I want to do.

This code uses John Carter's Squeeze technique.



Code:
def EMA8 = ExpAverage(close, 8);
def EMA21 = ExpAverage(close, 21);

def bullish = if EMA8 > EMA21 then 1 else 0;
def squeeze = if TTM_Squeeze().SqueezeAlert >= 0 then 1 else 0;
def histSignal = if TTM_Squeeze().Histogram[0] > TTM_Squeeze().Histogram[1] then 1 else 0;
def greaterVol = VolumeAvg().Vol > VolumeAvg().VolAvg and close > close[1];
def wave = if TTM_Wave().Wave2High[0] > TTM_Wave().Wave2High[1] and TTM_Wave().Wave2Low[0] > TTM_Wave().Wave2Low[1] then 1 else 0;

def conditions = bullish and squeeze and histSignal and wave;
plot signal = conditions[1];
signal.SetDefaultColor(Color.WHITE);
signal.SetLineWeight(2);
 
Last edited by a moderator:
P

Pensar

Active member
VIP
@ChiliPepper Replace the plot in your code with this and add the desired color code lines. I included a couple notes.

Code:
# Using the exclamation point in front of a variable means "is not true". Saying "!conditions[1]" means that I want the conditions to be not true on the previous bar (finds the beginning or end of the conditions).
# the "low" and "high" assigns where you want the regular arrows to plot.
plot signal1 = if !conditions[1] and conditions then low else double.nan; # first arrow
     signal1.setpaintingstrategy(paintingstrategy.arrow_up);
plot signal2 = if conditions[1] and !conditions then high else double.nan; #second arrow
     signal2.setpaintingstrategy(paintingstrategy.arrow_down);
Here is similar way that returns the same as the above snippet, but this time using boolean arrows.

Code:
plot signal1 = !conditions[1] and conditions; # first arrow
     signal1.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
plot signal2 = conditions[1] and !conditions; # second arrow
     signal2.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
 

Similar threads

Top