Click here to Skip to main content
15,887,896 members
Home / Discussions / C#
   

C#

 
GeneralRe: Data in XmlFiles or in Database Pin
Eddy Vluggen26-Apr-13 22:36
professionalEddy Vluggen26-Apr-13 22:36 
AnswerRe: Data in XmlFiles or in Database Pin
Eddy Vluggen26-Apr-13 23:32
professionalEddy Vluggen26-Apr-13 23:32 
GeneralRe: Data in XmlFiles or in Database Pin
Frygreen27-Apr-13 0:31
Frygreen27-Apr-13 0:31 
AnswerRe: Data in XmlFiles or in Database Pin
PIEBALDconsult27-Apr-13 12:31
mvePIEBALDconsult27-Apr-13 12:31 
QuestionRunning a loop, try to get both [i] value (todayvalue), and [i - 1] value (yesterdays value) Pin
lordoftrades25-Apr-13 0:47
lordoftrades25-Apr-13 0:47 
AnswerOT Pin
Keith Barrow25-Apr-13 2:56
professionalKeith Barrow25-Apr-13 2:56 
GeneralRe: OT Pin
lordoftrades25-Apr-13 3:37
lordoftrades25-Apr-13 3:37 
GeneralRe: OT Pin
Keith Barrow25-Apr-13 6:26
professionalKeith Barrow25-Apr-13 6:26 
lordoftrades wrote:
Maybe this explains it better: I'm trying to detect when MA20 is crossing above MA50 (given that MA10 already is above). I need to know that MA20 was below MA50 yesterday to be sure that it has crossed as I'm not interested in the days when it stays above.

Assuming you've calc'd the averages in psuedo code I'd do something like:

C#
//Assuming I've understood correctly :~
double MovingAverage10 = IndicatorValue(_MovingAverage10Keys[symbolIndex]);
double MovingAverage20 = IndicatorValue(_MovingAverage20Keys[symbolIndex]);
double MovingAverage50 = IndicatorValue(_MovingAverage50Keys[symbolIndex]);
double YesterdayMovingAverage10 = IndicatorValue(_MovingAverage10Keys[symbolIndex-1]); //Not needed.
double YesterdayMovingAverage20 = IndicatorValue(_MovingAverage20Keys[symbolIndex-1]);
double YesterdayMovingAverage50 = IndicatorValue(_MovingAverage50Keys[symbolIndex-1]);


public bool NeedToSell()
{
   //If M10 is already above (both M50 & 20 assumed) - reversed condition to exit
   if(MovingAverage10 < MovingAverage50 || MovingAverage10 < MovingAverage20)
       return false;
   //MA20 is crossing above MA50 - reversed condition to exit
   if (MovingAverage20 <= MovingAverage50) 
       return false;
   //MA20 was below MA50 yesterday
   return YesterdayMovingAverage20 < YesterdayMovingAverage50
}



lordoftrades wrote:
I start to realize that the transition from VBA to C# is pretty tough

Darn tootin' I went the other way when I worked at the Uni, took me a while (well, to VB6) to wrap my head around it. The code you have looks quite procedural, my guess is it will simplify if you get the OO goodness right, but without knowing the problem domain it is hard to help.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed”
“One of the greatest problems of our time is that many are schooled but few are educated”


Sir Thomas More (1478 – 1535)

GeneralRe: OT Pin
lordoftrades25-Apr-13 20:29
lordoftrades25-Apr-13 20:29 
QuestionExRichTextBox Pin
Star.jon24-Apr-13 21:45
Star.jon24-Apr-13 21:45 
AnswerRe: ExRichTextBox Pin
Marco Bertschi24-Apr-13 22:10
protectorMarco Bertschi24-Apr-13 22:10 
GeneralRe: ExRichTextBox Pin
Star.jon25-Apr-13 20:32
Star.jon25-Apr-13 20:32 
GeneralRe: ExRichTextBox Pin
Star.jon25-Apr-13 20:35
Star.jon25-Apr-13 20:35 
GeneralRe: ExRichTextBox Pin
Marco Bertschi25-Apr-13 21:49
protectorMarco Bertschi25-Apr-13 21:49 
Questionhow to detect SoundEffect stoped in xna Pin
payjo24-Apr-13 15:15
payjo24-Apr-13 15:15 
Questionsetup error in c# Pin
User349024-Apr-13 4:11
User349024-Apr-13 4:11 
AnswerRe: setup error in c# Pin
Keith Barrow24-Apr-13 5:05
professionalKeith Barrow24-Apr-13 5:05 
QuestionCallBack to consumer using RESTful / MVC / WCF Pin
jexes23-Apr-13 22:51
jexes23-Apr-13 22:51 
QuestionProgramming a Symbol Handheld Scanner Pin
bob18123-Apr-13 20:57
professionalbob18123-Apr-13 20:57 
AnswerRe: Programming a Symbol Handheld Scanner Pin
Pete O'Hanlon23-Apr-13 21:29
mvePete O'Hanlon23-Apr-13 21:29 
AnswerRe: Programming a Symbol Handheld Scanner Pin
Joe Woodbury24-Apr-13 8:19
professionalJoe Woodbury24-Apr-13 8:19 
Questionprinting students grades after finding them in files.. Pin
Magda634723-Apr-13 9:30
Magda634723-Apr-13 9:30 
AnswerRe: printing students grades after finding them in files.. Pin
Eddy Vluggen23-Apr-13 9:36
professionalEddy Vluggen23-Apr-13 9:36 
QuestionWhich one is overriding and which one is overloading Pin
Arun kumar Gautam23-Apr-13 2:55
Arun kumar Gautam23-Apr-13 2:55 
AnswerRe: Which one is overriding and which one is overloading Pin
Keith Barrow23-Apr-13 3:07
professionalKeith Barrow23-Apr-13 3:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.