简体   繁体   中英

How to identify the color of candle?

i want to put a long position when at least 3 candles are red and the next one formed after it should be green or if the red candle is still forming, i want to wait until a green candle shows up

if open[3] > open[2] and open[2] > open[1] // here i want to check if red candles are still forming  after these 3
   if open >= open[1]  //  here I want to check if the current candle is green or not 
      strategy.entry("long", strategy.long,100)

i don't have much idea how can i form this condition so i am unable to provide more than this,

参考我的想法

As we can understand from your image, red candle is a beaish candle, green is a bullish candle.
In your code you can use:

red_candle = close < open
green_candle = open > close

// here i want to check if red candles are still forming  after these 3
if red_candle[3] and red_candle[2] and red_candle[1]
    //  here I want to check if the current candle is green or not 
    if green_candle
        strategy.entry("long", strategy.long,100)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM