how to add a value in pips in coding

Created at 07 Sep 2022, 06:33
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!
MO

moiz.forex

Joined 05.09.2022

how to add a value in pips in coding
07 Sep 2022, 06:33


Hi community Can anyone help me in this. I am working on a sample bot and here i am stuck at a point. I am new in botting thing and mostly know nothing so i am experimenting for a strategy here

I want that only buy or sell position if the Price is 20 30 40 pips more or less of the reference price.

                    TradeParameterCalculations("Short","Any");
                    var ordstop = PlaceStopOrder(TradeType.Sell, SymbolName, _lots, Bars.LowPrices.Last(1), _shortlabel, _sl, _tp);

 

 

Now after the Low prices. what bot is doing its actually selling a trade at the previous candle low where as i want to set command that sell 20 pips more lower than the low price of last candle and same in the case of buy positions where i want to buy 20 pips more than the high price..

 

Please help


@moiz.forex
Replies

PanagiotisCharalampous
07 Sep 2022, 08:32

Hi,

You can try something like this

PlaceStopOrder(TradeType.Sell, SymbolName, _lots, Bars.LowPrices.Last(1) - (Symbol.PipSize * 20), _shortlabel, _sl, _tp);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

moiz.forex
07 Sep 2022, 17:02

RE:

PanagiotisCharalampous said:

Hi,

You can try something like this

PlaceStopOrder(TradeType.Sell, SymbolName, _lots, Bars.LowPrices.Last(1) - (Symbol.PipSize * 20), _shortlabel, _sl, _tp);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Ok so what you added after Last(1) -(Symbol.PipSize *20), the minus or the dash size gives command of less 20 pips and then at the buy side we will do + (Symbol.PipSize*20),

 

and if i want to change how many pips up and down i want all i can do is to change the 20 number is that rite?


@moiz.forex

PanagiotisCharalampous
08 Sep 2022, 08:29

Hi moiz.forex,

Yes that is correct

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous