• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Triple cross - indicator - logic development

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

    Triple cross - indicator - logic development

    Hello,

    Can anyone help with the code logic. I am decent at coding, not an expert but I can work my way around. I am trying to do the following:

    I have an indicator. Let's take for example I use the RVI indicator and I add the indicator three times using different values (50) (100) and (200) .

    I want to set an alert or draw an arrow when the 50 crosses above both 100 and 200. It's pretty simple to just do

    if (CrossAbove(... , ..., 1))
    {

    }


    However, i want to put a logic where to only draw the arrow and set alert when it crosses not just in the last bar. The reason is because it could cross anytime, doesn't have to be in the last bar. I also want it so that if 100 is above 200 or 200 is above 100 doesn't matter as long as the 50 crosses above both.

    Once that is confirmed then send the signal. When i do a CrossAbove or CrossBelow it looks back x number of bars. . . . i don't want to put x number of bars... . because it could happen in the last 100 bars. . .

    let me know if this makes sense. . i included an image of the crosses i'm trying to capture.


    #2
    Hello priceisking,

    Thanks for your post.

    When your script is loaded, it will process each historical bar starting from the very first bar n days ago (according to the days to load of the chart). If the condition exists 50 crosses above the 100 & 200) then you can draw the arrow. Please note that the Alert() method will only function when the data is real time, so you would not see historical Alerts().

    To see all the historical crosses marked, you would draw the arrow and make sure that the draw arrow uses a unique tag name to prevent the arrow from being removed. To create a unique tag name you can add the CurrentBar number to the tag name used, for example "MyUpArrow"+CurrentBar. Reference: https://ninjatrader.com/support/help...currentbar.htm

    In looking at your screenshot, I wonder if the real concern you have is that the cross condition does not happen on the same bar for both the 100 and 200. In the example you showed, in each case it appears that it would cross the 100 followed by the cross of the 200, so in that regard perhaps all you need is a single cross condition of checking the 50 to the 200.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Paul. I think the latter will end up doing. Will just have to code extra for when 100 is above 200 and when 200 is above 100 .. this way I an capture when 50 crosses both those conditions.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by junkone, 09-12-2019, 07:10 PM
      11 responses
      77 views
      0 likes
      Last Post cnecorp
      by cnecorp
       
      Started by cordoba, Today, 01:38 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by Irukandji, Today, 01:42 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by RogerLin, Today, 12:49 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by Plaket, Today, 12:54 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Working...
      X