Plot shapes don't appear on charts

Hi Guys

I've noticed that plotshapes don't appear on chart when the buy/sell occurs on a CS that has opened and closed at the same price. However the backtest shows that a buy or sell order has taken place on that day. The image below shows an example

Here is the line of code regarding the plotting of my shapes

PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone),colorBrightGreen,layer = 0, yposition = graph0, offset = 20, XShift = 0 );
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed,layer = 0, yposition = graph0, offset = -20, XShift = 0 );

Chart

Thanks for your help in understanding whats going on here

@kgalea,

One of the first things I try to do when attempting to work out an issue, is throw all the data into an exploration. That way I can see the status of all the variables that I am working with.

In you code segment, you are actually doing assignments to variables like ypostion and offset and xshift. This may be a carry over of your coding from languages that support named variables, but in AFL it is actually an assignment. While it should not cause an issue, I would recommend just putting the values in the PlotShape call.

2 Likes

Hello @snoopy.pa30

I do not understand how to use the exploration function although from this post is sounds very useful

When I run the exploration I get no results, do I need the Trace functions in my formula to view the exploration and if so I'd be grateful if you could provide me with a simple example.

@Random_Entry,

The Exploration requires that you have a "Filter" defining when to include a result, and the Columns that you want in your result. Here is a simple example:

// Simple Exploration

ma20 = MA(C,20);  // Calculate your values

Filter = 1;  // Shows EVERTHING
AddColumn(O, "Open");
AddColumn(H, "High");
AddColumn(L, "Low");
AddColumn(C, "Close");
AddColumn(MA20, "MA 20");  // Show your calculation

With the above, and the manual, you should start to see how useful and versatile the exploration is. You can show anything that you calculate (text and information fields as well).

2 Likes

thanks @snoopy.pa30 I'll play with that and hopefully expand my knowledge at an exponential rate :slight_smile:

Please ONLY put CODE, not everything (not entire post), in code tags.

Code tags are meant to surround ONLY the code so it can be copy pasted to formula editor without changes. Do NOT use it for entire post because first two sentences you wrote are NOT CODE.

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.