i use a dailyprofit counter to detect the daily total profit.
at the end of the day, the dailyprofit counter will set zero and works another round the next day...
but the program is trading the same as without the counter....
am i making any mistake? any easier method to do so? thanks a lot!
Code: Select all
[intrabarordergeneration = true];
input: NetProfitLimit(800), NetLossLimit(-800);
var: var0(0), var1(0), var2(0), var3(0), DailyProfit(0), tradeprofit(0);
tradeprofit = PosTradeProfit(0,0);
condition1 = CurrentBar > 2 and var2 cross under varX ;
condition2 = CurrentBar > 2 and var2 cross over varY ;
condition3 = DailyProfit <= NetProfitLimit and DailyProfit >= NetLossLimit;
if marketposition = 0 and condition3 and condition1 then
Buy next bar market
else if marketposition = -1 and condition3 and condition1 then
begin
DailyProfit = DailyProfit + tradeprofit;
Buy next bar market;
end;;
if marketposition = 0 and condition3 and condition2 then
Sell Short next bar market
else if marketposition = 1 and condition3 and condition2 then
begin
DailyProfit = DailyProfit + tradeprofit;
Sell Short next bar market;
end;;
input: CloseTime(1615);
if (Time = CloseTime) then
Begin
RecalcLastBarAfter(1);
DailyProfit = 0;
sell next bar market;
buytocover next bar market;
End;