Support and Resistance not working

Resistance = Close >= Study("Resist", 1);
Support = Close <= Study("Supp", 1);

Buy = Resistance OR Support;
//Sell = 0;
//Buy = ExRem(0, 0);
//Sell = ExRem(Sell, Buy);

//Buy = Cross(Close, Study("Resist", 1));

AlertIF( Buy, "SOUND C:\Users\owner\Music\8.wav", "Audio alert", 1 );

//Turnover
AvgPrice = (O+H+L+C)/4;
Turnover = (Avgprice * Volume);
TurnoverAvg = MA(Turnover, 20);
VolumeAvg = MA(Volume, 20);
VolumeDiff = Volume - VolumeAvg;
VolumePct = (VolumeDiff / VolumeAvg) * 100;

//Previous Close
PrevClose = Ref(C, -1);
TtD_Change = ROC(C,1);

Filter = Buy;
//Filter = Resistance OR Support;
//Action = WriteIf(Buy, "BUY", " ");

SetSortColumns ( -9 );
AddColumn(C, "Last ", 2.2, colorWhite, IIf(C>Study("Ra"),colorGreen,colorBlack));
AddColumn(Study("Resist"), "Resistance Level", 2.2, colorWhite, colorBlack);
AddColumn(Study("Supp"), "Support Level", 2.2, colorWhite, colorBlack);
AddColumn(V,"Volume",1.2,IIf(V>VolumeAvg,colorGreen,colorRed));
AddColumn(VolumePct,"Volume % change",1.3, IIf(VolumePct>0,colorGreen,colorRed));
AddColumn(Turnover, "Value", 1,IIf(Turnover>TurnoverAvg,colorGreen,colorRed));
AddColumn(TtD_Change,"% Change",1.3,IIf(TtD_Change>0,colorGreen,colorRed));

@waves, I see that this is your first post, but I still feel obliged to remind you that when you post some code, you should always use the mandatory tags as explained here.

Moreover, in general, you should make an effort to better explain your issue (code alone, sometimes, in not enough).

I did not test your code, but in any case, I wonder if the ChartID parameter in your Study() calls is the correct one, as explained in the documentation.

CHARTID - identifies the chart pane where the study was drawn - you can find out what is the chart ID for given chart by looking in Parameters dialog, Axes & Grid, Miscellaneous: Chart ID or using GetChartID() AFL function.

Please, follow the above recommendations and provide additional feedback.

In addition to @beppe's comments, please note that the documentation for the Study() function says that AmiBroker only accepts two letter codes for the Study ID.

2 Likes