Code entry/exit strategy without using buffer?

 

I put an indicator on the chart and created a sub-chart and drag drop moving average on the sub-chart. I want to code a signal when moving average crossing the indicator then open or close the trade.

The problem is that the moving average value difference is large (like photo attached) so that I can't use buffer to do simple code such as this,

if(indicator[1] < MA[1] && indicator[0] > MA[0])
        //then buy

Is there any other way to code it without using buffer?

Files:
new_SS.png  19 kb
 
Seems you are watching 2 indicators that have a totally different range values into the same window.

In this case, "crosses" between 2 lines are just a visual thing, crosses will change if you change the scale of the chart.

In few words, you are trying to code something that has no sense to be coded.

The only reasonable thing is to apply MA to indicator values (instead of price) and check crosses between indicator value and ITS OWN average.
 
I don't know that it's just a visual only, Tried to zoom in and out and it shows different result. Thanks for your help
 

Actually everything you can compare visually, you can also compare mathematically. sometimes it is difficult but sometimes it is even not as complicated as it seems at first glance. in short, you have to buffer the values of the indicators. Then normalize or standardize them using whatever method suits for your datatype. You don´t have to come up with something complicated yourself and you can use basic mathematical formulas which are available everywhere.  you can use similar simple scaling example like that val1 = 0.2543; val2= 1045; n_max = 100; n_min = 0;

minmaxscaling() return {((val - minval)/(maxval - misval))*(n_max - n_min)+n_min }

scaled_val1 = minmaxscaling(val1,mathmin(val1,val2), mathmax(val1,val2), n_min, n_max ) and do with scaled_val2 same  to get right value. now values of both indicators on a 0-100 scale and they are mathematically comparable. If the values are still not suitable , they can calibrated to match each other.

Reason: