DATA : CSI DATA FUTURES 20 YEARS DAILY. NO REAL-TIME DATA. NO BROKER.
PROBLEM: MAKING STRATEGIES ON POWERLANGUAGE IN BACKTESTING.
HERE IS MY STRATEGY RULES:
TURTLE SOUP
FOR BUYS (SELLS ARE REVERSED)
1. Today must make a new 20-day low-the lower the better.
2. The previous 20-day low must have occurred at least four trading sessions
earlier. This is very important.
3. After the market falls below the prior 20-day low, place an entry buy stop
5-10 ticks above the previous 20-day low. This buy stop is good for today only.
4. If the buy stop is filled, immediately place an initial good-till -canceled sell
stop-loss one tick under today's low.
5. As the position becomes profitable, use a trailing stop 15%.
Code: Select all
[IntrabarOrderGeneration=true]
vars:
ticksize(minmove/PriceScale),
newlow_con(false),
newlow_bcon(false);
newlow_con = low<lowest(low,20)[1];
newlow_bcon = lowestbar(low,20)[1]>3;
if newlow_con and newlow_bcon then begin
buy("long") 1 contract this bar at close;
end;
if marketposition <> 0 then begin
sell("stop loss") 1 contract next bar at low-1*ticksize stop;
setpercenttrailing(0,15);
end;
1. When the current price falls below the 20-day low, I want to place a buy order immediately, and a stop loss + trailing stop order at the time of execution. However, as in this coding, this bar order is only a closing price order. How can I make order intraday when the current price is lower than 20-day low? I don't want to make order when the market is closed.