# Cross function No output

I am trying to get buy, and sell signals from the following code:

``````
GraphXSpace=7;

n=Optimize("ZIG",9,5,50,1);
per=Optimize("rsi",28,5,50,1);

Var = Zig(RSI(per), n);

//Plot(Var, "", 39);

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
//Plot( TEMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );

Tma = TEMA( P, Periods);

//Plot(Tma, "", colorRed, styleLine);

``````

I can see the output from the above code using _TRACE and verify it using the Plot function.

However, when I add the following code, it doesn't produce any result. I have confirmed using the _TRACE function which shows only '0' as output.

``````Buy = Cross(Var, Tma) ;
Sell = Cross(Tma, Var) ;
Short =Cross(Tma, Var) ;
Cover = Cross(Var, Tma) ;
``````

Appreciate it if someone can point out errors in my above codes.

@Wyatt_Earp, although _TRACE() is very useful in many cases, in this one, I suggest using an exploration to examine the values ​​you're using to set up your buy/sell rules.

Depending on the price of the instrument you may or may not get results!
If the price is above 100 the cross will never happen as the RSI is a value bounded between 0 and 100 (and this applies also to its derived value using Zig()).

And when, by chance there is a cross (i.e. the price is in a range similar to the value of the RSI) , it doesn't seem significant to me in any way.

Try adding this snippet below your code (apply it to a single instrument) and see the actual values used in your formula.

``````Buy = Cross( Var, Tma ) ;
Sell = Cross( Tma, Var ) ;
Short = Cross( Tma, Var ) ;
Cover = Cross( Var, Tma ) ;

AddColumn( RSI( per ), "RSI" );
AddColumn( Var, "Var = Zig(RSI)" );
AddColumn( Sell, "Sell = Cross(Tma, Var)", 1 );
AddColumn( Short, "Short = Cross(Tma, Var)", 1 );
AddColumn( Cover, "Cover = Cross(Var, Tma)", 1 );
if (Status("action") == actionExplore)
SetSortColumns( -2 ); // order results by recent date
``````
3 Likes