I have a strategy that enters by market order 2 contracts, one with a specific target and one with a trailing stop, both contracts before they hit their target have a hard stop. As my trading starts each day, it counts the number of winners vs losers, as well as how much each position (trade entry consisting of 2 trades) won or lost.
I was able to write a function that calculated the number of entries for a given trading date, however I am not sure how to go about coding the other requirements.. Below is my function.
Code: Select all
Inputs:
ScanDate(numeric);
Variables:
x(0),
vLastEntryTime(0),
vCurrentEntryTime(0),
vPositionProfit(0),
vTotalProfit(0),
vNbrWinningTrades(0),
vNbrLosingTrades(0),
intrabarpersist vNbrEntries(0);
{calculate number of entries}
if entrydate(1) = scandate then begin
vCurrentEntryTime = EntryTime(1);
if vCurrentEntryTime > vLastEntryTime then begin
vNbrEntries = vNbrEntries +1;
end;
vLastEntryTime = vCurrentEntryTime;
end;
{calculate number of wins}
//????????????
{calculate number of losses}
//??????????????????
{calculate win total amount}
//???????????????
_KT_fPOQ = netprofit; // vNbrWinningTrades; // vNbrEntries;