Symbol.Ask & Symbol.Bid Values for BackTesting Timeframe

Created at 24 Aug 2014, 16:06
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CL

clark

Joined 24.08.2014

Symbol.Ask & Symbol.Bid Values for BackTesting Timeframe
24 Aug 2014, 16:06


I've written the code below which I've used for my cbot successfully in backtesting on the 1 minute timeframe.

I want the code to work the same way when I use it on the live chart so I need to know how to write the code to get the Symbol.Bid value for the 1 minute timeframe otherwise the code will work differently on the live chart and return the Symbol.Bid value for each tick.

I've looked through the forum but can't find the answer so would appreciate assistance with this.

if (position != null && position.TradeType == TradeType.Buy)
           {
                foreach (var order in PendingOrders)
                {
                    CancelPendingOrder(order);
                }
                if (MACDValue < 0)
                {
                    Close(TradeType.Buy);
                }
                else if (Symbol.Bid > position.EntryPrice)
                {
                    ModifyPosition(position, Symbol.Bid - (TrailingStop * Symbol.PipSize), position.TakeProfit);
                }
                else if (BuyTrailingStop > position.EntryPrice)
                {
                    ModifyPosition(position, BuyTrailingStop, position.TakeProfit);
                }
            }


@clark
Replies

modarkat
25 Aug 2014, 10:15

Here you go:

            var m1Series = MarketData.GetSeries(TimeFrame.Minute);
            var m1Bid = m1Series.Close.Last(0);

 


@modarkat

clark
27 Aug 2014, 16:05

RE:

modarkat said:

Here you go:

            var m1Series = MarketData.GetSeries(TimeFrame.Minute);
            var m1Bid = m1Series.Close.Last(0);

 

It worked - Thank you modarkat!! 


@clark