My new strategy enters at market incorrectlly
Forums › ProRealTime English forum › ProOrder support › My new strategy enters at market incorrectlly
- This topic has 7 replies, 2 voices, and was last updated 3 years ago by IcaroFM.
-
-
01/04/2021 at 2:55 PM #156260
Hi, I’ve a problem with a strategy. It’s a simple strategy that buy when the value of the indicator leaves -100 and sell when the value of the indicator leaves 100.
But I don’t know why strategy has wrong signals. I’ve tried with other markets, but I’ve the same problem. It’s probably an oversight of mine but I can’t find it. Thank you to those who want to help me.
01/04/2021 at 3:54 PM #156275Give your topic a meaningful title.Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
Thank you 🙂
If your code is not hundreds of lines, post it please.
01/04/2021 at 5:23 PM #156311Sorry for my title Roberto.
Here the indicator:
Indicator123456789101112131415161718192021222324252627HighMom = DHigh(0) - DHigh(2)LowMom = DLow(0) - DLow(2 )Cond1 = (DHigh(0) >= Dlow(5) OR DHigh(0) >= DLow(6) )Cond2 = ( DHigh(2) >= DClose(7) OR DHigh(2) >= DClose (8) )Cond3 = ( DLow(0) <= DHigh (5) OR DLow(0) <= DHigh(6) )Cond4 = (DLow(2) <= DClose(7) OR DLow(2) <= DClose(8) )Cond = ( Cond1 OR Cond2 ) AND ( Cond3 OR Cond4 )IF Cond thenNum = HighMom + LowMomElseNum = 0ENDIFDen = ABS( HighMom ) + ABS( LowMom )TDREI = 100 * Summation [5](Num) / Summation [5] (Den)SignBuy=0SignSell=0if TDREI[1]=100 and TDREI<100 thenSignSell=1endifif TDREI[1]=-100 and TDREI>-100 thenSignBuy=1endifreturn TDREI,SignSell as "Sell",SignBuy as "Buy"And here the strategy
Strategy123456789101112131415161718192021222324252627282930313233343536373839404142shorta = 0compra = 0copri = 0vendi = 0signal,SignSell,SignBuy=Call "TD REI"//if signal[1]>99 and signal<99 thenif SignSell=1 thenShorta=1Vendi=1endif//if signal[1]<-99 and signal>-99 thenif SignBuy=1 thenCompra=1copri = 1endifREM - * - * -* - Comincio le azioni - * - * - * -NumContrattiMax=2IF LongOnMarket and (vendi or shorta) THENSELL AT MARKETENDIFIF ShortOnMarket and (copri or compra) THENEXITSHORT AT MARKETENDIFIF shorta and COUNTOFSHORTSHARES<NumContrattiMax THENSELLSHORT 1 contracts at marketSET STOP %LOSS SLLong*0.1SET TARGET %PROFIT TPLong*0.1ENDIFIF compra and COUNTOFLONGSHARES<NumContrattiMax THENbuy 1 contracts at marketSET STOP %LOSS SLLong*0.1SET TARGET %PROFIT TPLong*0.1ENDIFThanks
01/05/2021 at 3:06 AM #156368Firstly, your indicator returns 1 for both sell and buy signal making them difficult to see on the chart, I suggest that you replace lines 21 and 24 of your indicator with:
12SignSell = -50 //line21SignBuy = 50 //line 24you don’t have to change the code in your strategy because they are TRUE being <> 0, but can easily be spotted on the chart.
Secondly, you have added a variable named NumContrattiMax, but it can only be 1 unless you set line 1 to TRUE.
Thirdly, you have added two variables, TPLong and SLLong as if you wanted to make those values for Long trades different from the Short ones, but you are using the same variables for both Long and Short trades.
The trade you are talking about seems to have been opened on Dec. 7th at 01:00 (you did not specify any daye & time, which you should always do, instead) accorduing to the SHORT signal from the prior candle as you can see from my pic (-50).
Everything seems fine to me.
01/05/2021 at 8:56 AM #156379Thank you Roberto.
- I’ve changed to -50 and 50 so I can see better on the chart.
- Yes, that’s right, this is a generic strategy that I use to test my ideas. So it’s not all fine. I need to see how the indicator works. But you’re right, it’s useless if the first line is set to “False” value.
- Yes, that’s right, as point 2, I’ve use this code to see how the indicator works.
The different between me and you is the TD value. In that trade I’ve the indicator at 100 not less than 100. You can also see that I’ve not -5 sell signals on the bottom of the chart. I’ve dont’t understand why.
01/05/2021 at 9:16 AM #15638701/05/2021 at 11:44 AM #156417Prova ad usare questa versione dell’indicatore:Try using this version:
123456789101112131415161718192021222324252627HighMom = DHigh(0) - DHigh(2)LowMom = DLow(0) - DLow(2 )Cond1 = (DHigh(0) >= Dlow(5) OR DHigh(0) >= DLow(6) )Cond2 = ( DHigh(2) >= DClose(7) OR DHigh(2) >= DClose (8) )Cond3 = ( DLow(0) <= DHigh (5) OR DLow(0) <= DHigh(6) )Cond4 = (DLow(2) <= DClose(7) OR DLow(2) <= DClose(8) )Cond = ( Cond1 OR Cond2 ) AND ( Cond3 OR Cond4 )IF Cond thenNum = HighMom + LowMomElseNum = 0ENDIFDen = ABS( HighMom ) + ABS( LowMom )TDREI = 100 * Summation [5](Num) / Summation [5] (Den)SignBuy=0SignSell=0if TDREI[1]=100 and TDREI<100 thenSignSell=-50endifif TDREI[1]=-100 and TDREI>-100 thenSignBuy=50endifreturn TDREI AS "Td Rei",SignSell as "Sell",SignBuy as "Buy"01/05/2021 at 12:06 PM #156419Same result Roberto.
It’s not so important, this indicator doesn’t do what I’m expected, and I think that I don’t use in the future. Anyway it’s very strange, I’ve write many strategies in the past and this is the first time that happen this strange behavior
-
AuthorPosts
Find exclusive trading pro-tools on