Hello all,
Suppose I have an indicator that I use to generate entry signals. This indicator has the value of 1 when the signal is active and 0 when no signal exists.
How do I create a screener that looks for stocks where the high of the week in which the BUY SIGNAL indicator flashed a signal has not been violated? In other words, if a BUY SIGNAL appeared, say, 15 weeks ago, then every week since then has had a lower high.
Here’s what I’ve coded:
myBUYSIGNAL = CALL "BUY SIGNAL"
FOR i=0 to 20 DO
If myBUYSIGNAL[i] >= 1 then
signal=high[i]
else
signal=0
endif
c1= highest[high](i) >= signal
NEXT
SCREENER [c1]
I’m getting the following message: “An error has occurred during the execution of your ProScreener market scan”.
Your assistance on this would be extremely helpful.
Thank you,
Igor
Hi Igor
What is your code for the “Buy Signal” Indicator … the code might help to suss out the cause of the error?
Cheers
GraHal
Hi GraHal,
The code is as follows:
c1= low<=1.02*Average[10](Close) and close>=Average[10](close)
c2= close>=100
IF AverageTrueRange[1](close)>=1.25*Average[20](AverageTrueRange[1](close)) AND Volume>=1.25*Average[20](Volume) AND close>open AND high>=highest[52](high)*0.95 and c1 and c2 THEN
BUYSIGNAL = 1
ELSE
BUYSIGNAL=0
ENDIF
RETURN BUYSIGNAL
Thanks in advance.
Igor
Any suggestion from anyone?
Hi Igor
Below will give you the highest high in the last 15 periods up to the last period, …
c1 = High > Highest[15](High[1])
I’m only saying above as that was what flashed in my mind when I read your posts and code. Above may spark some further thoughts in your mind.
I’ll come back if I have any more ideas re your requirement. I’m having a ‘motivation crisis’ today, but nothing serious 🙂
Hi from8to800,
Did you find the solution to your problem?
I’m seeing the same message some times…
Thank you, and good luck!
Here’s what I’ve coded:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
myBUYSIGNAL = CALL “BUY SIGNAL”
FOR i=0 to 20 DO
If myBUYSIGNAL[i] >= 1 then
signal=high[i]
else
signal=0
endif
c1= highest[high](i) >= signal
NEXT
SCREENER [c1]
|
I’m getting the following message: “An error has occurred during the execution of your ProScreener market scan”. Your assistance on this would be extremely helpful. Thank you, Igor
Your variable SIGNAL may only have value 1 ONLY when myBUYSIGNAL[20], i.e. the last iteration, will be true, else… it will ALWAYS be ZERO even if the first iterations were all true!
Moreover,
highest[high]
will be expanded, at scan time, to, say
highest[1.1960] //in case you trade Eur/Usd
highest[13960] //in case you trade DAX
and will almost always generate an error!
Roberto
Hi everyone, and thank you Roberto for your kind atention. I’m afraid I don’t completely understand your explanation.
I’m having the same error as ‘from8to800’ but, surprisingly my code fails just some times. Most times, it works fine. I don´t think its a network problem, because it fails always with the same stocks (for example, it fails if you try to backtest OTEX with 3000 bars)
The strategy tries to catch high capitalization breakouts, and I’m trying to optimise two variables: ‘volatilidad’ from 2 to 8 (step=3) and ‘misumacap’ from 100 to 300 (step=50).
Thanks in advance,
Miguel
DEFPARAM cumulateorders=false
Capital = 100000
Risk = 1
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
riesgo=(priceopen-stoploss)*2
cap=volume*typicalprice
sumacap=summation[5](cap)
sumacap25=summation[25](cap)
media5=sumacap25/5
supermediacap=100*sumacap/media5
//vola=ABS(highest[5](high)-lowest[5](low))*100/typicalprice
alto=highest[5](high)
bajo=lowest[5](low)
vola=ABS(alto-bajo)*100/typicalprice
//semana y día alcista
if vola>=volatilidad and supermediacap>=misumacap and close>open[5] and close>open then
condicion1=1
elsif condicion1[1]>0 and condicion1<5 and low>stoploss then
condicion1=condicion1[1]+1
else
condicion1=0
endif
if condicion1=1 then
priceopen = alto+((alto-bajo)*(5/100))
stoploss = bajo-((alto-bajo)*(5/100))
riesgo=(priceopen-stoploss)*2
PositionSize = abs(round(maxrisk/riesgo))
endif
if condicion1>0 then
BUY positionsize shares at priceopen stop
endif
GRAPH supermediacap coloured (0,200,0,255) as "supermediacap"
GRAPH vola coloured (0,100,100,255) as "volatilidad"
SET TARGET PROFIT riesgo
SET STOP LOSS riesgo
@vitatrader35, this a ProScreener support forum, if you want to talk about a strategy you should open a new topic in the ProOrder Support Forum. Thank you.
I’m afraid I don’t completely understand your explanation
Let me know what it is, so I can try to explain it better. I was just pointing out a couple of logic errors, I did not mean to correct the code at all, since I did not understand exactly what from8to800 was trying to accomplish.
Hi, Robertogozzi
I just posted here because yours is the only explanation I found to this kind problem. I read your message more carefully and now I think I understand. Thank you, because I think you opened the way to find the solution (its more than possible that my code has one -or more- logic problem…). I’ll try to make the question in the right place.
One more question, about the original post: could this also be an error?
(wrong)
c1= highest[high](i) >= signal
(righ, if all the iterations were positive)
c1= highest[i](high) >= signal
Thank you for your help
Yes vitatrader35, that would work finely!
But be aware that
c1= highest[high](i) >= signal
when signal IS zero will be expanded, at scan time, to
c1= highest[high](i) >= 0
thus making c1 TRUE!
I don’t know if this logic behaviour is unwanted or not, I just pointed it out.