Announcement

Collapse
No announcement yet.

PriceBarColor; same bar double trade

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PriceBarColor; same bar double trade

    Jason, many thanks for your prompt and clear reply.
    Still more questions:
    19. Follow up of question 16: Brad is using 'bPosition' in Sample_TargetStop.efs (see attached) to 'prevent new entry on the same bar that an exit trade occured'. I still do not see the reason to this prevention. Even if I did a close of a trade on Current bar, I should still be able to generate a New Signal on the Same Current bar (like a Reversal) because the buy/sell will be done on the NEXTBAR anyway.
    20. strMA-Pcrsv_NEXBAR.efs (and others) do not paint the bars on BackTest, as expected from the code. Is it normal? Only on PaperTrade the bar painting works? See code below:

    var study = new MAStudy(40, 0, "Close", MAStudy.SIMPLE);
    function preMain() {
    setPriceStudy(true);
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.black);

    }
    function main() {
    var v = study.getValue(MAStudy.MA);
    if(v == null)
    return;
    if(close() >= v && !Strategy.isLong())
    Strategy.doLong("Crossing Up", Strategy.MARKET, Strategy.NEXTBAR); //AA
    if(close() < v && !Strategy.isShort())
    Strategy.doShort("Crossing Down", Strategy.MARKET, Strategy.NEXTBAR); //AA
    if(Strategy.isLong())
    setPriceBarColor(Color.lime);
    else if(Strategy.isShort())
    setPriceBarColor(Color.red);
    return v;
    }
    Thanks, Arie
    Attached Files

  • #2
    Hello Arieal,

    19. When back testing with the Strategy Analyzer, the EFS only gets executed once. We don't know the order of how the trades occurred that creates the high and low for that particular bar. Theoretically, yes, you could write a back testing EFS that reenters a trade right after exiting a position on the same bar. The problem is that you have to make some assumptions as to the timing of things during that bar. Did the high occur before the low or vise versa? There's no way to know this in a back testing scenario. So for back testing purposes only, you should not enter a new trade on the same bar where you just closed the previous position because you could be creating unrealistic results. That's why Brad's formula uses "bPosition" to prevent entering a new position on the same bar. Avoiding reentry on an exit bar is not a rule you have to follow, it's just some good advice.

    20. You shouldn't have any problems with painting bars. The code you posted is working on my end. What are you seeing on your end?

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Jason,
      I am deeply in gratitude for your help and time.
      Related to question 20, no, I still couldn't see on my chart the bars being colored, neither the MA(40) was displayed by the code's return. Any suggestion for this problem?
      Thanks, Arie

      Comment


      • #4
        Dear Jason
        Display problem solved: I didn't apply the efs formula to the chart, but I was just running the BackTestk, believing that this will also do the display.
        Thanks, Arie

        Comment

        Working...
        X