Topics
15 May 2023, 10:05
 417
 3
05 Apr 2023, 01:13
 715
 4
24 Mar 2023, 00:27
 615
 3
01 Feb 2023, 14:39
 688
 9
Replies

Goulk
15 May 2023, 12:03

RE: RE:

firemyst said:

Goulk said:

Hello to all,
I have a question for you, can you create an action that repeats every (X PIP) away ?

Example:

On EURUSD
Every 10 PIPS away from PRICE X, OPEN ONE POSITION.

If possible, I need an example because I am not very practical. 

Thank you for your time
 :D

 

Some sample code to do something every x pips going long:


if (currentPrice >= priceX + (Symbol.PipSize * 10))
{
     //do what you want when you want to be at least 
     //10 pips higher than the last time you entered
}

 

Thanks a lot, I'll try now. :)

@Goulk

Goulk
05 Apr 2023, 10:27

RE:

PanagiotisCharalampous said:

Hi Goulk

Try the following

var trade = PositionLabelID.OrderBy(x => x.EntryTime).First()

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 

Thanks, this works perfectly. :)


@Goulk

Goulk
24 Mar 2023, 09:51

RE:

PanagiotisChar said:

Hi there,

Is it possible to get negative results?  Like -12 -32 -59 ecc...

Yes it is. If your position has negative profit then it will print negative numbers.

How do I get this? can I get it to a specific position?

All positions have a NetProfit property e.g. Positions[0].NetProfit

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Thanks, It was my coding error. :D
Thx For your time.

@Goulk

Goulk
02 Feb 2023, 17:38 ( Updated at: 21 Dec 2023, 09:23 )

RE: RE: RE: RE: RE: RE:

ncel01 said:

Goulk said:

ncel01 said:

Goulk said:

ncel01 said:

Goulk said:

 Hello everyone,
 
 I have a code able to close a group of positions "BUY - SELL" with positive profit.
 Is possibile subtract from the ".netprofit" of this code the expenses of Commisione and swap ?


if (Positions.Count(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == LabelID) > 0)
{
if (Positions.Where(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == LabelID).Average(x => x.NetProfit) >= 0)
foreach (var position in Positions)
{
if (position.TradeType == TradeType.Sell && position.SymbolName == SymbolName && position.Label == LabelID)
ClosePosition(position);
}

Thank you for your time

Hi Goulk,

NetProfit should already reflect all the costs deducted:

NetProfit = GrossProfit - Swaps - Comissions

If so, my backtest results would be the same as 'LIVE'. Unfortunately this is not the case.

When positions are closed in 'LIVE', they have a different closing price than the 'Tick' backtest

 

Hi Goulk,

I am not sure about comissions but swaps are not taken into account when backtesting.

That should explain the difference in case the take profit is set based on a net profit and not on the distance to the entry price. Since the net profit will reduce due to the swaps, the distance to the entry price will need increase accordingly to end up with the same net profit.

Ok thanks ncel01.
This is exactly the problem I have. So, is it possible to add swap in my code? And if so, how?
Thank you for your time.

Hi Goulk,

I don't think it is possible to add it directly but it should be possible to somehow account for it.

What I would do:

I'd code the bot to reduce the distance to TP by the number of pips applied to swaps on a daily basis.

Cons:

Costs associated to the swaps will only be reflected when the positions close.

Some brokers apply a 3-day swap on wednesdays. You can also adjust this programmatically.

Alternatively (easier):

I'd increase the commissions to compensate this. I told you I was not sure about comissions but these are definitely considered when backtesting and can be defined by the user.

Cons: not so accurate.

I hope this helped.

Ncel01,

Thanks for the answers,

At this point, I wonder if it is possible to use the . GrossProfit to make the backtest equal to LIVE.

Is SWAP considered in the .GrossProfit "LIVE" ?

Thank you.


@Goulk

Goulk
02 Feb 2023, 00:55 ( Updated at: 21 Dec 2023, 09:23 )

RE: RE: RE: RE:

ncel01 said:

Goulk said:

ncel01 said:

Goulk said:

 Hello everyone,
 
 I have a code able to close a group of positions "BUY - SELL" with positive profit.
 Is possibile subtract from the ".netprofit" of this code the expenses of Commisione and swap ?


if (Positions.Count(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == LabelID) > 0)
{
if (Positions.Where(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == LabelID).Average(x => x.NetProfit) >= 0)
foreach (var position in Positions)
{
if (position.TradeType == TradeType.Sell && position.SymbolName == SymbolName && position.Label == LabelID)
ClosePosition(position);
}

Thank you for your time

Hi Goulk,

NetProfit should already reflect all the costs deducted:

NetProfit = GrossProfit - Swaps - Comissions

If so, my backtest results would be the same as 'LIVE'. Unfortunately this is not the case.

When positions are closed in 'LIVE', they have a different closing price than the 'Tick' backtest

 

Hi Goulk,

I am not sure about comissions but swaps are not taken into account when backtesting.

That should explain the difference in case the take profit is set based on a net profit and not on the distance to the entry price. Since the net profit will reduce due to the swaps, the distance to the entry price will need increase accordingly to end up with the same net profit.

Ok thanks ncel01.
This is exactly the problem I have. So, is it possible to add swap in my code? And if so, how?
Thank you for your time.

@Goulk

Goulk
01 Feb 2023, 17:19 ( Updated at: 21 Dec 2023, 09:23 )

RE: RE:

ncel01 said:

Goulk said:

 Hello everyone,
 
 I have a code able to close a group of positions "BUY - SELL" with positive profit.
 Is possibile subtract from the ".netprofit" of this code the expenses of Commisione and swap ?


if (Positions.Count(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == LabelID) > 0)
{
if (Positions.Where(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == LabelID).Average(x => x.NetProfit) >= 0)
foreach (var position in Positions)
{
if (position.TradeType == TradeType.Sell && position.SymbolName == SymbolName && position.Label == LabelID)
ClosePosition(position);
}

Thank you for your time

Hi Goulk,

NetProfit should already reflect all the costs deducted:

NetProfit = GrossProfit - Swaps - Comissions

If so, my backtest results would be the same as 'LIVE'. Unfortunately this is not the case.

When positions are closed in 'LIVE', they have a different closing price than the 'Tick' backtest

 


@Goulk