NexusFi: Find Your Edge


Home Menu

 





Math.Abs() erratic outcome in strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Trader.Jon with 3 posts (0 thanks)
    2. looks_two MXASJ with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 cory with 1 posts (0 thanks)
    1. trending_up 2,222 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 1 attachments




 
Search this Thread

Math.Abs() erratic outcome in strategy

  #1 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

Another week, another challenge,

I had a bunch of erratic outcomes in backtesting so I stripped down the code and ...

Using the PRC2 from the downloads area, and NOW the only condition in the strategy is the Math.Abs portion of the code

My pseudo code [idea to test]

IF the (Absolute Value of the ((PRC2.SqHI2 minus HIGH) is GREATER THAN
( the Absolute Value of the ((LOW minus PRC2.SqLOW2 ))
Then Go LONG ...

ie there is more potential to go up than there is to go down if that is true. The reason I am using Abs is to cover cases when the HI might already be greater than the Sqh2 .... reversing logic to go shorts ... on the screen shot you will see that the trigger bars are (in this example) in position to take SHORT, but 1 went LONG instead.. 33.3333% of trades going the wrong way do not a happy tester make!

Likely it is my mis use of the tool, but I dont know any better lol

Thanks especially for a fix ... been hitting on this all weekend trying to find the problem
Jon


 
Code
                            
 

if
(
Position.MarketPosition == MarketPosition.Flat 
&& (Math.Abs(PRC2(PRC2DegreePRC2Period1.622.00PRC2HATEMAPeriodPRC2TEMAPeriod).Sqh2[0] - Highs[0][0])) >
 (
Math.Abs(Lows[0][0] - PRC2(PRC2DegreePRC2Period1.622.00PRC2HATEMAPeriodPRC2TEMAPeriod).Sql2[0])) 
)
// go long 

Attached Thumbnails
Click image for larger version

Name:	Math.Abs().errors.jpg
Views:	204
Size:	947.1 KB
ID:	25994  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Deepmoney LLM
Elite Quantitative GenAI/LLM
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
43 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800


I believe Math.Abs simply ensures the return is a positive number. Is that what you want?

For example Math.Abs(-24312) returns 24312, and Math.Abs(24312) returns 24312.

Reply With Quote
  #4 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

prc is probl the most heavily repaint (recalculation) indicator.

Reply With Quote
  #5 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


MXASJ View Post
I believe Math.Abs simply ensures the return is a positive number. Is that what you want?

For example Math.Abs(-24312) returns 24312, and Math.Abs(24312) returns 24312.

Cory,

Thats the plan ... it is ... just the way the results come out it has no pattern that I can determine what the error comes from. The screen shot shows two very similar, consecutive entries, but one is long and the other short.

Jon

Started this thread Reply With Quote
  #6 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


cory View Post
prc is probl the most heavily repaint (recalculation) indicator.

Cory,

I appreciate the analysis.

I have looked at the code, I cant really see where it recalculates ... but it is definitely too complex for my wetware.

Any thoughts on a version that doesnt recalculate, or let it recalculate but only allow changes to the current bar? Something like a 'window' to stop changes to already plotted data?

Jon

Started this thread Reply With Quote




Last Updated on November 21, 2010


© 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