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!
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
NinjaTrader
Simple Total FootPrint Bid x Ask
Collapse
X
-
Originally posted by NinjaTrader_Cal View PostKetron82,
The screenshot you sent shows compile errors but not for the indicator in question. The errors are actually point towards another indicator called ASKBIDPRICE.CS
I would open that file and compile that code.Code:protected override void OnMarketData(MarketDataEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Last) Print("Last = " + e.Price + " " + e.Volume); else if (e.MarketDataType == MarketDataType.Ask) Print("Ask = " + e.Price + " " + e.Volume); else if (e.MarketDataType == MarketDataType.Bid) Print("Bid = " + e.Price + " " + e.Volume); }
in C++ I have a main program and the subfunction and I recall subfunction from the main......in c# for ninja should be the same...or not?
Comment
-
I think that I made conceptual error becuase I simply follow the WIZARD and at the end I click GENERATE but I get error. Could I have some settings wrong in NinjaCompiler?
I post all my simply step:
1) http://clip2net.com/s/5V9KFp
2) http://clip2net.com/s/5V9M4H
3) http://clip2net.com/s/5V9Obd
4) http://clip2net.com/s/5V9RTM
5) http://clip2net.com/s/5V9SOu
6) http://clip2net.com/s/5V9Yug
P.s. If I solve It....like I do in C++ or MQL....I will add the funcrtion OnMarketData() with only a print command (for begin) to put some value in the OutputWindow.
Many Many thanks and sorry for my elementary englishLast edited by ketron82; 10-09-2013, 08:55 AM.
Comment
-
The compiling problem was that Ninja compile all the file not compilet yet. With NinjaTrader_Cal that helped me...I removed the other incomplete indicator and the problem has disappeared.
Many thanks again to NinjaTrader_Cal
Now....I will continue experiment and I will post news on this threadLast edited by ketron82; 10-09-2013, 02:52 PM.
Comment
-
Well...I started test
For now....I would simply cumulate ask volume and bid vol.
I simply have to compare last price with ask or bid price...and so:
if Last Price==Ask Price --> Volume of last price is ASK
if Last Price==Bid Price --> Volume of last price is BID
and I made this code that working but have some problem yet.
Code:#region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { /// <summary> /// Enter the description of your new custom indicator here /// </summary> [Description("Enter the description of your new custom indicator here")] public class TEST : Indicator { #region Variables // Wizard generated variables // User defined variables (add any user defined variables below) public DataSeries price; public DataSeries volume; public long volask; public long volbid; public long vol; public double prezzo; public int count; #endregion /// <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 = false; double[] price; int[] volume; volask=0; volbid=0; prezzo=0; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. } protected override void OnMarketData(MarketDataEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Last) { Print("Last = " + e.Price + " " + e.Volume /*+ "// current ask = "+ GetCurrentAsk() + " current bid = "+ GetCurrentBid()*/); prezzo=e.Price; vol=e.Volume; // if(prezzo==GetCurrentAsk()) // {volask=e.Volume+volask; // Print(" ###### ASK ######## " + prezzo + " " + volask); // } // if(prezzo==GetCurrentBid()) // {volbid=e.Volume+volbid; // Print(" ###### BID ######## " + prezzo + " " + volbid); // } } else if (e.MarketDataType == MarketDataType.Ask) //Print("Ask = " + e.Price + " " + e.Volume); { if(prezzo==e.Price && vol!=0) { volask=volask+vol; Print(" ###### ASK ######## Prezzo Last= " + prezzo + " ## Prezzo Ask " + e.Price + " ## Volume ASK= " + volask); vol=0; } } else if (e.MarketDataType == MarketDataType.Bid) //Print("Bid = " + e.Price + " " + e.Volume); { if(prezzo==e.Price && vol!=0) { volbid=volbid+vol; Print(" ###### BID ######## Prezzo Last= " + prezzo + " ## Prezzo Bid " + e.Price + " ## Volume BID= " + volbid); vol=0; } } } #region Properties #endregion } } #region NinjaScript generated code. Neither change nor remove. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { public partial class Indicator : IndicatorBase { private TEST[] cacheTEST = null; private static TEST checkTEST = new TEST(); /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public TEST TEST() { return TEST(Input); } /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public TEST TEST(Data.IDataSeries input) { if (cacheTEST != null) for (int idx = 0; idx < cacheTEST.Length; idx++) if (cacheTEST[idx].EqualsInput(input)) return cacheTEST[idx]; lock (checkTEST) { if (cacheTEST != null) for (int idx = 0; idx < cacheTEST.Length; idx++) if (cacheTEST[idx].EqualsInput(input)) return cacheTEST[idx]; TEST indicator = new TEST(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; Indicators.Add(indicator); indicator.SetUp(); TEST[] tmp = new TEST[cacheTEST == null ? 1 : cacheTEST.Length + 1]; if (cacheTEST != null) cacheTEST.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheTEST = tmp; return indicator; } } } } // This namespace holds all market analyzer column definitions and is required. Do not change it. namespace NinjaTrader.MarketAnalyzer { public partial class Column : ColumnBase { /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.TEST TEST() { return _indicator.TEST(Input); } /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public Indicator.TEST TEST(Data.IDataSeries input) { return _indicator.TEST(input); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.TEST TEST() { return _indicator.TEST(Input); } /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public Indicator.TEST TEST(Data.IDataSeries input) { if (InInitialize && input == null) throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method"); return _indicator.TEST(input); } } } #endregion
Can someone help me to modify the code?
P.s. Next step after have solved this problem is to make experiment with array (dataseries) to start a structure to archive footprint in row and column.
TNX to ALLLast edited by ketron82; 10-10-2013, 06:13 AM.
Comment
-
I made other tests but I cannot solve this problem....with this simple function, in the Output Windows I sometime read that "last price" is not equal at askprice or bid price....and this is strange.
Any ideas?
Code:protected override void OnMarketData(MarketDataEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Last) { //Print("### Last = " + e.Price + " " + e.Volume + " Bid Price= " + GetCurrentBid() + " Ask Price= " + GetCurrentAsk()); } // else if (e.MarketDataType == MarketDataType.Ask) // { // Print("Ask = " + e.Price + " " + e.Volume); // // } // else if (e.MarketDataType == MarketDataType.Bid) // { // Print("Bid = " + e.Price + " " + e.Volume); // // } //Print("Posizione = " + vol + "\n\n"); }
Last edited by ketron82; 10-10-2013, 01:14 PM.
Comment
-
This is the screenshot where I compare MarketDelta (iqfeed) and Ninja (iqfeed).
I think that there is some problem using getcurrentask() or getcurrentbid() in onmarketdata() function....I make a conceptual error but I haven't found a correct logical working of onmarketdata()
How is a best way to use onmarketdata() ?
I made other test without getcurrentask and getcurrentbid but using
else if (e.MarketDataType == MarketDataType.Ask)
but something go wrong however.
Any ideas?
Comment
-
Ketron82,
OnMarketData() is a method used to call with ask, bid, last prices in that nature.
When a tick comes in this method will get called and calculate any actions that you have in the method.
As such, you can have the OnMarketData() draw an arrow when a particular data comes in, like a bid price.
Example -
Code:protected override OnMarketData(MarketDataEventArgs e) { if (e.MarketDataType == MarketDataType.Bid) { //Draw Object here } }
Cal H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by techgetgame, Today, 11:42 PM
|
0 responses
1 view
0 likes
|
Last Post
by techgetgame
Today, 11:42 PM
|
||
Started by sephichapdson, Today, 11:36 PM
|
0 responses
1 view
0 likes
|
Last Post Today, 11:36 PM | ||
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,612 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
Comment