Hi guys,
I know this indicator does repaint, but I need it in PRT to apply a very proficient strategy I already use in FX with MT4.
It is a stochastic used to trace tops and bottom.
I will discuss this strategy in a new post as soon I can try it.
I moved your thread to the English Probuilder support, since you wrote your posts in English.
For conversions, please follows these rules https://www.prorealcode.com/topic/free-conversion-mt4-indicators-mql4/
Thank you.
You already asked for this conversion in another topic: https://www.prorealcode.com/topic/drake-delayed-stocastic-da-mq4-a-prt/
I told you that it is not possible, you’ll never get the same curves on your chart. This is what you’ll get when non repainting:
[attachment file=66764]
this is the code:
defparam calculateonlastbars=2000
Slw = 8
Pds = 13
Slwsignal = 9
if barindex>Pds then
smconst = 2 / (1+Slw)
smconst1 = 2 / (1+Slwsignal)
prev = MAvalue2[1]
AA = 0
tmpDevAA = Highest[Pds](high)[Pds] - Lowest[Pds](low)[Pds]
if (tmpDevAA <> 0) then
AA = 100* ((Close - Lowest[Pds](low)[Pds]) / tmpDevAA)
endif
// ---
MAValue2 = smconst * (AA-prev) + prev
//-----------
MyHigh = -999999
MyLow = 99999999
for i = 1 to Pds do
Price = MAValue2[i]
if( Price > MyHigh ) then
MyHigh = Price
endif
if( Pds <= 0 ) then
MyHigh = Price
endif
if( Price < MyLow ) then
MyLow = Price
endif
if( Pds <= 0 ) then
MyLow = Price
endif
next
prev1 = MAValue[1]
aa1=MAValue2
bb= 0
if ((MyHigh-MyLow) <> 0) then
bb=100*(aa1-MyLow)/(MyHigh-MyLow)
endif
MAValue = smconst * (bb-prev1) + prev1
prev2=MAValue2[1]//GetIndexValue2(shift+1);
prev3=MAValue//GetIndexValue(shift);
mavalue3= smconst1 * (prev3-prev2) +prev2
endif
return mavalue,mavalue3
Thank you very much Nicolas, I will compare the result with the MT4 version and see if results are what I am looking for.
Anyway, I found another version without repainting (words of author), would you mind to give it a look?
Thanks again
Hello,
I am new to coding with PRT. I used the above code as an indicator on my chart and all was good. I then created an automated strategy what didnt do what I thought. The explanation I think maybe that the above code is delayed, or repaints. Although I thought this is unlikely on the PRT platform. I am at a bit of a loss as to what is happening. Not really sure how to go about debugging it. For instance, in the above code that returns mavalue and mavalue3. Lets say we want to code a simple crossover strategy. In the backtest I believe the two values mavalue and mavalue3 are always zero, and so no trades happen.
On a totally different track. I still have not got my head around having my code automatically saved. I have lost my code about 20 times in last two weeks. I now always copy to a notepad. I have also exported and when I name it to save I added a “-1”. For instance, “My Strategy v1.itf” becomes “My Strategy v1-1.itf”. It exports fine, but when I go to import the “-1” suffixed version it says “My Strategy v1.itf” already exists. It is like it just does not register the “-1” as part of the name. Very confusing to me.
Other than that I am enjoying the speed at which I can test ideas but a major limitation is only having 10000 bars at my disposal. If my strategy is on small timeframes such as 1 or 2 minutes then this equates to only about a couple of weeks of testing, if that. Ideally I would love to be able to test my strategy over at least one or two years of M1 or M2 data. Guessing this is not possible.
Regards,
Roy
The above code does not repaint. You should be able to get correctly the 2 curves data in order to trigger orders with them.
FYI, PRT v11 allow backtesting with up to 1 million bars.
Thanks Nicholas. I will have to take another look at what is going on. Unfortunately my broker, IG, is still on version 10.3 of PRT. Hoping within the next 18 months they will offer version 11.
Hi Nicholas,
I have used the code above and just added a simple buy if mavalue above mavalue2, and sell if opposite. This is just to test whether the value is doing anything. No trades are taken which would indicate to me that the values are always equal, and in this case, zero. If that is the case, then the code is repainting….unless I am making some “newbie” mistake.
//defparam calculateonlastbars=2000
Slw = 8
Pds = 13
Slwsignal = 9
if barindex>Pds then
smconst = 2 / (1+Slw)
smconst1 = 2 / (1+Slwsignal)
prev = MAvalue2[1]
AA = 0
tmpDevAA = Highest[Pds](high)[Pds] - Lowest[Pds](low)[Pds]
if (tmpDevAA <> 0) then
AA = 100* ((Close - Lowest[Pds](low)[Pds]) / tmpDevAA)
endif
// ---
MAValue2 = smconst * (AA-prev) + prev
//-----------
MyHigh = -999999
MyLow = 99999999
for i = 1 to Pds do
Price = MAValue2[i]
if( Price > MyHigh ) then
MyHigh = Price
endif
if( Pds <= 0 ) then
MyHigh = Price
endif
if( Price < MyLow ) then
MyLow = Price
endif
if( Pds <= 0 ) then
MyLow = Price
endif
next
prev1 = MAValue[1]
aa1=MAValue2
bb= 0
if ((MyHigh-MyLow) <> 0) then
bb=100*(aa1-MyLow)/(MyHigh-MyLow)
endif
MAValue = smconst * (bb-prev1) + prev1
prev2=MAValue2[1]//GetIndexValue2(shift+1);
prev3=MAValue//GetIndexValue(shift);
mavalue3= smconst1 * (prev3-prev2) +prev2
endif
//return mavalue,mavalue3
if mavalue<mavalue3 then
if LongOnMarket then
SELL 1 CONTRACTS at MARKET
endif
if NOT ShortOnMarket then //and Hour[1]=11 then
SELLSHORT 1 CONTRACTS AT MARKET
endif
endif
if mavalue>mavalue3 then
if ShortOnMarket then
EXITSHORT 1 CONTRACTS at MARKET
endif
if NOT LongOnMarket THEN //and Hour[1]=11 then
BUY 1 CONTRACTS AT MARKET
endif
endif