Code: Select all
if TrendFlag and Flag and NoGap then begin
Buy("75") .75*size shares next bar at Trig Stop;
Buy("25") .25*size shares next bar at Trig Stop;
end;
Code: Select all
if TrendFlag and Flag and NoGap then begin
Buy("75") .75*size shares next bar at Trig Stop;
Buy("25") .25*size shares next bar at Trig Stop;
end;
Code: Select all
SetStopShare;
SetBreakEven(R*1.2);
Could you give me the piece of code where both orders are generated?It looks better now but I am running into another issue. When a sell order for partial profits is made, it appears that no other sell orders will take place on the same bar. I have several instances on my charts where both the partial sell and the rest of the position should be sold on the same bar. The partial is sold and then the system exits on the next bar if the condition is still true. For instance, I have a partial sell at a price level.
Code: Select all
if MP = 1 then sell .25*size shares from entry("Long") next bar at (1.2*R + Trig) limit;
if MP = 1 then sell from entry("Long") next bar at iStop Stop;
SetStopShare;
SetBreakEven(R*1.2);
Code: Select all
if MP = 1 then begin
print(File("C:\sell_limit_exit.txt"), "======================", NewLine,
"The date is ", DateToString(DateToJulian(Date)), ",", NewLine,
"time is ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine,
"bar # is ", Symbol_CurrentBar, ",", NewLine,
"current bar open is ", open, ",", NewLine,
"current bar high is ", high, ",", NewLine,
"current bar low is ", low, ",", NewLine,
"current bar close is ", close, ",", NewLine,
"market position on chart is", MarketPosition, ",", NewLine,
"MP = 1, so at close of this bar (or at current tick if IOG=TRUE) the limit order to sell at ", 1.2*R + Trig, " is generated by the script", NewLine,
"to be executed at bar # ", Symbol_CurrentBar+1, " if IOG=FALSE. If IOG=TRUE, it can be filled at next intrabar tick");
sell .25*size shares from entry("Long") next bar at (1.2*R + Trig) limit;
end;
if MP = 1 then begin
print(File("C:\sell_stop_exit.txt"), "======================", NewLine,
"The date is ", DateToString(DateToJulian(Date)), ",", NewLine,
"time is ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine,
"bar # is ", Symbol_CurrentBar, ",", NewLine,
"current bar open is ", open, ",", NewLine,
"current bar high is ", high, ",", NewLine,
"current bar low is ", low, ",", NewLine,
"current bar close is ", close, ",", NewLine,
"market position on chart is", MarketPosition, ",", NewLine,
"MP = 1, so at close of this bar (or at current tick if IOG=TRUE) the stop order to sell at ", iStop, " is generated by the script", NewLine,
"to be executed at bar # ", Symbol_CurrentBar+1, " if IOG=FALSE. If IOG=TRUE, it can be filled at next intrabar tick");
sell from entry("Long") next bar at iStop Stop;
end;
print(File("C:\breakeven_stop_exit.txt"), "======================", NewLine,
"The date is ", DateToString(DateToJulian(Date)), ",", NewLine,
"time is ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine,
"bar # is ", Symbol_CurrentBar, ",", NewLine,
"current bar open is ", open, ",", NewLine,
"current bar high is ", high, ",", NewLine,
"current bar low is ", low, ",", NewLine,
"current bar close is ", close, ",", NewLine,
"market position on chart is", MarketPosition, ",", NewLine,
"On every code calculation the BrekEven stop order to exit at ", EntryPrice, " is generated by the script", NewLine,
"to be executed only if you have an open position at bar # ", Symbol_CurrentBar+1, " if IOG=FALSE. If IOG=TRUE, it can be filled at next intrabar tick");
SetStopShare;
SetBreakEven(R*1.2)