Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Started by alifarahani, Today, 09:40 AM
      6 responses
      41 views
      0 likes
      Last Post alifarahani  
      Working...
      X