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

OnMarketData question

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

    #16
    koganam, explain please about 1/381 percent - i don't understand this thing - how do you calculate this percent and what does it mean?

    Comment


      #17
      Originally posted by agafon2 View Post
      koganam, explain please about 1/381 percent - i don't understand this thing - how do you calculate this percent and what does it mean?
      You are asking why there is a difference of 1 (382 - 381) in volume. That fractional difference is 1/381.

      Comment


        #18
        Originally posted by agafon2 View Post
        Hello

        This is an indicator, which in real time separate volume on every Last tick to bulls or bears (if last price = bid - volume is bearish; if last price = ask - volume is bullish)

        Here is a code:

        Code:
                int Previous_time;
                double Previous_Ask, Previous_Bid; 
                double Bulls_Volume, Bears_Volume;
        
                /// <summary>
                /// This method is used to configure the indicator and is called once before any bar data is loaded.
                /// </summary>
                protected override void Initialize()
                {
                    Overlay                = true;
                    CalculateOnBarClose = false;
                }
        
                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
        
                protected override void OnMarketData(MarketDataEventArgs e)
                {
                    
                  if (e.MarketDataType == MarketDataType.Ask) {
                    Previous_Ask = e.Price;
                    Print("Ask = " + e.Price + " " + e.Time);    
                  }    
                
                  if (e.MarketDataType == MarketDataType.Bid) {
                    Previous_Bid = e.Price; 
                    Print("Bid = " + e.Price + " " + e.Time);    
                  }
                    
                  if (e.MarketDataType == MarketDataType.Last) {
                    if(e.Price == Previous_Ask) {
                      Bulls_Volume += e.Volume;
                    } else {
                      Bears_Volume += e.Volume; 
                    }
                    
                    
                    /*
                    if(e.Price == Previous_Bid) {
                      Bears_Volume += e.Volume; 
                    }*/
                    
                    //Print("Last = " + e.Price + " " + e.Time + " Volume: " +e.Volume);
                  }
                
                }        
        
                }
        Result:

        Look at this picture:
        SaveImg &#1087;&#1086;&#1079;&#1074;&#1086;&#1083;&#1080;&#1090; &#1074;&#1072;&#1084; &#1079;&#1072;&#1075;&#1088;&#1091;&#1079;&#1080;&#1090;&#1100; &#1092;&#1086;&#1090;&#1086; &#1080;&#1083;&#1080; &#1082;&#1072;&#1088;&#1090;&#1080;&#1085;&#1082;&#1091; &#1073;&#1077;&#1089;&#1087;&#1083;&#1072;&#1090;&#1085;&#1086; &#1080; &#1073;&#1077;&#1079; &#1088;&#1077;&#1075;&#1080;&#1089;&#1090;&#1088;&#1072;&#1094;&#1080;&#1080;


        On some bars a sum of bearish (red color) and bullish (green color) is equals total volume on bar (black color) - and it's exactly correct, but on some bars this sum of bearish and bullish volumes doesn't equal total volume on bar - why it's so?
        Hi agafon2,

        did you resolve the issue in the meantime? I want to do the same thing, so I am wondering how you accomplished to split the volume correctly.

        Cheers,
        NutFlush

        P.S. If you haven't resolved it, I might have an idea where the problem is...

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ETFVoyageur, Today, 02:08 AM
        0 responses
        3 views
        0 likes
        Last Post ETFVoyageur  
        Started by kujista, 04-22-2024, 07:46 AM
        3 responses
        12 views
        0 likes
        Last Post kujista
        by kujista
         
        Started by kujista, 04-23-2024, 06:23 AM
        7 responses
        57 views
        0 likes
        Last Post kujista
        by kujista
         
        Started by SentientDavid, Today, 01:34 AM
        0 responses
        6 views
        0 likes
        Last Post SentientDavid  
        Started by MrForgetful, Today, 01:28 AM
        0 responses
        5 views
        0 likes
        Last Post MrForgetful  
        Working...
        X