I thought I was getting this..but somehow I messed up.
I have an SMA55. I only want it to track H4(other time frames get scaled SMA). When a bar Closes above it I want a signal to buy. When a bar Closes below it I want a signal to sell. If I already have received a signal I should not receive another unless the SMA is crossed. The current bar should not be tracked.
This is my CheckBuy Function:
Check Sell the logic is reversed.
I am not sure how to hold the data for the indicators since I can't figure out the Global Scoped variables.
What am I missing or doing wrong?
I have an SMA55. I only want it to track H4(other time frames get scaled SMA). When a bar Closes above it I want a signal to buy. When a bar Closes below it I want a signal to sell. If I already have received a signal I should not receive another unless the SMA is crossed. The current bar should not be tracked.
This is my CheckBuy Function:
Inserted Code
bool CheckForBuy(int idx) { if (Close[idx]>SMA55[idx]) { if (Close[idx]>Close[idx-1]) { if (Close[idx-1]<=SMA55[idx-1]) { return(true); } } } else return(false); }
Check Sell the logic is reversed.
I am not sure how to hold the data for the indicators since I can't figure out the Global Scoped variables.
What am I missing or doing wrong?
Attached Image