// if C > Hi_D do this and nothing else
{
Plot(Hi_D,"",colorGreen,styleDashed|styleNoRescale | styleNoLabel,null,null,0,0,2);
GfxTextOut("ENTER", X+10 , ENTERA );
}
It is fundamental to understand the difference between array and scalar value and differences between if-else and IIF IIf function versus if statement
These subjects were addressed dozens of times on the forum and in the manual. Please read.
l'm still confused is there an example of a simple way that a condition can call a function or a procedure or you can just set a path to follow under certain circumstances?
As explained in documents I pointed out you need a SCALAR VALUE (single number) to use if-else. Neither C or Lo_D are scalar values. These are arrays (multiple values, separate value for each bar). To use if-else you need a value for single bar. Such as Close[ 0 ] - that is the close for very first bar.
Did you read the documents carefully? I mean really carefully. I guess not. You responded in 15 minutes. That is not enough time to read the documents I pointed out.
You really need to read and understand. Posting copy-paste code is useless as it does not make you understand.
There are plenty of examples in the Knowledge Base including
that show how to write text conditionally on chart
So GFX is not a good option but it seems more manageable with plottext.
I'll play around with the plottext as for now I get print on both sides since GFX cant be called under a condition.
thanks for the help
This was the code by passing the Null to the color where I didn't need text, instead of using GFX.
It's simple enter signal , that plots a line with the "Enter" on far right. Additional stops , targets can be added using similar code. Still needs some cleanup but the idea is coming together. Its for intra-day trades with a simple momentum daily signal.
// Short Enter
Lo_D = TimeFrameGetPrice( "L", inDaily, -1 );
x= BarCount -1 ;shift =10; width =5;
color = LastValue( IIF( C < Lo_D, colorwhite, colorBlack ) );
bkcolor = LastValue( IIF( C < Lo_D, colorred, colorblack ) );
ENTER = LO_D; ENTERA= LastValue(ENTER); ENTERB= LineArray( x-shift, ENTERA, x-width, ENTERA);
Plot(IIF( C < lo_D, ENTERB, Null ),"",colorRed,styleDashed|styleNoRescale | styleNoLabel,null,null,10,0,2);
PlotText( "ENTER" ,x+10, enterA, color, bkcolor, yoffset = 0 );