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

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 (== BarsInProgress)
    {

    }
    else if (
    == BarsInProgress)
    {
        Print(
    "Indicator " Time[0] + " CurrentBar: " CurrentBar " (" BarsInProgress ")");



    Strategy OnBarUpdate()
    PHP Code:

    if (== BarsInProgress)
    {

    }
    else if (
    == 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 (== BarsInProgress)
    {
        
    // own method BarUpdate()
        
    BarUpdate(Time[0], CurrentBarLow[0], High[0], BarsType.Volumes[CurrentBar]);

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by f.saeidi, Yesterday, 12:14 PM
    9 responses
    23 views
    0 likes
    Last Post f.saeidi  
    Started by Tim-c, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Started by FrancisMorro, Today, 03:24 AM
    0 responses
    3 views
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,772 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    31 views
    0 likes
    Last Post Max238
    by Max238
     
    Working...
    X