Not sure what I did wrong in this code but it is not returning +1, 1 or 0 in my market analyzer. I am using 200 bars as look back. Any help is appreciated.
Part of code below:
protected override void OnBarUpdate() { if (CurrentBar<3) return; int dist=1; if(TickSize == .01) dist = 20; else dist = 2; if(EMA (Close,20)[0]<WMA (Close,40)[0] && SMA (Close,10)[0]<WMA(Close,40)[0] && SMA (Close,13)[0]<WMA(Close,40)[0] && (EMA (Close,20)[1]>WMA (Close,40)[1] || SMA (Close,10)[1]>WMA(Close,40)[1] || SMA (Close,13)[1]>WMA(Close,40)[1]) ) { if(soundon) { if (!Historical) PlaySound(soundFile1); } tcdown.Set(-1); DrawText("short"+CurrentBar.ToString(),false, "D", 0, High[0] + (dist * TickSize),10, dnColor, new Font("Wingdings",8f), StringAlignment.Center, Color.Transparent, Color.Transparent, 0); } if(EMA (Close,20)[0]>WMA (Close,40)[0] && SMA (Close,10)[0]>WMA(Close,40)[0] && SMA (Close,13)[0]>WMA(Close,40)[0] && (EMA (Close,20)[1]<WMA (Close,40)[1] || SMA (Close,10)[1]<WMA(Close,40)[1] || SMA (Close,13)[1]<WMA(Close,40)[1]) ) { if(soundon) { if (!Historical) PlaySound(soundFile2); } tcup.Set(1); DrawText("long"+CurrentBar.ToString(),false, "C", 0, Low[0] - (dist * TickSize),-10, upColor, new Font("Wingdings",8f), StringAlignment.Center, Color.Transparent, Color.Transparent, 0); } else tcdown.Set(0); tcup.Set(0); }
Comment