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 NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X