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?
hibrid auto and manual trading.
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: hibrid auto and manual trading.
Please post your code... We can help you to debug.::
I tried to use it with !From Broker To Strategy syncronizer to no avail.
What am I doing wrong? Any suggestions?
Re: hibrid auto and manual trading.
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);