how to convert percent to pip

Created at 02 May 2023, 19:59
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!
IR

IRCtrader

Joined 17.06.2021

how to convert percent to pip
02 May 2023, 19:59


i want this bot modify my all position by percent for take profit and stoploss

first now it run every tick i want just modify for my last position beofre running bot and new position after running bot

i dont know how to convert percent to pip 

using System;
using System.Linq;
using cAlgo.API;


namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWCPStep : Robot
    {


        [Parameter("Take Profit Percent", DefaultValue = 3.1)]
        public double tpPercent { get; set; }
        [Parameter("Stop Loss Profit Percent", DefaultValue = 3.1)]
        public double slPercent { get; set; }

        [Parameter("Modify TP ", DefaultValue = true)]
        public bool tpOptiion { get; set; }

        [Parameter("Modify Sl ", DefaultValue = true)]
        public bool slOptiion { get; set; }


        protected override void OnStart()
        {

        }

        protected override void OnTick()
        {



            //calc STEP Percent Profit

            double StepPercent = ((Account.Equity / Account.Balance) - 1) * 100;


            foreach (var position in Positions)
            {
                double tpcalc = Symbol.PipValue * position.Quantity / Account.Balance;
                double slcalc = Symbol.PipValue * position.Quantity / Account.Balance;

                if (tpOptiion)
                {
                    var tp = position.EntryPrice + 10 * Symbol.PipSize;
                    ModifyPosition(position, position.StopLoss, tp);
                }
                if (slOptiion)
                {
                    var sl = position.EntryPrice + 10 * Symbol.PipSize;
                    ModifyPosition(position, sl, position.TakeProfit);
                }
                if (slOptiion && tpOptiion)
                {
                    var tp = position.EntryPrice + 10 * Symbol.PipSize;
                    var sl = position.EntryPrice + 10 * Symbol.PipSize;
                    ModifyPosition(position, sl, tp);
                }



            }


        }

    }


}

 


cTrader Automate
@IRCtrader
Replies

IRCtrader
08 May 2023, 18:18

RE:

percent of profit or stoploss

Netprofit exactly 

PanagiotisChar said:

Hi there,

Percent of what exactly?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 


@IRCtrader

PanagiotisChar
09 May 2023, 08:43

Hi there,

You need to use the Symbol.PipValue and multiply it by the position's volume to find out how much your net profit changes for each pip move. Then based on the net amount you want to risk, you need to calculate the relevant amount of pips.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

IRCtrader
17 May 2023, 18:49

RE:

thanks. it works.

i have a problem with pip.value

it sometimes return 0.

i check it in different broker and i see this more in roboforex. they could do that or it is a bug?

to fix that i have to change account in other broker and return to my main account to works.

i use this formual in aw manager(percent). 

PanagiotisChar said:

Hi there,

You need to use the Symbol.PipValue and multiply it by the position's volume to find out how much your net profit changes for each pip move. Then based on the net amount you want to risk, you need to calculate the relevant amount of pips.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 


@IRCtrader