Risk Management: If already long then do not place new order

后端 未结 1 1744
别跟我提以往
别跟我提以往 2021-01-24 02:03

If the flag is already indicating long, there should not be a new flag indicating long. If flag does not indicate long evaluate the expression

longCondition = i         


        
1条回答
  •  Happy的楠姐
    2021-01-24 02:43

    I assume this is an indicator and not a strategy. Because you can configure how many entries you want to have in the same direction in a strategy with the pyramiding parameter. Default is 0, so if this is a strategy and you haven't changed the pyramiding parameter, it shouldn't be a problem.

    For indicators, you can use a variable like this:

    //@version=4
    study("My Script", overlay=true)
    
    var isLong = false
    var isShort = false
    
    rsi = rsi(close, 14)
    moving_avg = ema(close, 9)
    
    buySignal = not isLong and (rsi<50) and (close>moving_avg)    // Buy only if we are not already long
    sellSignal = not isShort and (rsi>50) and (close

    0 讨论(0)
提交回复
热议问题