Looking for a simple script to track the open prices as certain conditions are met.
For example:
Bar 1
Bar 2
DynamicOpenPrice
If (Bar 2 high > Bar 1 high || Bar 2 Low < Bar 1 Low) // Check if the latest candle creates a higher high or lower low than previous candles high/low
{
DynamicOpenPrice = Bar 2 Open; // Open Price Pivot will be moved to latest candles Open price
Print("Current Open Pivot : ", DynamicOpenPrice);
}
If the above conditions aren't met then the DynamicOpenPrice stays at the previous level.
I have tried this very basic script but am getting weird outputs from the "Print". The DynamicOpenPrice is constantly changing with every tick. tested on a 15min chart by the way.
Any help would be greatly appreciated!
edit some example images below.... the DynamicOpenPrice (green line) should move up as new candle highs are created. And vice-versa as new lows are created the DynamicOpenPrice (green line) will move to the new candles open.
For example:
Bar 1
Bar 2
DynamicOpenPrice
If (Bar 2 high > Bar 1 high || Bar 2 Low < Bar 1 Low) // Check if the latest candle creates a higher high or lower low than previous candles high/low
{
DynamicOpenPrice = Bar 2 Open; // Open Price Pivot will be moved to latest candles Open price
Print("Current Open Pivot : ", DynamicOpenPrice);
}
If the above conditions aren't met then the DynamicOpenPrice stays at the previous level.
I have tried this very basic script but am getting weird outputs from the "Print". The DynamicOpenPrice is constantly changing with every tick. tested on a 15min chart by the way.
Any help would be greatly appreciated!
edit some example images below.... the DynamicOpenPrice (green line) should move up as new candle highs are created. And vice-versa as new lows are created the DynamicOpenPrice (green line) will move to the new candles open.
Attached Image
Attached Image
Attached Image
Attached Image