Place a mark at a specific bar

Hello,

How can mark a specific Bar in Explore ? For example, I want to put an Arrow or mark a different color at the bar, Low= LLV (L, 50) ? I am trying to write code to explore those stoks when the current Low price approach to a previous Trough, for example, LLV(L, 50). Thanks!

1 Like

@Laserman you can find many examples in the user guide and on this forum. Also, it is usually a good idea to post whatever you have tried and show the users so they can help you solve your problem.

For your specific question there are many different ways to output an Exploration to show different conditions. An example,

lv50 		= LLV( Low, 50 );
Condition	= L == lv50;

Filter = 1;
Condition_color = IIf( Condition, colorRed, colorDefault );
AddColumn( Low, "Low" );
AddColumn( lv50, "LLV( Low, 50 )" );
AddColumn( Condition, "Condition", 1.2, colorDefault, Condition_color );

Run on a given date and on a Watch List may produce this type of output.
image

Or more simple,

// Explore //
Filter = 1;
AddColumn( Low, "Low", 1.2, colorDefault, IIf( L == LLV( Low, 50 ), colorRed, colorDefault )); 

image

To explore symbols which approach a previous LLV you may use AlmostEqual and greater as > / smaller as < operators.

Also to approach previous LLV you would have to use Ref() function since LLV includes current bar's value.

ll = LLV(L, 50);
prev_ll = Ref(ll, -1); 

percent = 0.5;// approach range

color_cond = AlmostEqual(L, prev_ll, percent*1e5) AND L > prev_ll;

Filter = 1;//color_cond;

AddColumn(L, "Low", 1.2, -1, IIf(color_cond, colorRed, -1));

Hello @Portfoliobuilder and Fxshrat,

Thank you very much for your help ! The following is my code for this pattern-Explorer and the explorer-result. I hope I can place a mark (an Arrow, or Text, or diffrent color) at the Trough-Bar (MSP) and the Peak-Bar (PKP) on the Chart when I veiw the results from the Explore-Report. Thank you again !

image

image

// CK-Date=2020-03-12, Ticker=AAXN
X=100;
MSP=LLV(L,X); // How to place a Arrow Mark , or text mark , or Color mark at this Trough Bar on Chart ?
MSPB=LLVBars(L,X);
PKP=HHV(H,MSPB);// How to place a Mark at this Peak Bar ?
PKPB=HHVBars(H,MSPB);
AddColumn(MSP,"MSP");
AddColumn(MSPB,"MSPB");
AddColumn(PKP,"PKP");
AddColumn(PKPB,"PKPB");
AddColumn(Close, "Close");
UPPA=(PKP-MSP);
DNPA=(PKP-L);
PBRate=DNPA/UPPA;
AddColumn(PBRate, "PBRate");

Filter=Close>40 AND Close< 60 AND PBRate>0.9 AND MSPB>50 AND PKPB>15;

// CK-Date=2020-03-12, Ticker=AAXN
X=100;
MSP=L==LLV(L,X); // How to place a Arrow Mark , or text mark , or Color mark at this Trough Bar on Chart ?
MSPB=LLVBars(L,X);
PKP=HHV(H,MSPB);// How to place a Mark at this Peak Bar ?
PKPB=HHVBars(H,MSPB);
AddColumn(MSP,"MSP");
AddColumn(MSPB,"MSPB");
AddColumn(PKP,"PKP");
AddColumn(PKPB,"PKPB");
AddColumn(Close, "Close");
UPPA=(PKP-MSP);
DNPA=(PKP-L);
PBRate=DNPA/UPPA;
AddColumn(PBRate, "PBRate");
Filter=Close>40 AND Close< 60 AND PBRate>0.9 AND MSPB>50 AND PKPB>15;

//indicator
Plot(C,"Close",colorBlack,styleCandle);
PlotShapes(MSP*shapeUpArrow,colorGreen);

Hi Anthony,

Thank you!

I add your code but no change on the chart when I view the results from the Analysis report.
image

// CK-Date=2020-03-12, Ticker=AAXN
X=100;
AddColumn(X, "X");
MSP=LLV(L,X); // How to place a Arrow Mark , or text mark , or Color mark at this Trough Bar on Chart ?
MSPB=LLVBars(L,X);
PKP=HHV(H,MSPB);// How to place a Mark at this Peak Bar ?
PKPB=HHVBars(H,MSPB);
AddColumn(MSP,"MSP");
AddColumn(MSPB,"MSPB");
AddColumn(PKP,"PKP");
AddColumn(PKPB,"PKPB");
AddColumn(Close, "Close");
UPPA=(PKP-MSP);
DNPA=(PKP-L);
PBRate=DNPA/UPPA;
AddColumn(PBRate, "PBRate");

//indiccator
//Plot(C,"Close",colorBlack,styleCandle);
//PlotShapes(MSP*shapeUpArrow,colorGreen);

Filter=Close>40 AND Close< 60 AND PBRate>0.9 AND MSPB>50 AND PKPB>15;

Plot(C,"Close",colorBlack,styleCandle);
PlotShapes(MSP*shapeUpArrow,colorGreen);

I also made a change to the following line in your original code;

MSP=L==LLV(L,X);

So, you should also update your formula.

Hi Anthony,

No results after update my formula. I can locate the MSP-Bar using my code and just need to place an Arrow mark on this specific Trough bar. The logic meaning will change a lot if I change the MSP=llv(L,X) to MSP=L==LLV(L,x). Could you show me your result (or a sample code) with an Arrow mark on charts ? Thank you! very much !

image

click the Apply button in the formula editor.

Hi Anthony,

I did but no change. Thank you!

use ticker symbol AAXN

image

Yes, I can find out the AAXN using my origina code but no reuslt if I update my original code to your code: MSP=L==LLV (L,X);

Please post your most recent code that you updated and are using.

image

I copied your code and Apply to "AAXN" but no result after "Explore"

You are not going to see any arrows on the top chart. Is that where your are looking for arrows ?

you will have to add some additional formula to the top chart code inorder to visualize the arrows.

If you click apply a separate chart window will open and display the arrows. What chart is at the very bottom of your image it is cut off , is this the chart that opened when you clicked apply button. if so, check for the arrows.