Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

Need simple daily buy entry code - PineScript

Nov 16, 2020 - 7:17 AM

Viewed 904 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/21303 COPY
  • I need very simple help. I'm extremely new to coding so I don't know how to do this.... How do I write a code that buys 25pips (w 7 pip stop-loss) of any selected pair every Wednesday at 10am est. ?

    0
  • Hello

    Haven't tested but I'd do something like this

    Based on this documentation: https://www.tradingview.com/pine-script-reference/v4/#fun_strategy{dot}entry

    //@version=4
    
    var InitCapital = 1000000
    var InitPosition = 100
    var InitCommission = 0.15
    var InitPyramidMax = 10
    var CalcOnorderFills = true
    var CalcOnTick = true
    var MaxBarsBack = 1500
    var DefaultQtyType = strategy.fixed
    var DefaultQtyValue = strategy.fixed
    var Currency = currency.USD
    var Precision = 6
    var Commission_type = strategy.commission.percent
    var Overlay=true
    var MaxLines=500
    var MaxLabels=500
    
    var StudyName = "Pinescript Sample"
    var ShortStudyName = "Pinescript Sample"
    
    strategy(title=StudyName, shorttitle=ShortStudyName, overlay=Overlay,
     pyramiding=InitPyramidMax, initial_capital=InitCapital, default_qty_type=DefaultQtyType, default_qty_value=InitPosition, commission_type=Commission_type,
     commission_value=InitCommission, calc_on_order_fills=CalcOnorderFills, calc_on_every_tick=CalcOnTick, max_bars_back=MaxBarsBack ,precision=Precision, currency=Currency,
     max_lines_count=MaxLines, max_labels_count=MaxLabels)
    
    ///
    pip() => syminfo.mintick * (syminfo.type == "forex" ? 10 : 1)
    
    // check if it's wednesday 10 am EST
    if dayofweek(timenow) == dayofweek.wednesday 
     and timestamp("GMT-5", year(timenow), month(timenow), dayofmonth(timenow), 10, 00, 00))
    
      // buy 1 contract
       strategy.entry(id="Long",  long=true)  
    
    strategy.exit(id="Exit Long", from_entry="Long",  profit=25, loss=7)
    
    0

    Dave - Helping traders becoming the best version of themselves
  • Daveatt you're a good man. I'll let you know how it goes after testing

    1
  • Didn't work unfortunately 😢

    0
CONTENTS