Strategy Take Profit Logic

Questions about MultiCharts and user contributed studies.
user_01
Posts: 7
Joined: 13 Mar 2024
Been thanked: 1 time

Strategy Take Profit Logic

Postby user_01 » 23 Apr 2024

Hi guys, i implemented a partial take profit strategy but it seems to not work properly in real-time. In backtest it works fine. I trade daily bars and have IOG turned on. From the image attached, you could see that it takes TP1 right after it enters a buy at the same price. Can someone explain why this difference happens in real-time vs backtesting? I dont believe it is a code issue because it works fine in backtest. Maybe theres some difference in settings for real-time data and historical data im not aware of. Thank you in advance.

Code: Select all

if condition1 and condition2 and condition3 and condition4 then begin contract_size = (equity * (Risk/100)) / (close - sl); if contract_size > max_buypower / close then contract_size = max_buypower / close; pt1 = close + 1 * (close - sl); pt2 = close + 5 * (close - sl); pt3 = close + 10 * (close - sl); var0 = ((contract_size + currentcontracts) * close / equity) * 100; Buy(NumToStr(var0,2) + "%") contract_size contracts next bar x limit; end; if close < sl - ticksl then Sell("Initial SL") next bar on market; if marketposition <> 0 and close >= pt1 then begin Sell("PT1") 0.5 * currentcontracts contracts next bar on market; end;
Attachments
Screenshot 2024-04-24 113400.png
(8.55 KiB) Not downloaded yet

Return to “MultiCharts”