Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Heikin-Ashi

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Hello fliesen,

    Thank you for your patience.

    I was only able to produce four alerts during the day. Your NinjaScript / C# Code will always be logically processed and evaluate according to your set logic - this can of course lead to unexpected results at times, thus we would suggest to simplify and debug your code to better understand the event sequence it would go through - unfortunately we cannot offer such debug or code modification services here, but please see the provided resources below to help you proceed productively :

    First of all you would want to use Print() statements to verify values are what you expect - Debugging your NinjaScript code: http://www.ninjatrader.com/support/f...ead.php?t=3418

    For strategies add TraceOrders = true to your Initialize() method and you can then view valuable output related to strategy submitted orders through Tools > Output window - TraceOrders: http://www.ninjatrader.com/support/f...ead.php?t=3627

    It may also help to add drawing objects to your chart for signal and condition confirmation - Drawing Objects: http://www.ninjatrader.com/support/f...ead.php?t=3419

    If you would prefer the debug assist of a professional NinjaScript consultant, please check into the following listings - Click here for a list of certified NinjaScript Consultants: http://www.ninjatrader.com/partners#...pt-Consultants

    Comment


      #17
      Thank you Patrick for your exhaustive explanation, but I just discovered that the problem simply depends upon the Rearm function, presently set to 0, so that the alerts may occur only once. As soon as I set it to another value, the strategy works perfectly.
      Then everything is now ok. So long.

      Comment


        #18
        Excuse me Patrick
        Just to learn how Ninja works, I run the strategy with my 7-instrument list, printing its steps to the Output Window (Alert + Instrument +Time).
        I expected that any instrument were to be analyzed one after the other in a regular sequence, as 1-2-3-4-5-6-7 then back to 1-2-3-4-5-6-7 etc.
        On the contrary, the attachment shows that there is no order: the first symbol is CL, then HG, then CL again, then $EUR/USD twice, then a new one then $EUR/USD once again, then CL twice and so on.
        Take for granted that my code is a very simple one, with no loops or jumps either, then why are instruments analyzed this "casual" way ?
        By the way: if Time[0] doesn't print seconds, how may I display them too ?
        Attached Files

        Comment


          #19
          Hello fliesen,

          Thank you for your post.

          The seconds only print when a bar close is not at 00, I assume this is ran on minute data as the time stamp is on the minute. If you ran this as CalculateOnBarClose = False then it would print the time stamp of each tick which would include the seconds on the real-time data (historical would still reflect 00 for the seconds).

          May I review your code on my end?

          Comment


            #20
            Sure.
            The code core is in lines 78-81, which look for a new uptrend = a reverse of bearish HeikinAshi candles, eventually giving an alert at line 84 and setting a mark (Variable0) for identifying and warning a possible Close of this new trend (lines 58-62).
            Lines 88 to 118 enforce the signal as long as other indicators (Stochastics and ParabolicSar) confirm the uptrend.

            Same thing is implemented for the opposite search of a downtrend (lines 120 to end, with warning at lines 68 to 74).

            Prints to Output occur before and after any if-statement.

            PS: Your end might need the HkAshi.cs file of the post #15.
            Attached Files
            Last edited by fliesen; 04-02-2014, 10:05 AM.

            Comment


              #21
              Hello fliesen,

              Thank you for your response.

              Is this being ran as a basket test in the Strategy Analyzer?

              I was unable to reproduce the same results, although I used a 1 Minute bar series for the input. What is the Period and Interval used in your test?

              Comment


                #22
                No basket test, and yes, I run it on the 1-minute timeframe.
                This is a very simple strategy, just releasing reversal signals in the alert window. The only thing one needs is the HkAshi.cs file for implementing the HeikinAshi bars, a variant of normal japanese candlesticks. Everything else is standardly available at Ninja. If you speak about the Output prints, yes, I changed something for your better understanding of the code. If you mean that results are ok, this is enough to me, I'd only like to see how Ninja follows its logic, since lately I experienced some strange occurences.
                As an example, I tried to perfectly DUPLICATE a strategy and to run them both. In such a case I should get the same alerts twice. On the contrary, although this does happens in most cases, I often get only ONE alert instead of two as expected. This necessarily means that something is wrong with "either" strategy, and that I can't rely on it. Therefore I need to understand what's going on.
                Last edited by fliesen; 04-02-2014, 12:00 PM.

                Comment


                  #23
                  Hello fliesen,

                  Thank you for your response.

                  My results would be as expected, seems the strategy is running fine on my end.

                  Comment


                    #24
                    A small problem: the following IF-ELSE condition is not working since I often get BOTH Alert1 AND Alert2 instead of either one. Why ?
                    if (Variable1==1 && Variable2==1)

                    {
                    Alert("MyAlert1", Priority.High, "Signal 1", @"C:\Programmi\NinjaTrader 7\sounds\Alert2.wav", 60, Color.White, Color.Red);
                    }


                    else


                    if (Variable1==1 || Variable2==1)

                    {
                    Alert("MyAlert2", Priority.High, "Signal 2", @"C:\Programmi\NinjaTrader 7\sounds\Alert2.wav", 60, Color.White, Color.Gray);
                    }
                    Last edited by fliesen; 04-03-2014, 02:53 AM.

                    Comment


                      #25
                      Hello fliesen,

                      Thank you for your response.

                      Those conditions would return true together each time, unless only Variable 1 or 2 was 1.

                      Comment


                        #26
                        Shoudn't the IF-ELSE statement return either one consequence, eventually none, but never both ?
                        I supposed it works this way:

                        If condition1 is true -> {do something}
                        _______otherwise -> {do nothing}

                        resulting in one consequence ("something") or none of both.

                        Alternatively:

                        If condition1 is true -> {do this}
                        _______otherwise -> if condition2 is true -> {do that}
                        ________________________otherwise -> {do nothing}

                        resulting in one between "this" or "that", or none of the three.

                        So how do I get just ONE consequence in the above cases, and not two together ?
                        Last edited by fliesen; 04-03-2014, 10:05 AM.

                        Comment


                          #27
                          Hello fliesen,

                          Thank you for your response.

                          That is my understanding as well, do you mind if I test the full file on my end? You will find the file in the following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Indicator or Strategy respectively.

                          Comment


                            #28
                            No problem at all, here it is. Please remember that the .cs file of post #15 is required on your end.
                            You may disregard all lines but 216 to 242 for the uptrend (or 266 to 293 for the opposite downtrend). The code works fine giving reliable signals, with the small disease that SOMETIMES I get both the alerts # 9n and 9o, as well as 9p and 9q, while - because of the IF-ELSE statement - I should expect only one of them.
                            Basically, the double signal is quite a small trouble, as far as alerts but no orders are concerned. However, I'm curious to understand the IF-ELSE function for future use.
                            (I apologize for the many "Print" statements introduced for debugging)
                            Attached Files
                            Last edited by fliesen; 04-03-2014, 12:51 PM.

                            Comment


                              #29
                              Hello fliesen,

                              Thank you for your response.

                              Here you have an else then a print and then another if. You need to put these together as else if not else then print and then if. Please make the corrections as seen below:
                              Code:
                              				if (StochasticsFast(3, 14).K[0] < StochasticsFast(3, 14).D[0] && (StochasticsFast(3, 14).D[0] > 75 || StochasticsFast(3, 14).K[0] > 75))
                              			{
                              	Print("Alert9n   "+Instrument.FullName+"    "+Time[0]);
                              					Alert("MyAlert9n", Priority.High, "HkA$/FAST--   "+ Close[0]+"  "+Math.Round(StochasticsFast(3, 14).K[0]) +"<"+Math.Round(StochasticsFast(3, 14).D[0])+"%", @"C:\Programmi\NinjaTrader 7\sounds\Alert2.wav", 60, Color.Gold, Color.DarkGreen);
                              			}
                              				[B]else if [/B](StochasticsFast(3, 14).D[0] > 75 || StochasticsFast(3, 14).K[0] > 75)
                              			{
                              	Print("Alert9o   "+Instrument.FullName+"    "+Time[0]);
                              					Alert("MyAlert9o", Priority.High, "HkA$/FaSt-   "+ Close[0]+"  "+Math.Round(StochasticsFast(3, 14).D[0]) +":"+Math.Round(StochasticsFast(3, 14).K[0])+"%", @"C:\Programmi\NinjaTrader 7\sounds\Alert2.wav", 60, Color.Gold, Color.Green);
                              			}	
                              			
                              Print("VorAlert9p   "+Instrument.FullName+"    "+Time[0]);			
                                			
                              				if (ParabolicSAR(0.02, 0.2, 0.02)[0] > Close[0] && ParabolicSAR(0.05, 0.3, 0.05)[0] > Close[0])
                              			{
                              	Print("Alert9p   "+Instrument.FullName+"    "+Time[0]);
                              					Alert("MyAlert9p", Priority.High, "HkA$/SAR--   "+ Close[0], @"C:\Programmi\NinjaTrader 7\sounds\Alert2.wav", 60, Color.Gold, Color.Black);
                              			}
                              			  	[B]else if [/B](ParabolicSAR(0.02, 0.2, 0.02)[0] > Close[0] || ParabolicSAR(0.05, 0.3, 0.05)[0] > Close[0])
                              			{
                              	Print("Alert9q   "+Instrument.FullName+"    "+Time[0]);
                              					Alert("MyAlert9q", Priority.High, "HkA$/Sar-   "+ Close[0], @"C:\Programmi\NinjaTrader 7\sounds\Alert2.wav", 60, Color.Gold, Color.Gray);
                              			}

                              Comment


                                #30
                                Thanks a lot.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by AaronKoRn, Yesterday, 09:49 PM
                                0 responses
                                11 views
                                0 likes
                                Last Post AaronKoRn  
                                Started by carnitron, Yesterday, 08:42 PM
                                0 responses
                                10 views
                                0 likes
                                Last Post carnitron  
                                Started by strategist007, Yesterday, 07:51 PM
                                0 responses
                                12 views
                                0 likes
                                Last Post strategist007  
                                Started by StockTrader88, 03-06-2021, 08:58 AM
                                44 responses
                                3,982 views
                                3 likes
                                Last Post jhudas88  
                                Started by rbeckmann05, Yesterday, 06:48 PM
                                0 responses
                                10 views
                                0 likes
                                Last Post rbeckmann05  
                                Working...
                                X