I am trying to build a daily profit stop for my trading system. The idea is to activate a trigger (or flag) that kicks in at a predetermined profit ($200 dollars for example) and keeps trading as long as the daily profit is above that profit level. As soon as the daily profit drops below it ($187.50 for example) the system stops trading for the day. I tried variations on the daily loss/profit examples in this forum, but it does not work correctly. Here is an example of what I have done so far:
If Use_ProfitStop = True then begin
If date > date and time < StartTime then begin
yesterdayProfit = NetProfit;
todayProfit = NetProfit - yesterdayProfit;
If ProfitStop < (todayProfit + MaxPositionProfit) and (todayProfit + OpenPositionProfit) < ProfitStop
then StopTrading = True else StopTrading = False;
If MarketPosition = 1 and StopTrading = True then Sell("PStop_X_L")this bar close;
If MarketPosition = -1 and StopTrading = True then Buytocover("PStop_X_S")this bar close;
Problem is that I get the signal that it has reached a limit, but it re-enters the market again later on the same trading day. Any help is greatly appreciated!
The code that you combine with your question doesn't make sense since it doesn't show any entries.
So, by which magic do you think other FIO members could guess how your entry rules are faulty
because they lead to unwanted re-entries?