Click here to Skip to main content
15,909,091 members
Home / Discussions / C#
   

C#

 
GeneralRe: Data in XmlFiles or in Database Pin
jschell29-Apr-13 7:45
jschell29-Apr-13 7:45 
GeneralRe: Data in XmlFiles or in Database Pin
Jasmine250129-Apr-13 13:13
Jasmine250129-Apr-13 13:13 
GeneralRe: Data in XmlFiles or in Database Pin
jschell30-Apr-13 9:44
jschell30-Apr-13 9:44 
GeneralRe: Data in XmlFiles or in Database Pin
Jasmine250130-Apr-13 11:30
Jasmine250130-Apr-13 11:30 
GeneralRe: Data in XmlFiles or in Database Pin
jschell1-May-13 8:22
jschell1-May-13 8:22 
GeneralRe: Data in XmlFiles or in Database Pin
Jasmine25011-May-13 9:03
Jasmine25011-May-13 9:03 
GeneralRe: Data in XmlFiles or in Database Pin
jschell2-May-13 7:57
jschell2-May-13 7:57 
GeneralRe: Data in XmlFiles or in Database Pin
Jasmine25012-May-13 9:02
Jasmine25012-May-13 9:02 
GeneralRe: Data in XmlFiles or in Database Pin
jschell3-May-13 11:02
jschell3-May-13 11:02 
GeneralRe: Data in XmlFiles or in Database Pin
Jasmine25013-May-13 11:40
Jasmine25013-May-13 11:40 
GeneralRe: Data in XmlFiles or in Database Pin
jschell6-May-13 8:11
jschell6-May-13 8:11 
GeneralRe: Data in XmlFiles or in Database Pin
Jasmine25016-May-13 8:26
Jasmine25016-May-13 8:26 
GeneralRe: Data in XmlFiles or in Database Pin
jschell7-May-13 9:27
jschell7-May-13 9:27 
AnswerRe: Data in XmlFiles or in Database Pin
RedDk26-Apr-13 11:54
RedDk26-Apr-13 11:54 
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 

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.