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

One per Bar

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

    One per Bar

    Hello,

    please I have a dub.

    I'm developing a strategy in Ticks. When start a bar (ex. 5 min.), in a certain moment an "indicator > Value" and give the signal. I would like to fix this price.

    My question: Is there a specify function "One per Bar" or may I use variable?

    This is my propose (CalculateOnBarClose = false)

    How can you see (in red color) a variable go=1 every first tick of every candle and go=0 when there is the first signal of the indicator. It work fine but maybe there is a better function.

    Many thanks!
    ================================================== =======

    protected override void OnBarUpdate()
    {

    if (FirstTickOfBar)
    {
    DetectSignalUp = 1;
    DetectSignalDown = 1;

    }
    if (sCandles.SpreadHigh[0]>= LevSpreadCS)
    {
    if (DetectSignalUp == 1)
    {
    extremeRed = GetCurrentBid();
    Print (Time[0].ToString() + " | " + extremeRed + " | Extreme UP red arrow");
    DrawTriangleDown("My triangle down" + CurrentBar, false, 0, extremeRed, Color.Red);
    DetectSignalUp = 0;
    }
    }

    else if (sCandles.SpreadLow[0]<= LevSpreadCSLow)
    {
    if (DetectSignalDown == 1)
    {
    extremeGreen = GetCurrentAsk();
    DrawTriangleUp("My triangle up" + CurrentBar, false, 0, extremeGreen, Color.Lime);
    Print (Time[0].ToString() +" | " + extremeGreen + " | Extreme DOWN green arrow");
    DetectSignalDown = 0;

    }
    }
    }

    #2
    Hello ClauTrade,

    Thank you for your post.

    In order to have the signal once per bar utilizing FirstTickOfBar is the correct function.

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by traderqz, Today, 12:06 AM
    2 responses
    3 views
    0 likes
    Last Post traderqz  
    Started by RideMe, 04-07-2024, 04:54 PM
    5 responses
    28 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by f.saeidi, Today, 08:13 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by DavidHP, Today, 07:56 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by kujista, Today, 06:23 AM
    3 responses
    11 views
    0 likes
    Last Post kujista
    by kujista
     
    Working...
    X