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

C#

 
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 
Thank you very much Keith, it cleared out quite some things for me, and I see that my logic sense has been totally lost some time.

I still have some questions on how to solve the case regarding the "yesterdays moving average".

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.

The MovingAverages are some sort preset scripts in a software that I use (IQBroker)

C#
///<param name="indicatorKey" type="Indicator"></param>
        public void OnInitialize(int indicatorKey)
        {
            _MovingAverage10Keys = new int[SymbolCount()];
            _MovingAverage20Keys = new int[SymbolCount()];
            _MovingAverage50Keys = new int[SymbolCount()];
            _indicatorKeys = new int[SymbolCount()];

            for (int i = 0; i < SymbolCount(); i ++)
            {
                _indicatorKeys[i] = IndicatorCopy(indicatorKey, i);
                _MovingAverage10Keys[i] = IndicatorSMA(_indicatorKeys[i], 10);
                _MovingAverage20Keys[i] = IndicatorSMA(_indicatorKeys[i], 20);
                _MovingAverage50Keys[i] = IndicatorSMA(_indicatorKeys[i], 50);

                ChartIndicator(i, 0, IQ_YAxis.MERGE_RIGHT, _indicatorKeys[i], IQ_LineType.LINE, 1, IQ_Color.GREEN);
                ChartIndicator(i, 0, IQ_YAxis.MERGE_RIGHT, _MovingAverage10Keys[i], IQ_LineType.LINE, 1, IQ_Color.RED);
                ChartIndicator(i, 0, IQ_YAxis.MERGE_RIGHT, _MovingAverage20Keys[i], IQ_LineType.LINE, 1, IQ_Color.ORANGE);
                ChartIndicator(i, 0, IQ_YAxis.MERGE_RIGHT, _MovingAverage50Keys[i], IQ_LineType.LINE, 1, IQ_Color.BLUE);
            }
        }
        #endregion</pre>


Here's the If-part of the code:

C#
///<param name="indicatorKey" type="Indicator"></param>;public override void OnSymbolBar(int symbolIndex)
       {
           //double value = IndicatorValue(_indicatorKeys[symbolIndex]);
           double MovingAverage10 = IndicatorValue(_MovingAverage10Keys[symbolIndex]);
           double MovingAverage20 = IndicatorValue(_MovingAverage20Keys[symbolIndex]);
           double MovingAverage50 = IndicatorValue(_MovingAverage50Keys[symbolIndex]);

           if (MovingAverage10 &gt; MovingAverage50  &amp;&amp;  MovingAverage20 &gt; MovingAverage50)
//Here I was thinking of detecting whether MA20 was below MA50 yesterday............. And if it was, then go to next line...
               {
                   BrokerMarket(IQ_ActionType.BUY, symbolIndex, 10, IQ_TIF.DAY, &quot;Buy&quot;);
               }
                   if (MovingAverage20 &lt; MovingAverage50 &amp;&amp; MovingAverage50 - MovingAverage20 &lt;= 0.8 &amp;&amp; PositionExists(IQ_TradeStatus.OPEN, symbolIndex))
           {
               int[] positionIndexes = PositionIndexList(IQ_TradeStatus.OPEN, symbolIndex);
               double quantity = PositionQuantity(positionIndexes[0]);
               BrokerMarket(IQ_ActionType.SELL, symbolIndex, quantity, IQ_TIF.DAY, &quot;Sell&quot;);
           }
       }
       #endregion</pre>


I start to realize that the transition from VBA to C# is pretty tough Smile | :)
Kind regards
Espen

GeneralRe: OT Pin
Keith Barrow25-Apr-13 6:26
professionalKeith Barrow25-Apr-13 6:26 
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 

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.