NexusFi: Find Your Edge


Home Menu

 





Indicator vs strategy discrepancy


Discussion in TradeStation

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




 
Search this Thread

Indicator vs strategy discrepancy

  #1 (permalink)
 bluefightingcat 
Espoo Finland
 
Experience: Intermediate
Platform: TradingBlox, Tradestation
Trading: Stocks
Posts: 41 since Sep 2015
Thanks Given: 2
Thanks Received: 10

Ok so I have an indicator plotted on my chart. I have the very same indicator code inserted as part of my strategy. However to my dismay I discovered that the values between the indicator and the strategy are slightly off. It seems that the indicator is calculated differently compared to when the exact same code is part of a strategy.

What could be causing this and is there a solution?

Here is the indicator code:

 
Code
Inputs: iLenRSI(3), iLenUP(2), iLenROC(100);

Var: vUpArray(0), vDownArray(0), vUpDown(0), vCRSI(0);

vUpArray = MRO(C<=C[1],100,1);
vDownArray = MRO(C>=C[1],100,1);
vUpDown = IFF(C=C[1], 0, IFF(vUpArray>0,vUpArray,-vDownArray));

vCRSI = (RSI(C,iLenRSI) + RSI(vUpDown, iLenUP) +
100*PercentRank(RateOfChange(C,1),RateOfChange(C,1),iLenROC+1))/3;

Plot1(vCRSI, "CRSI");

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


bluefightingcat View Post
Ok so I have an indicator plotted on my chart. I have the very same indicator code inserted as part of my strategy. However to my dismay I discovered that the values between the indicator and the strategy are slightly off. It seems that the indicator is calculated differently compared to when the exact same code is part of a strategy.

What could be causing this and is there a solution?

Here is the indicator code:

 
Code
Inputs: iLenRSI(3), iLenUP(2), iLenROC(100);

Var: vUpArray(0), vDownArray(0), vUpDown(0), vCRSI(0);

vUpArray = MRO(C<=C[1],100,1);
vDownArray = MRO(C>=C[1],100,1);
vUpDown = IFF(C=C[1], 0, IFF(vUpArray>0,vUpArray,-vDownArray));

vCRSI = (RSI(C,iLenRSI) + RSI(vUpDown, iLenUP) +
100*PercentRank(RateOfChange(C,1),RateOfChange(C,1),iLenROC+1))/3;

Plot1(vCRSI, "CRSI");


Make sure the lookback length (MaxBarsBack) is set to the same. Strategy default is 50, you can change it. Indicators have "auto detect" as default, you can change it.

Make both the same value.

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 bluefightingcat 
Espoo Finland
 
Experience: Intermediate
Platform: TradingBlox, Tradestation
Trading: Stocks
Posts: 41 since Sep 2015
Thanks Given: 2
Thanks Received: 10



kevinkdog View Post
Make sure the lookback length (MaxBarsBack) is set to the same. Strategy default is 50, you can change it. Indicators have "auto detect" as default, you can change it.

Make both the same value.

I tried that. Unfortunately it didn't help.

I'm using two different symbols in the strategy. I did some testing and it seems to me that the problem arises when I update the code of the indicator in the strategy to reference "Data2".
In theory there shouldn't be any discrepancy because when comparing the strategy with the indicator code, with the indicator one a single data stream, everything works fine.

So I suspect there is something wrong with my code when I try and use Data2 on the indicator.

Started this thread Reply With Quote
  #4 (permalink)
 bluefightingcat 
Espoo Finland
 
Experience: Intermediate
Platform: TradingBlox, Tradestation
Trading: Stocks
Posts: 41 since Sep 2015
Thanks Given: 2
Thanks Received: 10

I found my mistake. It was a typo in my code.

Started this thread Reply With Quote




Last Updated on March 21, 2023


© 2024 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 - Privacy Policy - Downloads - Top
no new posts