cross under not satisfied but still entered

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #163334 quote
    kevin12345kevin12345
    Participant
    Average

    hi,

    the low of the candle has not cross under the ema 37 line but still entered a long position. any reason why?

    //conditions to go long
    longc1 = ema37 - ema50 > 0.0002 
    longc2 = high[1] < high[2] and high[2] < high[3]
    longc3 = (low[1] crosses under ema37) or (low[1] crosses under ema50)
    longc4 = (close[1] > ema50) and (close[2] > ema50) and (close[3] > ema50)
    longconditions = longc1 and longc2 and longc3 and longc4
    
    //long entry trigger
    buyentry = close >= high[1] 
    
    if not onmarket and longconditions and buyentry then
    buy 1 contracts at market 
    endif
    

    thank you

    #163335 quote
    kevin12345kevin12345
    Participant
    Average

    picture here

    asd.png asd.png
    #163338 quote
    kevin12345kevin12345
    Participant
    Average

    i thought it may be because of the spread but i tried changing it to 0 to some other number but the results are still the same.

    #163339 quote
    kevin12345kevin12345
    Participant
    Average
    //indicators
    ema37 = ExponentialAverage[37](close)
    ema50 = ExponentialAverage[50](close)
    //conditions to go long
    longc1 = ema37 - ema50 > 0.0002 
    longc2 = high[1] < high[2] and high[2] < high[3]
    longc3 = (low[1] crosses under ema37) or (low[1] crosses under ema50)
    longc4 = (close[1] > ema50) and (close[2] > ema50) and (close[3] > ema50)
    longconditions = longc1 and longc2 and longc3 and longc4
    
    //long entry trigger
    buyentry = close >= high[1] 
    
    if not onmarket and longconditions and buyentry then
    buy 1 contracts at market 
    endif

    forgot the indicators

    #163341 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Line 4 is logically wrong, it can’t test  a cross under between the previous LOW and current EMA’s.

    Replace it by:

    longc3 = (low crosses under ema37) or (low crosses under ema50)
    #163342 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Do not use 0.0002, rather 2*PipSize.

    #163343 quote
    kevin12345kevin12345
    Participant
    Average

    but one of the conditions is if the previous low crosses under those ema or value of it less than the ema. i do not want the lastest candle.

    #163344 quote
    kevin12345kevin12345
    Participant
    Average

    when i try to replace line 7 with

    longc3 = (low[1] < ema37) or (low[1] < ema50)

    results are the same.

    #163345 quote
    kevin12345kevin12345
    Participant
    Average

    got it

    i did this

    longc3 = (low[1] crosses under ema37[1]) or (low[1] crosses under ema50[1])
    #163346 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    That looks good!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

cross under not satisfied but still entered


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kevin12345 @kevin12345 Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/07/2021
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...