print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Questions about MultiCharts and user contributed studies.
kiyi0317
Posts: 40
Joined: 13 Apr 2016
Has thanked: 17 times
Been thanked: 1 time

print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby kiyi0317 » 06 Feb 2017

dear MC support,

when I check and print out PosTradeProfit(1,0) / PosTradeExitPrice(1,0) / PosTradeEntryPrice(1,0)....all are zero. anything I am doing incorrectly?

brgds
YT

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby Angelina MultiСharts » 06 Feb 2017

Hello kiyi0317,

I've tried running the following script with 1 Day MSFT Free Quotes chart:

Code: Select all

once cleardebug;

if currentbar = 1 then buy next bar at market;

if currentbar = 5 then sell next bar at market;

if PosTradeCount(1) >= 1 then
print( PosTradeProfit(1,0), " ", PosTradeExitPrice(1,0), " ", PosTradeEntryPrice(1,0));
Output shows non-zero values - please see the screenshot attached.

Can you please describe your setup in more details?
Attachments
PosTradeProfit.PNG
(115.62 KiB) Downloaded 953 times

kiyi0317
Posts: 40
Joined: 13 Apr 2016
Has thanked: 17 times
Been thanked: 1 time

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby kiyi0317 » 06 Feb 2017

hi Angelina,

Code: Select all

print(date,time,close of data1,postradeprofit(1,0),postradeprofit(2,0));
The signal can being work perfectly. and then I added above code at the end of signal, but it just printing out zero as below screen cap. I could not found where is the mistake, pls adv.

range bar has being used and [SameExitFromOneEntryOnce = False];
any more details needed?

thanks
Attachments
ScreenHunter_391 Feb. 07 09.16.jpg
(57.5 KiB) Downloaded 944 times

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby Angelina MultiСharts » 07 Feb 2017

PLease replace your print statement with this one:

Code: Select all

Print(datetimetostring(datetime), " Completed trades: ", totaltrades, " Open entries:", CurrentEntries);

if PosTradeCount(1) >= 1 then
Print("BGP=", bigpointvalue:10:5, " TP=",PosTradeProfit(1,0):10:5, PosTradeEntryPrice(1,0):10:5, PosTradeExitPrice(1,0):10:5);
After that please run your signal and attach a screenshot of the output log.

kiyi0317
Posts: 40
Joined: 13 Apr 2016
Has thanked: 17 times
Been thanked: 1 time

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby kiyi0317 » 08 Feb 2017

Angelina, thank you

see below screen cap, the first picture seems workable. but once I closed the MC and re-start the MC, the history record was gone. (see the second one)

is it all right on picture one?
how can I get the postradeprofit(1,0) when I open the MC every morning?
Attachments
ScreenHunter_395 Feb. 08 16.19.jpg
(78.17 KiB) Downloaded 924 times
ScreenHunter_396 Feb. 08 16.24.jpg
(57.88 KiB) Downloaded 924 times

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby Angelina MultiСharts » 08 Feb 2017

kiyi0317,

In second case, as you can see there are no completed trades, so no Profit, Exit/Entry Prices to print out.

kiyi0317
Posts: 40
Joined: 13 Apr 2016
Has thanked: 17 times
Been thanked: 1 time

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby kiyi0317 » 08 Feb 2017

sorry, it does not make sense to me. Postradeprofit(1,0) is looking for the latest closed. why it was disappear when I close the MC and re-start? is it any problem with my script?

kiyi0317
Posts: 40
Joined: 13 Apr 2016
Has thanked: 17 times
Been thanked: 1 time

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby kiyi0317 » 09 Feb 2017

sorry, it does not make sense to me. Postradeprofit(1,0) is looking for the latest closed. why it was disappear when I close the MC and re-start? is it any problem with my script?
dear all,
any one can have some comments?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby JoshM » 10 Feb 2017

sorry, it does not make sense to me. Postradeprofit(1,0) is looking for the latest closed. why it was disappear when I close the MC and re-start? is it any problem with my script?
dear all,
any one can have some comments?
There may not be enough information in this thread to give a decisive answer:

- If you're doing a backtest on historical data and there is more than one closed position, then `PosTradeProfit(1, 0)` should return a value.

- If you're auto trading on real time data with auto trading just turned on, it's quite likely that `PosTradeProfit(1, 0)` returns 0 even though you did trades in the past. That's because the MultiCharts strategy typically assumes everything is flat, and so when it just starts trading it will not take previous positions (as well as previous orders and pending orders) into consideration. So with that case it makes sense that `PosTradeProfit(1, 0)` returns 0 too. Because as far as the strategy is concerned, there were no previous positions.

kiyi0317
Posts: 40
Joined: 13 Apr 2016
Has thanked: 17 times
Been thanked: 1 time

Re: print out PosTradeProfit / PosTradeExitPrice / PosTradeEntryPrice....all are zero.

Postby kiyi0317 » 10 Feb 2017

hi Josh,
thanks, I believe that is the answer. Hope that it would be happen in future to consider to have an option for counting the previous trade records.

brgds
Chan


Return to “MultiCharts”