Since I'm not a programmer I've been trying to Cut and Paste lines of codes references from help guide but I'm struggling here
Following is the main code that I'm writing, using GetcurrentBid() and GetcurrentAsk(), but I see they don't work for historical data, if anybody has a solution to this please let me know, it'll be highly appreciated.
public class Midpoint : Indicator
{
#region Variables
private DataSeries myDataSeries;
// Wizard generated variables
// User defined variables (add any user defined variables below)
#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()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Mpoint"));
CalculateOnBarClose = false;
Overlay = true;
myDataSeries = new DataSeries(this); // this refers to the indicator/strategy itself
// and syncs the DataSeries object to historical
// data bars
}
/// <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.
// Calculate the range of the current bar and set the value
myDataSeries.Set((GetCurrentBid() + GetCurrentAsk())/2);
Mpoint.Set(myDataSeries[0]);
Print("Bid: " + GetCurrentBid(0).ToString() + " Ask: " + GetCurrentAsk(0).ToString() + " Avg: " + ((GetCurrentBid() + GetCurrentAsk()) / 2).ToString());
}
Comment