![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Dec 2004
Location: , ,
Posts: 68
Thanks: 4
Thanked 3 times in 1 post
|
{Stoc-1}
_$Num1=C-Lowest(L,STLen); _$Denom1=Highest(H,STLen)-Lowest(L,STLen); _$Ratio1=IFF(_$Denom1>0,(_$Num1/_$Denom1)*100,_$Ratio1[1]); _$PctK1=IFF(CurrentBar=1,_$Ratio1,_$PctK1[1]+(.5*(_$Ratio1-_$PctK1[1]))); {Stoc-2} _$Num2=_$PctK1-Lowest(_$PctK1,STLen); _$Denom2=Highest(_$PctK1,STLen)-Lowest(_$PctK1,STLen); _$Ratio2=IFF(_$Denom2>0,(_$Num2/_$Denom2)*100,_$Ratio2[1]); _$PctK2=IFF(CurrentBar=1,_$Ratio2,_$PctK2[1]+(.5*(_$Ratio2-_$PctK2[1]))); plot1(_$PctK2,"stoc"); Tried it with the stochastic ninjatrader code, but failed to get the right result.... Could someone help me out converting above code to NT code? greetings, Bart |
|
|
|
|
|
#2 |
|
Member
Join Date: Dec 2004
Location: , ,
Posts: 68
Thanks: 4
Thanked 3 times in 1 post
|
//stoc1
nom.Set(Close[0] - MIN(Low, Len)[0]); den.Set(MAX(High, Len)[0] - MIN(Low, Len)[0]); ratio.Set(den[0]>0 ? (nom[0] / den[0])*100 : ratio[1]); pctk1.Set(CurrentBar == 0 ? ratio[0] : pctk1[1] + (0.5 * (ratio[0] - pctk1[1]))); Plot0.Set(pctk1[0]); //stoc2 nom2.Set(pctk1[0] - MIN(pctk1, Len)[0]); den2.Set(MAX(pctk1, Len)[0] - MIN(pctk1, Len)[0]); //ratio2.Set((den2[0]>0) ? ((nom2[0] / den2[0])*100) : ratio2[1]); //pctk12.Set(CurrentBar == 0 ? ratio2[0] : pctk12[1] + (0.5 * (ratio2[0] - pctk12[1]))); Stoc1 works fine, but as soon I UNcomment the stoc2 lines the indicatorlines disappear in the chart! What am I doing wrong? |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2004
Location: , ,
Posts: 68
Thanks: 4
Thanked 3 times in 1 post
|
Another strange thing happens:
dstoc1 indicator works fine and plots on the chart. As soon as I create another indicator(2) that uses dstoc1 indicator like this: Indicator2 uses: Plot1.Set(dstoc(Low,10)[0]); It effects the plotted dstoc1 indicator? I should see 2 different indicators on the chart right? |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Bart,
Could you give me a high level description of what you want to see? Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Jan 2005
Location: , ,
Posts: 109
Thanks: 0
Thanked 0 times in 0 posts
|
This is my approach. It plots Stoc1&Stoc2 given in your TS sample code.
Ray, always has cleaner code than me. If/when he responds, it will be clearer. Quote:
|
|
|
|
|
|
|
#6 |
|
Member
Join Date: Dec 2004
Location: , ,
Posts: 68
Thanks: 4
Thanked 3 times in 1 post
|
Work like a charm
![]() Thank you very much!( The difference: I -> nom.Set(Close[0] - MIN(Low, Len)[0]); You -> Num1=Close[0]-MIN(Low, StLen)[0]; ):? |
|
|
|
|
|
#7 |
|
Member
Join Date: Apr 2007
Location: , ,
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
|
I'm not a programer.
I copied and paste this and tried to compile as an indicator but got a numer of errors beginning at line 45. Is this because of the change in NT since 2004? Can anyone help pls. TIA |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
This might be the reason momentom, you can double click on each error listed on the bottom and see where it was found...if you don't want to debug this, you can directly import this one - http://www.ninjatrader-support2.com/...&id=86&catid=1
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|