NexusFi: Find Your Edge


Home Menu

 





Cycle progression?


Discussion in NinjaTrader

Updated
    1. trending_up 2,056 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 Leo123 
Pitea, BD, Sweden
 
Experience: Beginner
Platform: Ninjatrader
Trading: ES
Posts: 34 since Nov 2011
Thanks Given: 1
Thanks Received: 5

Is there anyone who can code this Metastock formula to Ninja Trader?

Sum(If(C>Ref(C,-1),1,0),5)<Sum(If(C<Ref(C,-1),1,0),5)

Sum(If(C>Ref(C,-1),1,0),5)>Sum(If(C<Ref(C,-1),1,0),5)


Someone explained:

1. If(C>Ref(C,-1),1,0) - If current close is greater than previous close then 1 else zero.
2. Sum of 1 for last 5 periods (i.e. sum of either 1 or 0 from point 1 result)
3. If(C<Ref(C,-1),1,0) - If current close is less than previous close then 1 else zero
4. Sum of 3 for last 5 periods (i.e. sum of either 1 or 0 from point 3 result)
Then
check if 2 < 4 or 2 > 4

Thanks


Started this thread Reply With Quote

 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 TimeTrade 
Erfurt Germany
 
Experience: Master
Platform: rtMagic, NinjaTrader
Broker: AMP/CQG, IAB
Trading: ES, 6E, FDAX, FGBL
Posts: 338 since Aug 2011
Thanks Given: 54
Thanks Received: 461



Leo123 View Post
Is there anyone who can code this Metastock formula to Ninja Trader?

Sum(If(C>Ref(C,-1),1,0),5)<Sum(If(C<Ref(C,-1),1,0),5)

Sum(If(C>Ref(C,-1),1,0),5)>Sum(If(C<Ref(C,-1),1,0),5)


Someone explained:

1. If(C>Ref(C,-1),1,0) - If current close is greater than previous close then 1 else zero.
2. Sum of 1 for last 5 periods (i.e. sum of either 1 or 0 from point 1 result)
3. If(C<Ref(C,-1),1,0) - If current close is less than previous close then 1 else zero
4. Sum of 3 for last 5 periods (i.e. sum of either 1 or 0 from point 3 result)
Then
check if 2 < 4 or 2 > 4

Thanks


QUICK&DIRTY... (only write as text, no 100% syntax checked )

variables:
DataSeries dsCmpLower;
DataSeries dsCmpHigher;

initialization:
dsCmpLower=new DataSeries(this);
dsCmpHigher=new DataSeries(this);


onbarupdate:

if(CurrentBar>0)
{
dsCmpLower.Set(Close[0]<Close[1] ? 1:0);
dsCmpHigher.Set(Close[0]>Close[1] ? 1:0);
}
else
{
dsCmpLower.Set(0);
dsCmpHigher.Set(0);
}

if(CurrentBar>5)
{
if(SUM(dsCmpLower,5)[0] > SUM(dsCmpHigher,5)[0])
{
// ...code...
}
}


Reply With Quote
Thanked by:
  #4 (permalink)
 Leo123 
Pitea, BD, Sweden
 
Experience: Beginner
Platform: Ninjatrader
Trading: ES
Posts: 34 since Nov 2011
Thanks Given: 1
Thanks Received: 5


TimeTrade View Post
QUICK&DIRTY... (only write as text, no 100% syntax checked )

variables:
DataSeries dsCmpLower;
DataSeries dsCmpHigher;

initialization:
dsCmpLower=new DataSeries(this);
dsCmpHigher=new DataSeries(this);


onbarupdate:

if(CurrentBar>0)
{
dsCmpLower.Set(Close[0]<Close[1] ? 1:0);
dsCmpHigher.Set(Close[0]>Close[1] ? 1:0);
}
else
{
dsCmpLower.Set(0);
dsCmpHigher.Set(0);
}

if(CurrentBar>5)
{
if(SUM(dsCmpLower,5)[0] > SUM(dsCmpHigher,5)[0])
{
// ...code...
}
}


Thanks you are fast!

But, there are some data errors...


Started this thread Reply With Quote




Last Updated on February 28, 2012


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts