Pivot Points calculation for bot

Created at 22 Aug 2017, 23:40
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!
DelFonseca's avatar

DelFonseca

Joined 25.06.2017

Pivot Points calculation for bot
22 Aug 2017, 23:40


Hi,

I am creating a bot for pivot points, calculations are correct, but something is not working correctly because in backtest (timeframe: D1) it gives different takeprofit values.

Follow the code:
 

private void ExecuteStrategy()
{
    var Daily = MarketData.GetSeries(TimeFrame.Daily);
    var High = Daily.High.Last(1);
    var Low = Daily.Low.Last(1);
    var Close = Daily.Close.Last(1);

    var Price = (Symbol.Ask + Symbol.Bid) / 2;

    var Pivot = (High + Low + Close) / 3;
    var R1 = 2 * Pivot - Low;
    var S1 = 2 * Pivot - High;

    var TakeProfifBuy = R1;
    var StopLossBuy = TakeProfifBuy / StopLossFactor;

    var TakeProfifSell = S1;
    var StopLossSell = TakeProfifSell / StopLossFactor;

    if (Price > Pivot)
       {
       ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInLots, Label, StopLossBuy, TakeProfifBuy);
       }
    if (Pivot > Price)
       {
       ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInLots, Label, StopLossSell, TakeProfifSell);
       }
}
On August 15, 2017 we do the calculations on the 14th:
> High: 109,798
> Low: 109,048
> Close: 109,653

> Pivot: 109,500
> R1: 109,951
> S1: 109,201

Why give me take profit on 111,756 instead 109,500?

Any Help ?
Thank you


@DelFonseca
Replies

Spotware
23 Aug 2017, 09:40

Dear deltrader.pt@gmail.com,

It seems that your take profit/stop loss parameters are passed as absolute prices rather than in pips. Can you please check this?

Best Regards,

cTrader Team


@Spotware

DelFonseca
24 Aug 2017, 22:48

RE:

Spotware said:

Dear deltrader.pt@gmail.com,

It seems that your take profit/stop loss parameters are passed as absolute prices rather than in pips. Can you please check this?

Best Regards,

cTrader Team

 

Hello, Actually my stoploss / takeprofit is calculated as price but in the default calgo is in pips. Is it possible put stoploss / takeprofit as a price and not as pips? If so, can you help me? I have already done a search without success. thank you so much.


@DelFonseca

Spotware
25 Aug 2017, 10:24

Dear deltrader.pt@gmail.com,

Currently ExecuteMarketOrder() takes stop loss and take profit only in pips.

Best Regards,

cTrader Team 


@Spotware