I have a code working on weekly closing. Basically, some buy signals on the stock along with specific conditions for foreign stock, in my case the benchmark index. My prob is when I use the setforeign function and use tradeprices as true to backtest, I get buy and sell signals at HIGH PRICE and NOT at close despite defining 0 trade delays and buyprice = sell price = close;
this is the code I am working with:
SetForeign("NIFTY",fixup = True, tradeprices = True);
marketup = TimeFrameExpand(RSI(14),inweekly) > 40
AND TimeFrameExpand(C, inweekly) > TimeFrameExpand(EMA(C,34), inweekly);
RestorePriceArrays(tradeprices);
If I change the tradeprices to false then I get the correct trade prices on the backtest (i.e. at CLOSE) but then the system DOES NOT use previous bar equity for new positions as programed SetOption( "UsePrevBarEquityForPosSizing", True ); and reduces the exposure of my portfolio dramatically.
I have ATR based SL along with other multiple sell signals for my system. Does that matter? Happy to send the entire code if needed.
I would really appreciate if anyone can help me resolve this issue pls.
Thanks