Thank you very much, Rob and Js!! After using “” If FD <> 0 and “” I did it!! It is working.
I still have to clean up the code but here is the progress so far.
Defparam CalculateOnLastBars = 5000
//
//AvgPeriod=14 // opens & closes 1 day back
//pubs = ( Dclose(2) - Dopen(1) ) // yesterday close -> today open
//profs = ( Dopen(1) - Dclose(1) ) // today open -> today close
//pubsAvg = average[AvgPeriod](pubs)
//profsAvg = average[AvgPeriod](profs)
//return pubsAvg as "pub", profsAvg as "pros", 0 as "zero line"
fade1=10
fade2=100
fade3=200
dis1=1.5
dis2=2.5
dis3=3
dis4=4.5
dis5=5
plus1=1
atr = averagetruerange[10](close)*0.5
ABSProfessionalslope=ABS(slopePro)
a0=1
a1=5
a2=20
s0=20
s1=40
pub=open-close[1]
pro=close-open
Avepub=average[24](pub)
Avepro=average[24](pro)
////////////////profe slope //////////////////
sum3= (Avepro -Avepro [1])+(Avepro[1] -Avepro [2])+(Avepro[2] -Avepro [3])
slopePro =sum3/3
if slopePro > slopePro[1] then
PubSlope=1
DRAWTEXT("➚",barindex,dis1, Dialog, Standard, 20) COLOURED(255,0,0)
endif
//////////////publi slope //////////////////
slopPub = (Avepub -Avepub [1])
if slopePro > slopePro[1] then
ProSlope=-1
DRAWTEXT("↘",barindex,-dis1, Dialog, Standard, 20) COLOURED(0,0,255)
endif
//////////////END slope //////////////////
a=25
pub1=ExponentialAverage(open)- ExponentialAverage (close)[1]
pro1=ExponentialAverage (close)- ExponentialAverage (open)
publi1=average[a](pub1)
profe1=average[a](pro1)
b=5
pub2=ExponentialAverage(open)- ExponentialAverage (close)[1]
pro2=ExponentialAverage (close)- ExponentialAverage (open)
publi2=average[b](pub2)*10
profe2=average[b](pro2)
////////////////profe 1D //////////////////
FDpro=profe2-profe2[1]
if profe2 > profe2[1] then
DRAWTEXT("U",barindex,dis5, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf profe2 < profe2[1] then
ProDecend=-1
DRAWTEXT("Dp",barindex,dis4, Dialog, Standard, 20) COLOURED(0,0,225)
endif
//////////////profe 2D //////////////////
SDpro=FDpro-FDpro[1]
if FDpro <> 0 and SDpro > 0 then
ProCon=-1
DRAWTEXT("Vp",barindex,dis2, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf FDpro <> 0 and SDpro < 0 then
DRAWTEXT("A",barindex,dis3, Dialog, Standard, 20) COLOURED(0,0,225)
EndIf
/////////////END 1D 2D //////////////////
//////////////publi 1D //////////////////
FD=publi2-publi2[1]
FD=publi2-publi2[1]
if publi2 > publi2[1] then
DRAWTEXT("U",barindex,-dis4, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf publi2 < publi2[1] then
DRAWTEXT("D",barindex,-dis5, Dialog, Standard, 20) COLOURED(0,0,225)
endif
//////////////publi 2D //////////////////
SD=FD-FD[1]
if FD <> 0 and SD > 0 then
DRAWTEXT("V",barindex,-dis2, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf FD <> 0 and SD < 0 then
DRAWTEXT("A",barindex,-dis3, Dialog, Standard, 20) COLOURED(0,0,225)
EndIf
/////////////END 1D 2D //////////////////
//////Condition////////////////
if ProDecend=-1 AND ProCon=-1 AND PubSlope=1 AND ProSlope=-1 then
DRAWTEXT("P",barindex,-6, Dialog, Standard, 20) COLOURED(0,0,225) //DRAWARROWup(barindex,-6) COLOURED(0,0,255,fade2)
endif
DRAWHLINE (0) COLOURED (0, 0,0,100)
// rat=0.05*Avepub/Avepro
return Avepub*a0 as "Pub", Avepro*a0 as "Professional", publi1*40 COLOURED(0, 0, 255) as "Publi1", profe1*20 COLOURED(255, 0, 255) as "Profe1", publi2 COLOURED(0, 0, 255) as "Publi2", profe2*a1 COLOURED(255, 0, 255) as "Profe2", slopPub*s1 COLOURED(0, 0, 255) as "slopPub", slopePro*s0 COLOURED(255, 0, 0) as "slopeAvepro",ABSProfessionalslope*10+5 COLOURED(255, 0, 255) as "ABSproslop" //, rat as "ratio" //COLOURED(255, 0, 0) COLOURED(0, 255, 0),
Regarding in the above code, ” if ProDecend=-1 AND ProCon=-1 AND PubSlope=1 AND ProSlope=-1 then ” attached picture
However, is it possible to have advice on how to call previously used if statement condition, please? ”
I do not want the “P” printed everywhere as attached picture…… I only want the P printed only if the above-mentioned 4 conditions are met.