Need help to find highest value of an array...

#1
How do i find the highest value of an array or how do i find the highest value in a +ve supertrend , i tried using HHV & highest function but counldn't get the signals that i wanted
so plz help me with this (plz see pic for clear understanding)

CODE

_SECTION_BEGIN("My first trading Strategy");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates); //Enable X-Axis (Date/Time Axis)
Plot(Close,"Candles",colorDefault,styleCandle); //Plot Candles
_SECTION_END();// SUPERTRENT FUNCTION //
function FunctionST (Period, Multiplier)
{
ATR_Val=ATR(Period);
UpperBand=LowerBand=final_UpperBand=final_LowerBand=SuperTrend=0;
// CALCULATE SUPERTRENT //
for( i = Period; i < BarCount; i++ )
{
UpperBand=((High + Low)/2) + Multiplier*ATR_Val;
LowerBand=((High + Low)/2) - Multiplier*ATR_Val;
final_UpperBand = IIf( ((UpperBand<final_UpperBand[i-1]) OR (Close[i-1]>final_UpperBand[i-1])), (UpperBand), final_UpperBand[i-1]);
final_LowerBand = Iif( ((LowerBand>final_LowerBand[i-1]) OR (Close[i-1]<final_LowerBand[i-1])), (LowerBand), final_LowerBand[i-1]);

SuperTrend = IIf(((SuperTrend[i-1]==final_UpperBand[i-1]) AND (Close<=final_UpperBand)),final_UpperBand,
IIf(((SuperTrend[i-1]==final_UpperBand[i-1]) AND (Close>=final_UpperBand)),final_LowerBand,
IIf(((SuperTrend[i-1]==final_LowerBand[i-1]) AND (Close>=final_LowerBand)),final_LowerBand,
IIf(((SuperTrend[i-1]==final_LowerBand[i-1]) AND (Close<=final_LowerBand)),final_UpperBand,0)))); }
Plot( SuperTrend, "SuperTrend", (IIf( SuperTrend>Close, ParamColor("Resistance", colorRed ), ParamColor( "Support", colorGreen ))), ParamStyle("Style") | styleThick | styleLine );
Return SuperTrend;
}Periods_set = Param("Periods", 1, 1, 50 );
Multiplier_set = Param("Multiplier ", 1, 1, 10 );
Multiplier = Multiplier_set;
Period = Periods_set ;SuperTrend = FunctionST(Period,Multiplier);buuy = supertrend<C;
seel= supertrend>C;cond = Highest(buuy);Sell = supertrend>C ;
Buy = LastValue(Highest(buuy));Buy = ExRem(Buy,Sell); //remove excessive buy signals
Sell = ExRem(Sell,Buy); //remove excessive sell signalsPlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45); (edited)
 

Attachments

#2
Can you explain the logic you are using to generate buy/sell signal. In your code buuy = supertrend<C; and seell = supertrend>C . In this the value of buuy and seell can only be 0 or 1. This you have followed up with Highest(buyy) which will always return 1 and hence latest() will also return 1.
 
#3
hello jinujose , thanks for your reply

As I am new to coding I don’t understand how to build these logics,

The logic that I had pasted in query is not correct and this isn’t where my signals need to appear.

I want signals to appear when 1st candle of current +ve supertrend need to appear above high of prev +ve super trend high.

I wasn’t sure which function do I need to use( hhv or highest), if I need to used 1 of these do I need to plot lastvalue along with this or ??????(I am confused).



Plz see this pics you will understand the logic that I want

Thank you….
 

Attachments

Similar threads