variable: intrabarpersist position_1(0);
variable: intrabarpersist entry_price(0);
variable: intrabarpersist stop_loss(0);
variable: intrabarpersist take_profit(0);
condition1 = close crosses above average(close, 7);
condition2 = close crosses below average(close, 7);
stop_loss_level = entry_price * 0.95; // Example: 5% stop-loss
take_profit_level = entry_price * 1.10; // Example: 10% take-profit
if position_1 == 0 then
begin
if condition1 then
begin
position_1 = 1;
entry_price = close;
stop_loss = stop_loss_level;
take_profit = take_profit_level;
// ... (rest of the entry logic)
end;
end
else
begin
if condition2 or close <= stop_loss or close >= take_profit then
begin
position_1 = 0;
entry_price = 0;
stop_loss = 0;
take_profit = 0;
// ... (rest of the exit logic)
end;
end;
1 評論