how to get price at broker?

Questions about MultiCharts and user contributed studies.
turbofib
Posts: 234
Joined: May 11 2013
Has thanked: 77 times
Been thanked: 7 times

Aug 03 2024

hi, i code this
mp=marketposition;

if mp<>mp[1] and mp<>0 then begin
print(date,time," ",entryprice," ",avgEntryPrice_at_Broker);
end;

1240626.00 900.00 5522.50 0.00
1240626.001115.00 5539.75 0.00
1240627.001330.00 5535.00 0.00
1240627.001415.00 5537.25 0.00
1240717.00 900.00 5661.75 0.00
1240722.001000.00 5607.00 0.00
1240726.00 945.00 5491.75 0.00


i see entryprice but i don't see avgEntryPrice_at_Broker
i've abilitate autotrading in AA mode and i'm connect to broker
Immagine.png
(11.67 KiB) Not downloaded yet
Attachments
Immagine_2.png
(29.82 KiB) Not downloaded yet

PeterSt
Posts: 33
Joined: Jun 18 2024
Has thanked: 5 times
Been thanked: 11 times

Aug 04 2024

I think you are too fast with obtaining the price from the Broker; you should or synchronize first, or wait for x milliseconds until the order has been processed by the broker and all.

Querying MarketPositionAtBroker also does wonders. Thus if that is still 0 then there is no Price yet either.

Regards,
Peter

turbofib
Posts: 234
Joined: May 11 2013
Has thanked: 77 times
Been thanked: 7 times

Aug 04 2024

ok if i want to get price in realtime i use MarketPositionAtBroker
but if i want to get price filled in position tracker (see pics)
how can i do?
The prices are already present and I want to print these at the end of the session
Image
Attachments
Immagine.png
(15.33 KiB) Not downloaded yet

PeterSt
Posts: 33
Joined: Jun 18 2024
Has thanked: 5 times
Been thanked: 11 times

Aug 04 2024

I want to print these at the end of the session
I think I understand, but still this is a bit vague to me. I think that your "problem" merely is to print them at all, which is a matter of doing it the correct way;
I am not of the type who asks "why do you want to use AA in the first place ?" but it is about that. So this is your choice - now behave accordingly. In my experience this is not easy at all.

So really, start out with being able to print them as per your first post and when that works go to the next step.
My idea : Literally Print them/it might not be the way to go. Obtain it in some log file could be the better thought;
Here I must pass for the general MC version, but for the .Net version I myself would face some challenges just the same (just no experience with it). Initialize a new Log File Name per session (per Backtest "session" / per Live session) comes to mind. Decently add to it, while knowing you can't close it at each new record added (too much time consuming ?). Thus no FileStreamWriter (.Net) but something which appends all the time. People in here will know ...

Why do this in AA mode ? :wink: (just interested)

turbofib
Posts: 234
Joined: May 11 2013
Has thanked: 77 times
Been thanked: 7 times

Aug 07 2024

because it is easier to manage multiple systems simultaneously on the same instrument