BULLFIZZ
Member
@barbaros can you please fix the below script, tried to load it up and i think something is not right. thank you very much.
# Define the length of the breakout period
input breakoutLength = 10;
# Define the amount by which the price must break out
input breakoutThreshold = 2;
# Define the amount of time to hold the position after a breakout
input holdPeriod = 5;
# Calculate the high and low prices over the breakout period
def high = Highest(high, breakoutLength);
def low = Lowest(low, breakoutLength);
# Check if the price has broken out
def breakout = if high[1] < high and low[1] > low then 1 else 0;
# Calculate the entry price for long and short positions
def longEntry = high + breakoutThreshold * tickSize;
def shortEntry = low - breakoutThreshold * tickSize;
# Set the entry and exit conditions for long and short positions
def longCondition = if !breakout[1] and breakout and close > longEntry then 1 else 0;
def shortCondition = if !breakout[1] and breakout and close < shortEntry then 1 else 0;
# Enter a long position if the long condition is met
if longCondition and !IsLong() then
Buy("Long Breakout") next bar at longEntry stop;
# Enter a short position if the short condition is met
if shortCondition and !IsShort() then
SellShort("Short Breakout") next bar at shortEntry stop;
# Exit the long position after the hold period has passed
if IsLong() and !longCondition and !shortCondition and barsSinceEntry > holdPeriod then
Sell("Long Exit") next bar at market;
# Exit the short position after the hold period has passed
if IsShort() and !longCondition and !shortCondition and barsSinceEntry > holdPeriod then
BuyToCover("Short Exit") next bar at market;
# Define the length of the breakout period
input breakoutLength = 10;
# Define the amount by which the price must break out
input breakoutThreshold = 2;
# Define the amount of time to hold the position after a breakout
input holdPeriod = 5;
# Calculate the high and low prices over the breakout period
def high = Highest(high, breakoutLength);
def low = Lowest(low, breakoutLength);
# Check if the price has broken out
def breakout = if high[1] < high and low[1] > low then 1 else 0;
# Calculate the entry price for long and short positions
def longEntry = high + breakoutThreshold * tickSize;
def shortEntry = low - breakoutThreshold * tickSize;
# Set the entry and exit conditions for long and short positions
def longCondition = if !breakout[1] and breakout and close > longEntry then 1 else 0;
def shortCondition = if !breakout[1] and breakout and close < shortEntry then 1 else 0;
# Enter a long position if the long condition is met
if longCondition and !IsLong() then
Buy("Long Breakout") next bar at longEntry stop;
# Enter a short position if the short condition is met
if shortCondition and !IsShort() then
SellShort("Short Breakout") next bar at shortEntry stop;
# Exit the long position after the hold period has passed
if IsLong() and !longCondition and !shortCondition and barsSinceEntry > holdPeriod then
Sell("Long Exit") next bar at market;
# Exit the short position after the hold period has passed
if IsShort() and !longCondition and !shortCondition and barsSinceEntry > holdPeriod then
BuyToCover("Short Exit") next bar at market;