• 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

Conditional formatting

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

  • NinjaTrader_PaulH
    replied
    Hello gretzkyless,

    The use of the triggerBar is to set when the first condition occurred so that you can evaluate in the 2nd condition: have 2 or less bars occurred since the first condition was true? So you would only change the number of 2 if you wanted to increase the number of allowable bars between condition 1 and condition 2.

    You can certainly use the same code elsewhere that you need to keep the bars between conditions as a condition, just be careful to use a different variable name for triggerBar.

    Leave a comment:


  • gretzkyless
    replied
    Thanks Paul. You read my mind


    Will work on using the current bar as suggested to get the outcome I want.

    As a follow-up question, statement, I'm assuming that the more conditions I add, I would continue to use the current bar, but update as needed for each condition. Will find out shortly.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello gretzkyless,

    Thanks for your post.

    If I understand correctly the issue is that the Macd crosses and you can have a variable number of bars that occur before the small triggers may cross and you want to limit the number of bars to two between the macd cross and the small trigger cross. So my answer will reflect that understanding.

    What would work is to remove the bool condition1true and use an integer variable that will hold the current bar number at the time of the macd cross and then test in the other condition to see that no more 2 bars have passed.

    if
    (CrossAbove(MACD_DiNapoli(8.3897, 17.5185, 9.0503), MACD_DiNapoli(8.3897, 17.5185, 9.0503).Avg, 1))
    {
    triggerBar = CurrentBar; // Save the bar number where this condition occurred
    }

    if
    (((CurrentBar - triggerBar ) <= 2) && CrossAbove(RyanTriggerLinesSmall(20, 5).Plot1_Up, RyanTriggerLinesSmall(20, 5).Plot2_Up, 1)
    {
    DrawArrowUp("UpAarrow" + CurrentBar, true, 0, Low[0] - (offset * TickSize)-0.30, Color.Green);
    }

    Here is a clarification of CurrentBar: http://www.ninjatrader.com/support/h...currentbar.htm

    Please let me know if I can be of further assistance.

    Leave a comment:


  • gretzkyless
    started a topic Conditional formatting

    Conditional formatting

    I have figured out how to have one indicator trigger and then a signal plots when the second indicator triggers. The problem I'm having is the number of bars. I'm not sure how to code x number of bars back.

    Below is what I'm trying to do...
    Trigger - MACD_DiNapoli crosses up
    Signal for trade entry - Small trigger lines cross up.

    CODE TO MAKE THIS HAPPEN
    if
    (CrossAbove(MACD_DiNapoli(8.3897, 17.5185, 9.0503), MACD_DiNapoli(8.3897, 17.5185, 9.0503).Avg, 1))
    {
    condition1true = true;
    }

    if
    (condition1true == true && CrossAbove(RyanTriggerLinesSmall(20, 5).Plot1_Up, RyanTriggerLinesSmall(20, 5).Plot2_Up, 1)
    {
    DrawArrowUp("UpAarrow" + CurrentBar, true, 0, Low[0] - (offset * TickSize)-0.30, Color.Green);
    condition1true = false;
    }

    The problem is, sometimes the small trigger lines cross up many bars after MACD crosses up. I want to limit the number of bars back to 2. What am I missing? Please advise.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Nate G, Yesterday, 05:27 PM
1 response
11 views
0 likes
Last Post MojoJojo  
Started by Mindset, Yesterday, 10:35 PM
1 response
5 views
0 likes
Last Post Mindset
by Mindset
 
Started by habibalex, Yesterday, 08:19 PM
1 response
11 views
0 likes
Last Post NinjaTrader_Marco  
Started by lakersfan, Yesterday, 07:53 PM
0 responses
10 views
0 likes
Last Post lakersfan  
Started by RobertoPaez, Yesterday, 07:33 PM
0 responses
6 views
0 likes
Last Post RobertoPaez  
Working...
X