1. Running a backtest on GC using 1 min bars for 4 years of data
2. Every entry has a pre-decided stop and profit target
3. My logic for simulating stops right now is as follows:
a. if High or Low > or < than Stop Price, Execute Stop next bar market
4. However in real market conditions, I m getting filled tick by tick in my Algo Engine.
5. So in reality, my slippage is going to be 1 to 2 ticks
6. I prefer not to use Intrabar order generation because it will make my strategy logic fairly complicated, because i have multiple time frames and I m using 1m in time frame to construct my own 60 min bars.
7. I was wondering if there is a solution along the lines.
buytocover ("60Min_S_PT") ContractSize shares next bar at 1341.10;
Question:
How do I specify to Multicharts in Easy language that if my stop price is 1340.10 and High of the bar is > 1340.10, fill me at 1340.20 on my stop.
******************************************************************************
Here is the sample code:
Code: Select all
// Shorts Profit Target and Stops
if marketposition = -1 then begin
// Did we hit the profit target
if low < shortProfitTarget then begin
Print("Profit Target Reached for Short Position, Low < ShortProfitTarget: ", shortProfitTarget);
Print("Symbol: ",symbolname, ", Date: ", Date, ", Time: ", Time, ", Open: ", Open, ", High: ", High, ", Low: ", Low, ", Close: ", Close);
Print("Covering short position for the Algo using Profit Target");
buytocover ("60Min_S_PT") ContractSize shares next bar market;
end;
// Did we hit the stop
if high > shortStop then begin
Print("Stop Reached for Short Position, High > ShortStop: ", shortStop);
Print("Symbol: ",symbolname, ", Date: ", Date, ", Time: ", Time, ", Open: ", Open, ", High: ", High, ", Low: ", Low, ", Close: ", Close);
Print("Covering short position for the Algo using Stop Loss");
buytocover ("60Min_S_ST") ContractSize shares next bar market;
end;
end;
// Long Profit Target and Stops
if marketposition = 1 then begin
// Did we hit the profit target
if high > longProfitTarget then begin
Print("Profit Target Reached for Long Position, High > LongProfitTarget: ", longProfitTarget);
Print("Symbol: ",symbolname, ", Date: ", Date, ", Time: ", Time, ", Open: ", Open, ", High: ", High, ", Low: ", Low, ", Close: ", Close);
Print("Covering long position for the Algo using Profit Target");
sell("60Min_L_PT") ContractSize shares next bar market;
end;
// Did we hit the stop
if low < longStop then begin
Print("Stop Reached for Long Position, Low < LongStop: ", longStop);
Print("Symbol: ",symbolname, ", Date: ", Date, ", Time: ", Time, ", Open: ", Open, ", High: ", High, ", Low: ", Low, ", Close: ", Close);
Print("Covering long position for the Algo using Stop Loss");
sell ("60Min_L_ST") ContractSize shares next bar market;
end;
end;