# AFL returns sell signal all the time

Hello All,

I have been able to calculate the vwap and and I have taken a diff of the close and vwap over the last x minutes and I have added buy and sell condition like this. The problem is it always returns a sell signal for all the bars irrespective of whether vwap_close is greater or less than vwap_close_stddev. I manually checked the values and they seem to be fine. Example. vwap_close is 7.5 and vwap_close_stddev is 64.6. Even in this case, a sell signal is returned. I am not very sure where am i going wrong. It could be something very silly. Please help

``````// Calculate vwap_close
vwap_close = Close - vwap;
vwap_close_stddev = StDev(vwap_close,2500,population = True);
Buy = (abs(vwap_close) > abs(vwap_close_stddev)) AND Close < ATP;
Sell = (abs(vwap_close) > abs(vwap_close_stddev)) AND Close > ATP;
``````

Try to understand the difference between state and signal form. Yours is state form.

You may use ExRem to get from state to signal (pulse) form.

``````Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
``````
2 Likes

Thanks fxshrat.

I tried

``````Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
``````

No signals get generated when I do this

Hi @satishvasu
I am really happy that you find a solution to your problem using the ExRem() function.

What I would like to ask you here, is because this is a very common question of many users.

If you like to help the community as fxshrat help you, can you please press The â€śSolvedâ€ť button on fxshrat post?

Donot press the heart button that means you like that post.

As @fxshrat is have a lot of Likes and I am jealous just press the solved button. So everyone knows this particular post is solved, and in the future they can visit your post to read what happen, and how you solve the code

Thank you

The â€śSolvedâ€ť button (checkmark) becomes visible when you click on (â€¦) button left to the â€śReplyâ€ť button

â€¦EDIT:
oups I just notice you may have a mistake
The ExRem() function goes below your Buy = something

``````Buy= some rules here ...
Sell = some rules here ...
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
``````
2 Likes

HI @PanoS,

The issue still persists. I have gone from too many signals to none now. Though I know that there are a few signals I am supposed to get by looking at the charts.

May be my understanding isnt right or thereâ€™s a different way of doing this.

I did click the â€ślikeâ€ť earlier for a post that was resolved. I will go back and click â€śsolvedâ€ť to that as well.

Thanks.

thats why we said post your code.
maybe you have so many BUY contition â€¦we camo guess your code

It was an issue with my code. I could fix it. The solution provided by fxshrat works.

Thanks for the help.