Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator, Strategy, run synchronously

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

    Indicator, Strategy, run synchronously

    Hello,

    I use an indicator and a strategy, each with 2 data series.
    1. Series 1 minute
    2. Series 5 seconds
    I implemented the indicator in the strategy.
    And I want that with every bar, first the indicator and then the strategy is called.

    I did read the documentation. This has not yet brought me.




    The indicator was added to the strategy normally in the OnStateChange method.

    Current status

    Indikator OnBarUpdate()
    PHP Code:
    
    if (0 == BarsInProgress)
    {
    
    }
    else if (1 == BarsInProgress)
    {
        Print("Indicator " + Time[0] + " CurrentBar: " + CurrentBar + " (" + BarsInProgress + ")");
    } 
    


    Strategy OnBarUpdate()
    PHP Code:
    
    if (0 == BarsInProgress)
    {
    
    }
    else if (1 == BarsInProgress)
    {
        // indikator Update
        MyVariableIndicator.Update();
        Print("Strategy " + Time[0] + " CurrentBar: " + CurrentBar + " (" + BarsInProgress + ")");
    } 
    

    current result (Ninja Script output)
    Indicator 15.06.2020 00:03:00 CurrentBar: 35 (1)
    Indicator 15.06.2020 00:03:05 CurrentBar: 36 (1)
    Indicator 15.06.2020 00:03:10 CurrentBar: 37 (1)
    Indicator 15.06.2020 00:03:45 CurrentBar: 38 (1)
    Indicator 15.06.2020 00:03:55 CurrentBar: 39 (1)
    Strategy 15.06.2020 00:03:00 CurrentBar: 35 (1)
    Strategy 15.06.2020 00:03:05 CurrentBar: 36 (1)
    Strategy 15.06.2020 00:03:10 CurrentBar: 37 (1)
    Strategy 15.06.2020 00:03:45 CurrentBar: 38 (1)
    Strategy 15.06.2020 00:03:55 CurrentBar: 39 (1)
    Indicator 15.06.2020 00:04:00 CurrentBar: 40 (1)
    Indicator 15.06.2020 00:04:05 CurrentBar: 41 (1)
    Indicator 15.06.2020 00:04:10 CurrentBar: 42 (1)
    Indicator 15.06.2020 00:04:15 CurrentBar: 43 (1)
    Indicator 15.06.2020 00:04:20 CurrentBar: 44 (1)
    Indicator 15.06.2020 00:04:25 CurrentBar: 45 (1)
    Indicator 15.06.2020 00:04:30 CurrentBar: 46 (1)
    Indicator 15.06.2020 00:04:35 CurrentBar: 47 (1)
    Indicator 15.06.2020 00:04:45 CurrentBar: 48 (1)
    Indicator 15.06.2020 00:04:55 CurrentBar: 49 (1)
    ... etc


    But i need
    Indicator 15.06.2020 00:03:00 CurrentBar: 35 (1)
    Strategy 15.06.2020 00:03:00 CurrentBar: 35 (1)
    Indicator 15.06.2020 00:03:05 CurrentBar: 36 (1)
    Strategy 15.06.2020 00:03:05 CurrentBar: 36 (1)
    ... etc



    How can I achieve that with each bar, first the indicator and then the strategy is called?

    #2
    I have now solved that. I have created my own function for the 2 Data series. I then call this up separately in the strategy.

    PHP Code:
    
    else if (1 == BarsInProgress)
    {
        // own method BarUpdate()
        BarUpdate(Time[0], CurrentBar, Low[0], High[0], BarsType.Volumes[CurrentBar]);
    } 
    

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X