Ive edited and rewrote my original post. I have been able to make this run perfect with the following setup, and the output displays 100% proper all of the time BUT this is not level 2, I have literally 9 different strategys I have been working on trying to get level two to do cumulative bid/ask to 1.3 ratio but for the life of me I can not do it and I have fallen off track. 1 minute chart, NQ, Calculate.OnEachTick; data resets on the beginnign of next bar, I will end up adding "do not buy/sell if ratio = 1 or 0 but I havent gotten that far yet.....
Here is the code I have for L1, any insight on how to modify this to run off L2 data??? Any help wouold be appreciated, Im losing my mind....
Here are the different segments associated with the bid/ask.
public class NQGROBIDASK1 : Strategy
{
private MACD MACD1;
private double cumulativeAskVolume = 0;
private double cumulativeBidVolume = 0;
_______________________________
protected override void OnMarketData(MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Last)
{
double tradePrice = e.Price;
double tradeVol = e.Volume;
double bid = e.Bid;
double ask = e.Ask;
if (tradePrice >= ask)
cumulativeAskVolume += tradeVol; // Buy at ask or higher
else if (tradePrice <= bid)
cumulativeBidVolume += tradeVol; // Sell at bid or lower
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 1 || MACD1 == null)
return;
// Reset mumulative volumes at the start of each bar
if (IsFirstTickOfBar)
{
cumulativeAskVolume = 0;
cumulativeBidVolume = 0;
}
// alculate and pritn bid/ask ratio
double totalVolume = cumulativeAskVolume + cumulativeBidVolume;
Print("Bar " + CurrentBar + " - Ask/Bid Ratio: " + askBidRatio.ToString("F2") +

Comment