I’m facing an issue with my Pine Script when trying to draw a position box (long/short) on a chart. The box appears far away from where it should be, even though I’ve entered the correct values for the entry and stop loss (SL).
What I’m trying to do:
Plot the entry price and SL on the EURGBP chart (1H timeframe).
Since the position is open and no take profit (TP) is set, I’ve set the TP to the same value as the entry to prevent the script from breaking.
The problem: Although I’m using the correct values, the plotted box is far from the expected location.
For example, following is one of the scripts I’m using:
//@version=5
indicator("Trade History: EURGBP! - Generated", overlay=true)
// Colors for different types of trades
longColor = color.new(color.green, 0)
shortColor = color.new(color.red, 0)
entryPrice136 = input(0.84480, title="Entry Price 136")
takeProfitLevel136 = input(0.84480, title="Take Profit Level 136")
stopLossLevel136 = input(0.84081, title="Stop Loss Level 136")
startTime136 = input.time(timestamp("2025-01-17 10:58"), title="Start Time for Position 136 (UTC)")
endTime136 = input.time(timestamp("2025-01-17 16:27"), title="End Time for Position 136 (UTC)")
isInTimeRange136 = (time >= startTime136 and time <= endTime136)
p_tpLvl136 = plot(isInTimeRange136 ? takeProfitLevel136 : na, title="TP 136", color=color.green, linewidth=2, style=plot.style_linebr)
p_slLvl136 = plot(isInTimeRange136 ? stopLossLevel136 : na, title="SL 136", color=color.red, linewidth=2, style=plot.style_linebr)
p_entryLvl136 = plot(isInTimeRange136 ? entryPrice136 : na, title="Entry 136", color=color.blue, linewidth=2, style=plot.style_linebr)
fill(p_entryLvl136, p_tpLvl136, color=isInTimeRange136 ? color.new(color.green, 80) : na, title="TP Area 136")
fill(p_entryLvl136, p_slLvl136, color=isInTimeRange136 ? color.new(color.red, 80) : na, title="SL Area 136")
If you notice,
The entryPrice136 is 0.84480, and the stopLossLevel136 is 0.84081. The plotted box is nowhere near these values on the chart (please see screenshot)
The box was plotted on EURGBP pair on 1H Timeframe
Is there anyone who would know how to resolve such an issue? Thanks.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745354560a4624038.html
评论列表(0条)