current price and intraday order?

Questions about MultiCharts and user contributed studies.
choiwongang
Posts: 3
Joined: 16 Nov 2021

current price and intraday order?

Postby choiwongang » 17 Nov 2021

MC VERSION: I WILL POST LATER
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;
Here is my code.

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.
Last edited by choiwongang on 18 Nov 2021, edited 6 times in total.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: current price and intraday order?

Postby TJ » 17 Nov 2021

See post #1 & 2
1. [FAQ] How to Post Codes ... so that people can read.
viewtopic.php?t=11713


Return to “MultiCharts”