//@version=4 strategy(title=“EMA crosses”, overlay=true)
// Inputs priceData = input(title=“Price data”, type=input.source, defval=hl2) ema1Length = input(title=“EMA 1”, type=input.integer, defval=12) ema2Length = input(title=“EMA 2”, type=input.integer, defval=24) ema3Length = input(title=“EMA 3”, type=input.integer, defval=36)
// Compute values ema1 = ta.ema(priceData, ema1Length) ema2 = ta.ema(priceData, ema2Length) ema3 = ta.ema(priceData, ema3Length)
enterLong = ema1 > ema2 and ema2 > ema3 enterShort = ema1 < ema2 and ema2 < ema3
// Plot values plot(series=ema1, color=color.orange, linewidth=2) plot(series=ema2, color=color.maroon, linewidth=2) plot(series=ema3, color=color.blue, linewidth=2)
// Submit orders if (enterLong) strategy.entry(id=“Enter Long”, long=strategy.long)
if (enterShort) strategy.entry(id=“Enter Short”, long=strategy.short)
Currently, this code always comes down at the beginning of the retest, and then the rest doesn't seem to trigger, which boss can tell me how to get the policy loop to execute, thank you.
Inventors quantify - small dreamsstrategy.entry ((id="Enter Long", long=strategy.long), this function call is misspelled. In this case, you can write directly: strategy.entry (("Enter Long", strategy.long, 1) and you will get 1 hand, a coin, a piece of paper.
Inventors quantify - small dreamsThe pyramiding parameter of the strategy function.
Inventors quantify - small dreams666, fill up the tank.
CryptoLiuI would also like to consult the writing of the same direction continuously triggering the signal, the current writing can only open a position in one direction, if enterLong is continuously triggered, then the next trigger can not be ordered. Please tell me how to write, can you make me more continuous?
CryptoLiuThank you, it's okay, I can continue to yell at the door.
Inventors quantify - small dreamsWhat's up? // Submit orders if enterLong and strategy.position_size <= 0 This is a list of all the different ways Strategy.entry is credited in the database. // strategy.exit ((("exit_long", "Enter_Long", when = enterShort) is the name of the program. if enterShort and strategy.position_size >= 0 This is a list of all the different ways Enter_Short is credited in the database. // strategy.exit (("exit_short", "Enter_Short", when =enterLong) What's up? If you write == 0, then the other one will not be triggered after opening the position, because holding is not equal to 0.
CryptoLiu//@version=4 This is the latest version This is a list of all the different ways EMA_crosses is credited in the database. // Inputs The value of the input data is the same as the value of the input data. Ema1Length = input ((title="EMA_1", type=input.integer, defval=12) is used to define the value of a variable. Ema2Length = input ((title="EMA_2", type=input.integer, defval = 24) Ema3Length = input ((title="EMA_3", type=input.integer, defval = 36) // Compute the values Ema1 = ta.ema ((priceData, ema1Length) is the length of the data. Ema2 = ta.ema ((priceData, ema2Length) is the length of the data. ema3 = ta.ema ((priceData, ema3Length) is the length of the data. enterLong = ema1 > ema2 and ema2 > ema3 enterShort = ema1 < ema2 and ema2 < ema3 // Plot values plot ((series=ema1, color=color.orange, linewidth=2)) plot (series=ema2, color=color.maroon, linewidth=2) plot ((series=ema3, color=color.blue, linewidth=2) // Submit orders if enterLong and strategy.position_size == 0 This is a list of all the different ways Strategy.entry is credited in the database. strategy.exit ((("exit_long", "Enter_Long", when = enterShort) is the name of the program. if enterShort and strategy.position_size == 0 This is a list of all the different ways Enter_Short is credited in the database. strategy.exit (("exit_short", "Enter_Short", when =enterLong) // Color background backgroundColour = (strategy.position_size > 0)? color.green : color.red This is a list of all the colors that are available in this category. bgcolor ((color=backgroundColour, transp=85)) is the name of the game. I've adjusted it a bit, but it only triggers once at the beginning of the policy, and then it doesn't.