Coding question
Forums › ProRealTime English forum › ProBuilder support › Coding question
- This topic has 9 replies, 2 voices, and was last updated 8 years ago by Nicolas.
-
-
03/01/2016 at 6:36 PM #3360
Hello. I have a question about how to modify a code from the library.
I’ve seen the Renko box on price chart indicator. I would like to know how to modify indicators to make them calculated on the renko box and not on the price. In the Renko indicator, i’ve seen 2 information Top and Bottom of the box. Maybe the middle would be correct… well, the goal would be to have the indicator calculated just like if it was on renko chart.So, let’s take for example the “Stair Step” indicator How would you modify the code to make it calculated on renko box indicator ??
Here is the code ://parameters :
// Step = 0.0010 forex 10 pips, adapt to item you are trading
// MAperiod = 20once ssMA = close
MA = average[MAperiod](close)if(MA > ssMA + Step) THEN
ssMA = MA
ELSIF (MA < ssMA – Step) THEN
ssMA = MA
ELSE
ssMA = ssMA
ENDIFRETURN ssMA
And here is the renko code :
123456789101112131415161718192021<span class="token comment" spellcheck="true">//parameters :</span><span class="token comment" spellcheck="true">// boxsize = 100 //1 hour timeframe default size, adapt it for your </span><span class="token keyword">once</span> topprice <span class="token operator">=</span> <span class="token keyword">close</span><span class="token keyword">once</span> bottomprice <span class="token operator">=</span> <span class="token keyword">close</span> <span class="token operator">-</span> boxsize<span class="token operator">*</span><span class="token number">2</span><span class="token keyword">if</span><span class="token punctuation">(</span><span class="token keyword">close</span> <span class="token operator">></span> topprice <span class="token operator">+</span> boxsize<span class="token operator">*</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token keyword">THEN</span>topprice <span class="token operator">=</span> <span class="token keyword">close</span>bottomprice <span class="token operator">=</span> topprice <span class="token operator">-</span> boxsize<span class="token operator">*</span><span class="token number">2</span><span class="token keyword">ELSIF</span> <span class="token punctuation">(</span><span class="token keyword">close</span> <span class="token operator"><</span> bottomprice <span class="token operator">-</span> boxsize<span class="token operator">*</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token keyword">THEN</span>bottomprice <span class="token operator">=</span> <span class="token keyword">close</span>topprice <span class="token operator">=</span> bottomprice <span class="token operator">+</span> boxsize<span class="token operator">*</span><span class="token number">2</span><span class="token keyword">ELSE</span>topprice <span class="token operator">=</span> toppricebottomprice <span class="token operator">=</span> bottomprice<span class="token keyword">ENDIF</span><span class="token keyword">RETURN</span> topprice <span class="token keyword">as</span> <span class="token string">"box top"</span><span class="token punctuation">,</span> bottomprice <span class="token keyword">as</span> <span class="token string">"bottom box"</span>03/01/2016 at 8:18 PM #3363Well, if i understand correctly, you would like to make the stairstep moving average calculated with something else than a classical candle close? And in your case, that would be the close of a renko box? (or my so called indicator..:) )
03/01/2016 at 9:16 PM #336403/02/2016 at 8:28 AM #3365First, you’ll have to adapt the renko indicator with a new variable that deal with what is the current close. Because indicators are often calculated on Close, my renko box indicator does not have one.
12345678910111213if(close > topprice + boxsize*2) THENtopprice = closebottomprice = topprice - boxsize*2boxclose = toppriceELSIF (close < bottomprice - boxsize*2) THENbottomprice = closetopprice = bottomprice + boxsize*2boxclose = bottompriceELSEtopprice = toppricebottomprice = bottompriceboxclose = boxcloseENDIFThen, instead of having :
1MA = average[MAperiod](close)You should make :
1MA = average[MAperiod](boxclose)But you have to merge the 2 indicators first. Let me know if it works like you want.
03/02/2016 at 9:56 AM #336803/02/2016 at 11:44 AM #3370Here is the full indicator code :
1234567891011121314151617181920212223242526272829303132333435363738//parameters :// boxsize = 100 //1 hour timeframe default size, adapt it for your// Step = 0.0010 forex 10 pips, adapt to item you are trading// MAperiod = 20boxsize = 100*pipsizeStep = 10*pipsizeMAperiod = 20once topprice = closeonce bottomprice = close - boxsize*2once ssMA = closeif(close > topprice + boxsize*2) THENtopprice = closebottomprice = topprice - boxsize*2boxclose = toppriceELSIF (close < bottomprice - boxsize*2) THENbottomprice = closetopprice = bottomprice + boxsize*2boxclose = bottompriceELSEtopprice = toppricebottomprice = bottompriceboxclose = boxcloseENDIFMA = average[MAperiod](boxclose)if(MA > ssMA + Step) THENssMA = MAELSIF (MA < ssMA - Step) THENssMA = MAELSEssMA = ssMAENDIFRETURN ssMA03/02/2016 at 11:47 AM #337203/02/2016 at 12:23 PM #337303/02/2016 at 1:02 PM #337603/15/2016 at 12:45 PM #3769 -
AuthorPosts
Find exclusive trading pro-tools on