trade closed in the same bar .. was it long or short?

Questions about MultiCharts and user contributed studies.
shivax
Posts: 90
Joined: 02 Sep 2013
Has thanked: 37 times

trade closed in the same bar .. was it long or short?

Postby shivax » 08 May 2018

Immagine1.png
(1.19 KiB) Downloaded 770 times
i want to know if this trade was long trade or short trade


Use Marketposition is not corret because it returns the value zero

How can i code it?(i don't use intrabar generation)

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: trade closed in the same bar .. was it long or short?

Postby ABC » 09 May 2018

shivax,

take a look at the strategy position trades keywords:
https://www.multicharts.com/trading-sof ... ion_Trades

PosTradeIsLong could for example tell you if a trade was long or short.

Regards,

ABC

shivax
Posts: 90
Joined: 02 Sep 2013
Has thanked: 37 times

Re: trade closed in the same bar .. was it long or short?

Postby shivax » 09 May 2018

PosTradeIsLong(PosAgo, TradeNumber
Tradenumber what is ? I dont understand

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: trade closed in the same bar .. was it long or short?

Postby ABC » 09 May 2018

shivax,,

TradeNumber is the (zero based) number of individual entries into the position for the specific trade and you can use PosTradeCount to retrieve it.
If you don't scale in and out of trades, it should always be 0.

Regards,

ABC

shivax
Posts: 90
Joined: 02 Sep 2013
Has thanked: 37 times

Re: trade closed in the same bar .. was it long or short?

Postby shivax » 09 May 2018

are you sure PosTradeislong run correctly?

i try this example :

Code: Select all

....
if Time=1000 then sellshort next bar at open;

print(Date,time," ",PosTradeislong(0,1));
i see all print =True

https://gyazo.com/6da22860acd84ee78125b0597a4ff603

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: trade closed in the same bar .. was it long or short?

Postby ABC » 09 May 2018

shivax,

what is your rational for setting TradeNumber to 1?

Regards,

ABC

are you sure PosTradeislong run correctly?

i try this example :

Code: Select all

....
if Time=1000 then sellshort next bar at open;

print(Date,time," ",PosTradeislong(0,1));
i see all print =True

https://gyazo.com/6da22860acd84ee78125b0597a4ff603

User avatar
signalworks
Posts: 65
Joined: 06 Oct 2013
Location: Germany.Solingen
Has thanked: 23 times
Been thanked: 2 times
Contact:

Re: trade closed in the same bar .. was it long or short?

Postby signalworks » 31 May 2018

shivax,

Another possibility: if you name your entries that way:

Code: Select all

buy ("PosName_Long") ...
sell short ("PosName_Short")...
then you can use

Code: Select all

PosTradeEntryName(PosAgo,TradeNumber)

Where: PosAgo - a numerical expression, specifying the position:

0 - open position;

1 - one position back (the last position closed);

2 - two positions back, etc.

TradeNumber - a numerical expression, specifying the number of trade (zero-based).
to determine the name of the last closed trade. Hope this helps.
regards.


Return to “MultiCharts”