• 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

IsFirstBarOfSession Question - runs twice?

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

  • liquid150
    replied
    Originally posted by NinjaTrader_Jesse View Post
    Hello liquid150,

    Thank you for the post.

    From the given code nothing sticks out as to what may be the cause, the only item which may cause this would be using a multi series script. Is that applicable here?

    I would otherwise need more details surrounding the test, would it be possible to extract the condition you have made and print and place that in a new empty indicator for testing? that could help to isolate the specific requirements to see this which will also help to understand why that's happening.

    You could try adding the BarsInProgress to your print or CurrentBar to see if anything else can be found:

    Code:
    Print(BarsInProgress + " " + CurrentBar + " " + "Bacon = " + priordaydeuptracker[0]);

    I look forward to being of further assistance.
    Thanks for the reply Jesse,

    Yes! This is a multiple data series script. I am also loading Daily and Weekly data. I must have assumed NT "knew" daily and weekly bars wouldn't handle IsFirstBarOfSession.

    Thanks for this information! I've moved this section of my code to reside within BarsInProgress == 0. It seems to be working as expected, now! I will reply to this thread if there are any additional problems with this issue.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello liquid150,

    Thank you for the post.

    From the given code nothing sticks out as to what may be the cause, the only item which may cause this would be using a multi series script. Is that applicable here?

    I would otherwise need more details surrounding the test, would it be possible to extract the condition you have made and print and place that in a new empty indicator for testing? that could help to isolate the specific requirements to see this which will also help to understand why that's happening.

    You could try adding the BarsInProgress to your print or CurrentBar to see if anything else can be found:

    Code:
    Print(BarsInProgress + " " + CurrentBar + " " + "Bacon = " + priordaydeuptracker[0]);

    I look forward to being of further assistance.

    Leave a comment:


  • liquid150
    started a topic IsFirstBarOfSession Question - runs twice?

    IsFirstBarOfSession Question - runs twice?

    Good morning,

    I have written an empirical scan into a strategy which tracks what happens after a specific bar pattern and calculates a percentage probability of the likely outcome based on the historical data loaded. I want to reset the count every day, but keep the previous day's counts for use in the calculations. I have tried to do this by creating multiple series to house the counts. During debugging I have noticed the IsFirstBarOfSession script I have written appears to process twice, but I could be missing something. On the second process the number previously sent to the prior day series switches to zero. Here is the script in question:

    Code:
    if (Bars.IsFirstBarOfSession)
                {
                    priordaydeuptracker[0] = deuptracker[1];
                    priordaydedowntracker[0] = dedowntracker[1];
                    priordaydetotaltracker[0] = detotaltracker[1];    
                    Print("Eggs = " + priordaydeuptracker[0]);
                    longtradefilter = false;
                    shorttradefilter = false;
                    trailingstoppriceseries[0] = stoplosss;
                    losslimitbool = false;
                    gainlimitbool = false;
                    currentPnL = 0.00;
                    risklimitbool = false;
                    deupcount = 0;
                    dedowncount = 0;
                    deuptracker[0] = 0;
                    dedowntracker[0] = 0;
                    detotaltracker[0] = 0;
                    decounter = 0;
                    Print("Bacon = " + priordaydeuptracker[0]);
                }
    else
                {
                    priordaydeuptracker[0] = priordaydeuptracker[1];
                    priordaydedowntracker[0] = priordaydedowntracker[1];
                    priordaydetotaltracker[0] = priordaydetotaltracker[1];
                }
    The variables deupcount, dedowncount, and decounter house the counts which are injected into series. I have arranged these in a sequence I would expect should perform the order of operations correctly, but when I run the strategy in Strategy Analyzer and check the Bacon and Eggs prints (so named for ease of finding them in the Output screen) I find that after the priorday trackers are assigned, a second assignment occurs after the other variables and series have been reset to zero. The output screen shows this print:

    Eggs = 4
    Bacon = 4
    Eggs = 0
    Bacon = 0

    There are no other assignments to the priorday series anywhere in the strategy, and there are no other bacon and eggs prints, either. I am not sure why this code is running twice like this and undoing itself. Any input on this is appreciated.

    Cheers.
    Last edited by liquid150; 02-10-2020, 07:36 AM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by karolwatcher, Today, 08:15 PM
0 responses
3 views
0 likes
Last Post karolwatcher  
Started by tradykat, Today, 06:07 PM
0 responses
7 views
0 likes
Last Post tradykat  
Started by tradykat, Today, 05:09 PM
0 responses
10 views
0 likes
Last Post tradykat  
Started by jeronymite, Today, 04:57 PM
0 responses
8 views
0 likes
Last Post jeronymite  
Started by caveat_lector, Today, 04:34 PM
0 responses
6 views
0 likes
Last Post caveat_lector  
Working...
X