Assigning a boolean value to a variable and keeping it until changed again
6 replies
AgatheBauer
7 years ago #116329
I’m using a commercial indicator that lacks support for alarms, therefore I reprogrammed it. It’s actually pretty simple: A moving average with 3 levels of ATR are plotted above and below (see screenshot). I want to get a signal when Ask is above or equal to MA + 3times ATR or Bid is below MA – 3times ATR. However, to not getting a signal on every tick when conditions are met, I want to set a boolean variable to false after the first detection of the signal and only allowing the signal again, after one bar has closed within the “borders”, the Boolean variable is reset to “true”.
For backtesting purposes, I went for +/- 1times ATR to get more signals. Right in the middle of the screenshot, you can easily spot an area, where short signals (red) are plotted that shouldn’t be allowed by the “reset” function (green) that resets the bool var to true. Why is this?
If anyone is kind enough to check on this, I attached the sqw file, too.
One more question: Is there any way to have values of variables plotted right on the chart for debugging purposes?
tomas262
7 years ago #141557
tomas262
7 years ago #141586
AgatheBauer
7 years ago #141592
I exported to a Signal Indicator.
AgatheBauer
7 years ago #141609
I still can’t find my mistake.
tomas262
7 years ago #141679
Hello,
you can try to export it as an expert advisor and see how it works then for you. It still can only draw arrow up or down with no trading. There seems to be with a difference in code evaluation when exported as the signal indicator
AgatheBauer
7 years ago #141810
Thank you! I will fix it by hand.
Viewing 6 replies - 1 through 6 (of 6 total)