| Coding Forum Collaborate, receive help, or discuss coding related issues. |
![]() | | Tweet | |
| | #1 | ||
![]() | What Am I Missing with My Slope Calculation Code ? The issue is basically that even with the slope degree input adjusted to extremes, some of these flat spots still trigger differently. If working properly the small transition in the middle should have stayed magenta as opposed to going green for 2-3 bars and back to magenta. Am I missing something in my code ? ![]() Here is a snippet of the EasyLanguage code in question. Code: Inputs: SlopeAv(5); Vars; Slope(0); Avg = average( Close, length) ; Slope =(TLSlopeEasy(Avg,1,SlopeAv)); if colorMode = 1 then setplotcolor[1](1, iff( Avg <Avg [1] and (Slope < .01 ), magenta, green ) ); plot1 (Avg , "Avg "); Below is a snippet from the diagnostics file (area highlighted in blue is where the color shift occurs). Am I missing something ...seems like just the type of scenario I was trying to smooth. The answer could be staring me in the face and I might not be seeing it. ------------------------------------------------------------------------------ 1111214 1419Avg 3.48Avg[1] 3.51|slope -0.04|condition FALSE 1111214 1419Avg 3.45Avg[1] 3.48|slope -0.03|condition FALSE 1111214 1420Avg 3.42Avg[1] 3.45|slope -0.03|condition FALSE 1111214 1420Avg 3.40Avg[1] 3.42|slope -0.03|condition FALSE 1111214 1420Avg 3.38Avg[1] 3.40|slope -0.03|condition FALSE 1111214 1420Avg 3.37Avg[1] 3.38|slope -0.02|condition FALSE 1111214 1420Avg 3.36Avg[1] 3.37|slope -0.02|condition FALSE 1111214 1420Avg 3.35Avg[1] 3.36|slope -0.02|condition FALSE 1111214 1421Avg 3.34Avg[1] 3.35|slope -0.01|condition FALSE 1111214 1421Avg 3.34Avg[1] 3.34|slope -0.01|condition FALSE 1111214 1423Avg 3.35Avg[1] 3.34|slope -0.01|condition FALSE 1111214 1424Avg 3.35Avg[1] 3.35|slope -0.00|condition FALSE 1111214 1426Avg 3.35Avg[1] 3.35|slope 0.00| condition FALSE 1111214 1429Avg 3.36Avg[1] 3.35|slope 0.00| condition FALSE 1111214 1429Avg 3.36Avg[1] 3.36|slope 0.00| condition FALSE 1111214 1429Avg 3.36Avg[1] 3.36|slope 0.00| condition FALSE 1111214 1430Avg 3.36Avg[1] 3.36|slope 0.00| condition FALSE 1111214 1430Avg 3.36Avg[1] 3.36|slope 0.00| condition FALSE 1111214 1430Avg 3.36Avg[1] 3.36|slope 0.00| condition FALSE 1111214 1431Avg 3.35Avg[1] 3.36|slope -0.00|condition FALSE Any help would be much appreciated | ||
| |
|
| | #2 | ||
![]() | Re: What Am I Missing with My Slope Calculation Code ? | ||
| |
|
| The Following User Says Thank You to onesmith For This Useful Post: | ||
Tams (12-16-2011) | ||
| | #3 | ||
![]() | Re: What Am I Missing with My Slope Calculation Code ? Quote:
To change color down it would need to pass this test: Avg <Avg [1] and Avg[1] < Avg [2] and Avg[2] < Avg [3] otherwise stay the same color, or display a neutral color. var: ChangeDown(False), ChangeUp(False); ChangeDown = Avg <Avg [1] and Avg[1] < Avg [2] and Avg[2] < Avg [3]; ChangeUp = Avg >Avg [1] and Avg[1] > Avg [2] and Avg[2] > Avg [3]; if ChangeDown then setplotcolor[1](1, magenta ) else if ChangeUp then setplotcolor[1](1, Green );
__________________ Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens. | ||
| |
|
| | #4 | ||
![]() | Re: What Am I Missing with My Slope Calculation Code ?
__________________ Fear none, frighten none. -My Best Contribution So Far -Open Source Trading Platforms (Master List) | ||
| |
|
| | #5 | ||
![]() | Re: What Am I Missing with My Slope Calculation Code ? Code: input: threshold(.1); var: avg(0), slope(0); avg=average(c,10); slope=(avg-avg[10])/10; if slope > threshold then setplotcolor(1,green) else if slope < -threshold then setplotcolor(1,red); plot1(avg,"avg"); | ||
| |
|
| | #6 | ||
![]() | Re: What Am I Missing with My Slope Calculation Code ?
__________________ Fear none, frighten none. -My Best Contribution So Far -Open Source Trading Platforms (Master List) | ||
| |
|
| The Following User Says Thank You to Do Or Die For This Useful Post: | ||
tommaso (12-20-2011) | ||
| | #7 | ||
![]() | | ||
| |
|
| The Following User Says Thank You to tommaso For This Useful Post: | ||
Do Or Die (12-20-2011) | ||
| | #8 | ||
![]() | Re: What Am I Missing with My Slope Calculation Code ? Quote:
S(i) = P(i) - P(i-1) i= 1, ... , k-1 If i represents an index from 1 to 10 what does k represent? ... a 1 point increment in grid? Can you help me visualize k in the code below? Code: for i=1 to 10 begin
s(i)=p(i)-p(i-1);
end; | ||
| |
|
| The Following User Says Thank You to onesmith For This Useful Post: | ||
Do Or Die (12-21-2011) | ||
![]() |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Slope of MACD Calculate Angle | v101 | Technical Analysis | 7 | 07-13-2010 04:33 AM |
| MA Slope | PeterBrazel | Coding Forum | 4 | 08-18-2009 12:05 AM |
| Tick Size Calculation | PeterBrazel | Coding Forum | 1 | 08-17-2009 08:55 PM |
| MA Slope | PeterBrazel | Coding Forum | 19 | 07-05-2009 11:27 PM |
| Determine Slope End or Start | januson | Technical Analysis | 11 | 11-20-2008 04:39 PM |