Co-Opted Color & Text with: !From Broker To Strategy MP Sync

Questions about MultiCharts and user contributed studies.
escamillo
Posts: 203
Joined: 25 Mar 2011
Has thanked: 23 times
Been thanked: 56 times

Co-Opted Color & Text with: !From Broker To Strategy MP Sync

Postby escamillo » 01 May 2012

As seen in the attached screenshot, when right-clicking on the text from the Strat
!From Broker To Strategy MP Synchronizer!
the next closest Strat to it in the active Strat list comes up as the one to be opened or edited, not !From Broker To Strategy MP Synchronizer!

Also, text color in !From Broker To Strategy MP Synchronizer! takes on whatever color the text is in the Strat closest to it.

And, some text in a Strat that normally shows up when NOT using !From Broker To Strategy MP Synchronizer!, will not show up when !From Broker To Strategy MP Synchronizer! is used (it is always the first text object of the nearby Strat).

I can fix the color issue, but !From Broker To Strategy MP Synchronizer! still co-opts the first text object in a nearby Strat so that it does not work.

Not a huge deal, but I would like an explanation as to:
1). why when you right click on the text another Strat comes up; and,
2). how to make it so that text in the near Strat is not eliminated when !From Broker To Strategy MP Synchronizer! is used.
Attachments
!From Broker --- Issues.png
(89.56 KiB) Downloaded 261 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Co-Opted Color & Text with: !From Broker To Strategy MP

Postby Henry MultiСharts » 02 May 2012

Can it be reproduced easily using your workspace? I have not reproduced it on our end.
Please send me your workspace and all studies you are using in it (Power Language editor->File->Export->export with dependent functions) at support@multicharts.com with exact steps on how to reproduce this behavior or come to our live chat Monday-Friday 6:30 am - 4 pm EST to demonstrate the issue.

Please tell me what version of MultiCharts are you using (go to Help -> About MultiCharts and tell me exact version and build number).

escamillo
Posts: 203
Joined: 25 Mar 2011
Has thanked: 23 times
Been thanked: 56 times

Re: Co-Opted Color & Text with: !From Broker To Strategy MP

Postby escamillo » 02 May 2012

Issue seen and fixed by Henry and crew. Version of
!From Broker To Strategy MP Synchronizer!
created/fixed by MC that will NOT co-opt text in other Strats is here:

Code: Select all

[intrabarordergeneration = true];

DEFINEDLLFUNC: "kernel32.dll", int, "GetTickCount";

// Existing issues - inaccurately sync order's prices:
// 1) entry prices - only in pyramiding mode
// 2) exit prices - always (used close price as close position price)

Input :
TimeOutMS(250), // time spent since BrokerMarketPosition changed and we start correct position
LatencyMS(500); // time spent since we start correct StrategyMarketPosition and return to monitoring mode

variables:
textID( 0 ),
intrabarpersist sync_state("MP is synchronized!"),
intrabarpersist diff_state("MP syncronization. Wait "),

_rightest(0),
_highest(0),

inner_mp(0),
broker_mp(0),

intrabarpersist mp_diff(false),
intrabarpersist mp_diff_time_start(0),

intrabarpersist mp_corrected(false),
intrabarpersist mp_corrected_time_start(0),

intrabarpersist place_correction_marketorder(false),

intrabarpersist _get_tick_count(0),
intrabarpersist _exit_price(0),

correct_contracts(0),
is_buy(false),
is_entry(true);

if getappinfo(airealtimecalc) = 1 and getappinfo(aistrategyauto) = 1 then begin

if textID = 0 then textID = text_new_s(d, time_s, c,"CurrentState");

once begin
print( text_setstyle(textID, 1, 0) );
diff_state += text(TimeOutMS*.001, " seconds.");
end;

inner_mp = currentcontracts*marketposition;
broker_mp = MarketPosition_at_Broker;

_rightest = getappinfo(airightdispdatetime);
_highest = getappinfo(aihighestdispvalue);

text_setlocation_s(
textID,
juliantodate(_rightest),
datetime2eltime_s(_rightest),
_highest
);

if broker_mp <> inner_mp then begin


_get_tick_count = GetTickCount ;

// market position differs state
if not mp_diff and not mp_corrected then begin
mp_diff = true;
mp_diff_time_start = _get_tick_count ;
text_setstring(textID, diff_state);
end;

// enter correction state after TimeOut
if mp_diff and not mp_corrected then begin
_exit_price = c; // assume that position can closed at close price
if _get_tick_count - mp_diff_time_start > TimeOutMS then begin
place_correction_marketorder = true ;
mp_corrected = true ;
mp_corrected_time_start = _get_tick_count ;
end;
end;

// correction state
if mp_corrected then begin
if _get_tick_count - mp_corrected_time_start > LatencyMS then begin
mp_corrected_time_start = _get_tick_count ;
mp_diff = false;
mp_corrected = false;
end;
end;

// place correction order
if place_correction_marketorder then begin
place_correction_marketorder = false ;
if 0 <> broker_mp then _exit_price = AvgEntryPrice_at_Broker;
ChangeMarketPosition(broker_mp - inner_mp, _exit_price, "Sync Order");
end;

end
else begin
text_setstring(textID, sync_state);
mp_corrected = false ;
mp_diff = false;
end;

end; // is real time and strategy auto


Return to “MultiCharts”