hibrid auto and manual trading.

Questions about MultiCharts and user contributed studies.
florianp3
Posts: 20
Joined: 10 Jun 2014
Has thanked: 4 times

hibrid auto and manual trading.

Postby florianp3 » 24 Apr 2015

I wrote a signal that takes info from the broker on my account equity, market position and avgentryprice then sends a stop order that will close any position if my daily loss limit is reached.
If I use it together with a order generating signal it autotrades just fine.
My wish is to trade discretionary with manual orders and have MC to place daily loss limit stops, but if I place it as a standalone and enable the autotrade, it does not read the info from the broker and consequently does not place my stop.
I tried to use it with !From Broker To Strategy syncronizer to no avail.
What am I doing wrong? Any suggestions?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: hibrid auto and manual trading.

Postby TJ » 24 Apr 2015

::
I tried to use it with !From Broker To Strategy syncronizer to no avail.
What am I doing wrong? Any suggestions?
Please post your code... We can help you to debug.

florianp3
Posts: 20
Joined: 10 Jun 2014
Has thanked: 4 times

Re: hibrid auto and manual trading.

Postby florianp3 » 24 Apr 2015

Code: Select all

Inputs: DayStartEQ(1000),DLL(-500); // DLL=daily loss limit

vars:closedEQ(0),stopval(pos(DLL)/bigpointvalue),mp(0),accntID(""),symb("");

accntID=GetAccountID(); // find the account number

mp=marketposition_at_broker; // find the real time market position

value1=GetRTAccountEquity(accntID); //find the real-time account equity
closedEQ=value1-DayStartEQ; // calculate the day net PL

if mp<>0 then begin
symb=GetPositionSymbol(accntID,1);
value2=GetPositionAveragePrice(symb,accntID);
value3=GetPositionQuantity(symb,accntID);

stopval=pos((DLL-closedEQ)/((pos(value3)*bigpointvalue)));

if mp>0 then sell ("LEQ") next bar at value2-stopval stop;
if mp<0 then buytocover ("SEQ")next bar at value2+stopval stop;
end;
Print(accntID,symb,value1,value2,value3,closedEQ,stopval);


Return to “MultiCharts”