I have the code below, that produces different prints for the CurrentBar index than the second code for the bars index in OnEachTickCalculation. Also, the last bar has an index number plus one when compared with the data box (i.s the Data Box shows last bar index of 6382, while the Output window print shows 6383).
I expected the blue and red highlighted prints would show identical bar number, but the CurrentBar index looks like it counts the actual ticks or something...
Thank you
if(longOrderId.Length == 0 && longAtmId.Length == 0) { if (longCondPrice > open && !isLongAtmStrategyCreated) { longOrderId = GetAtmStrategyUniqueId(); longAtmId = GetAtmStrategyUniqueId(); AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit, currentAsk + offsetLimitStop * TickSize, currentAsk + offsetLimitStop * TickSize, TimeInForce.Day, longOrderId, "3C", longAtmId, (atmCallbackErrorCode, atmCallBackId) => { //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == longAtmId) isLongAtmStrategyCreated = true; barNumberOfLongOrder = CurrentBar; triggerPriceLong = GetCurrentAsk(0); Print("Long ATM triggered at: " + Convert.ToString(triggerPriceLong) + " - Bar #" + barIndex + " open price is " + open + " - Current Bar: " + CurrentBar + " - " + Time[0]); Print("##########"); });
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { base.OnRender(chartControl, chartScale); // loop through only the rendered bars on the chart for(barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++) { ; // get the open price at the selected bar index value open = Bars.GetOpen(CurrentBar); Print("Bar #" + barIndex + " open price is " + open); } }
Long ATM cancel cond 2 price: 56.19 - Bar #6383 open price is 56.19 - Current Bar: 1289690 - 25/10/2019 13:31:42
>>> Long Order ID Reset Price: 56.19 - Bar #6383 open price is 56.19 - Current Bar: 1289691 - 25/10/2019 13:31:42
>>## Long ATM ID Reset Price: 56.19 - Bar #6383 open price is 56.19 - Current Bar: 1289692 - 25/10/2019 13:31:42
----------
Short condition at: 56.15 - Bar #6383 open price is 56.16 - Current Bar: 1289746 @ 25/10/2019 13:31:48
R = 1 - Current Bid: 56.15 - Bar #6383 open price is 56.16 - Current Bar: 1289746 - 25/10/2019 13:31:48
Short ATM triggered at: 56.15 - Bar #6383 open price is 56.16 - Current Bar: 1289746 - 25/10/2019 13:31:48
##########
++++++++++
Long condition at: 56.15Bar #6384 open price is 56.14 - Current Bar: 1289940 @ 25/10/2019 13:32:02
S = 1 - Current Ask: 56.15 - Bar #6384 open price is 56.14 - Current Bar: 1289940 - 25/10/2019 13:32:02
Long ATM triggered at: 56.15 - Bar #6384 open price is 56.14 - Current Bar: 1289940 - 25/10/2019 13:32:02
Comment