Coding Moving crossing other Averages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #40025 quote
    Juan Salas
    Participant
    Master

    Hi everyone,

    I have problem with coding a line.

    I want to BUY when the WilderAverage[1](close) crosses over Wilder Average[6] (close)[6]*1.0003 and then crosses over Wilder Average[6] (close)[6]*1.001, and after the first bull candle > than Wilder Average[6] (close)[6]*1.001

    REM Conditions

    entrylargo1 = WilderAverage[1](close) crosses over Wilder Average[6] (close)[6]*1.0003 AND crosses over Wilder Average[6] (close)[6]*1.001

    entrylargo2 = (open<close) >Wilder Average[6] (close)[6]*1.001

    I wrote:

    IF NOT LONGONMARKET AND entrylargo1 AND entrylargo2 THEN

    BUY 1 CONTRACT AT MARKET

     

    But, nothing happens.

    Any suggestions?

    Thanks in advance,

    Juan

    #40026 quote
    Despair
    Blocked
    Master

    AND in PRT is the logical AND and not the conjunction one uses in normal speech. So your condition could be:

    IF close crosses over MA1 and close crosses over MA2...
    you can not write:
    If close crosses over MA1 and (implying the close) crosses over MA2...
    You have to repeat WHAT crosses over WHICH threshiold.
    #40027 quote
    Juan Salas
    Participant
    Master

    Despair,

    THANNNKKKKKSSSSS so much!!

    It makes sense,

    Juan

    #40038 quote
    Juan Salas
    Participant
    Master
    DEFPARAM Cumulateorders = false
    
    // Indicadores
    WMprecio = WilderAverage[1](close)
    WM6mas2 = WilderAverage[6](close[6])*1.001
    WM6mas1 = WilderAverage[6](close[6])*1.0003
    WM6ceroazul = WilderAverage[6](close[6])
    //WM6menos1 = WilderAverage[6](close[6])*0.9997
    //WM6menos2 = WilderAverage[6](close[6])*0.999
    
    // Entrada LARGO
    IF NOT LONGONMARKET AND WMprecio crosses over WM6ceroazul AND WMprecio crosses over WM6mas1 AND WMprecio crosses over WM6mas2 AND open>WM6mas2 AND close>open THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Salida LARGO
    IF LONGONMARKET AND WMprecio crosses under WM6mas2 AND WMprecio crosses under WM6mas1 AND WMprecio crosses under WM6ceroazul THEN
    SELL AT MARKET
    ENDIF

    Hi Despair,

    I did it like you said, but still nothing happens. Do you think that it has something to do with the fact that the Moving Average are 6 period forward???

    I am attaching a portion of the code (the rest is incomplete), to see if anyone can see what is wrong in these lines.

    Thanks in advance,

    Juan

    #40041 quote
    Juan Salas
    Participant
    Master

    I think the problem is that all these requisites do not happen in the last candle. I have removed two of the three moving averages and I have one operation.

    It seems like 1.crossing the average and 2. than last candle is a bullish/green and that 3. its close is above the average, all have to happen in the last candles.

    Juan

    #40043 quote
    Juan Salas
    Participant
    Master

    I meant “in the last candle” (singular)

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

Coding Moving crossing other Averages


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Juan Salas @juan-salas Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Juan Salas
8 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/07/2017
Status: Active
Attachments: No files
Logo Logo
Loading...