Replies

c.ostmo
06 Apr 2017, 15:51

RE:

I keep getting this error: Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object. My question for reference: /forum/cbot-support/11446

Am I missing something? My code is similar to yours and I even replaced it, but I'm getting the same error. What commonly causes this?

 

Spotware said:

Dear Trader,

An open position doesn’t have a closing time therefore we do not provide ClosingTime. Once the position is closed it will be removed from the Positions list. In the History tab it is available because it shows the time that a position was closed. The following code snippet shows how to retrieve the closing time of a closed position, which is considered a historical trade:

            ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "mylabel");

            ClosePosition(Positions.Find("mylabel"));

            HistoricalTrade hist = History.FindLast("mylabel");

            Print("Position closed at: ", hist.ClosingTime.ToString());

We hope this helps you.

 


@c.ostmo

c.ostmo
06 Apr 2017, 14:46

I know I have no idea what I'm doing. I needed something like this:

                HistoricalTrade lastSell = History.FindLast("Sell");
                Print(lastSell.ClosingTime);

However, is there anyway to get the closing date? Will "ClosingTime" return the date, or just the time of day?

Also, this produces an error: "Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object." What am I missing? (If you could talk to me like I have no idea what I'm doing, I would appreciate it)


@c.ostmo

c.ostmo
06 Apr 2017, 14:23

RE:

Just to be clear, trades are definitely being take, and that line is printed after each one. None of them in the log have any date for the last trade.


@c.ostmo

c.ostmo
06 Apr 2017, 10:19

So much of this was exactly what I needed, especially Symbol.Ask and Symbol.Bid. Thanks a ton Lucian.


@c.ostmo

c.ostmo
05 Apr 2017, 22:01

RE: RE: RE: RE: RE:

Apolopgies, I think this is how you do it: /forum/whats-new/1463


@c.ostmo

c.ostmo
05 Apr 2017, 21:54

RE: RE: RE: RE:

I still don't understand this part. How can I get the high and low of the previous day and not just the previous candle? I want the previous day high and low while trading on the minute charts.

 

hiba7rain said:

Thanks Spotware, 

gut i dont know why am getting the values of all last bars and not only the high and low of previous day ??

Spotware said:

Use MarketSeries. Method Last Access a value in the dataseries certain bars ago.

 

    var previouseDayHigh = MarketSeries.High.Last(1);
    var previouseDayLow = MarketSeries.Low.Last(1);

hiba7rain said:

 :) any suggestions 

hiba7rain said:

Hi All, 

am looking for your support, how can i get the higher high and lower low price for previous day?

Thanks 

 

 

 

 


@c.ostmo