Trading System Macd

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #200045 quote
    SimonSimon
    Participant
    New

    Ciao, ho poco iniziato a realizzare dei TS per ProOrder e vorrei chiedere un aiuto per ricodificare questa strategia. (Multicharts)

    Ingresso long  e  short all’incrocio al rialzo o al ribasso tra Macd Signal e Macd line  e uscita dalle rispettive posizioni quando le due linee Macd Signal e Macd line iniziano a convergere.

    Grazie in anticipo .

    DEFPARAM CumulateOrders = False 
      
     
    //  Entrata Long
     
    indicator1 = MACDSignal[5,12,9](close)
     
    indicator2 = MACDline[5,12,9](close)
     
    c1 = (indicator1 CROSSES OVER indicator2)
     
     
    IF c1 THEN
     
    BUY 1 CONTRACT AT MARKET
     
    ENDIF
     
     
     
     
    // Condizioni per uscita Long
     
    //??
     
      
     
     
    // Entrata short
    
    
    indicator2 = MACDSignal[5,12,9](close)
     
    indicator3 = MACDline[5,12,9](close)
     
    c2 = (indicator2 > indicator3)
     
    IF c2 THEN
     
    SELLSHORT 1 CONTRACT AT MARKET
     
    ENDIF
     
     
     
    // Condizioni per uscita short
     
    //??
    Macd.jpg Macd.jpg
    #200081 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Mi spiace, ma non conosco il linguaggio Multicharts.

    Ad ogni modo segui questo link per chiedere la conversione https://www.prorealcode.com/free-code-conversion/.

    #200088 quote
    SimonSimon
    Participant
    New

    Grazie del suggerimento Roberto,

    sono riuscito a codificare la pima parte riguardo gli acquisti long e le relative uscite quando le linee Macd Signal e Macd line iniziano a convergere, quindi il valore Macd inizia a diminuire.

    Lo stesso dovrebbe avvenire per la fase short, ma non riesco a codificare l’uscita.

    La variabile A indica correttamente dove uscire ma il sistema non esce nel punto corretto.

    Sapresti cortesemente dirmi dove sbaglio?

    Grazie

    Simone

    DEFPARAM CumulateOrders = False
     
    //  Entrata Long
    ind1 = MACDSignal[12,26,9](close)
    ind2 = MACDline[12,26,9](close)
    c1 = (ind2 CROSSES OVER ind1)
    M= MACD[12,26,9](close)
    M1= MACD[12,26,9](close)
    IF c1 and M>0 THEN
    
    BUY 1 CONTRACT AT MARKET
    
    ENDIF
    
    // Condizioni per uscita Long
    //if onmarket and ind1-ind2>ind1[1]-ind2[1] and ind1[1]-ind2[1]>ind1[2]-ind2[2] then
    if onmarket and m<=m[1] then
    Sell  at Market
    endif
    
    //  Entrata Short
    c2 = (ind2 CROSSES under ind1)
    
    IF c2 and M1<0  THEN
     sellshort 1 CONTRACT AT MARKET
    ENDIF
    
    if m1>=m1[1]then
    a=0
    else
    a=1
    endif 
    
    // Condizioni per uscita Short
    //if onmarket and ind1-ind2>ind1[1]-ind2[1] and ind1[1]-ind2[1]>ind1[2]-ind2[2] then
    if onmarket and a=1 then
    Exitshort  at Market
    endif
    
    graph a
    #200089 quote
    SimonSimon
    Participant
    New

    [attachment file=”200090″]

    macd1-scaled.jpg macd1-scaled.jpg
    #200099 quote
    fifi743fifi743
    Participant
    Master

    Salve,
    Che cos’è l’indice o il forex e il timeframe

    #200104 quote
    SimonSimon
    Participant
    New

    le prove erano su indice Dax timeframe  1h

    il sistema comunque dovrebbe funzionare su qualsiasi strumento  applicando stoploss e ulteriori filtri ingresso

    #200106 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Esce perfettamente, esattamente quando a=1. Tu vedi la freccia di uscita sulla candela successiva, perché le strategie vengono eseguite allla chiusura di ogni candela, quindi entro qualche millisecondo l’operazione è chiusa, ma ormai si sta aprendo la nuova candela (o è stata appena aperta).

    #200110 quote
    fifi743fifi743
    Participant
    Master

    Sostituire a=1 con m[1]<m per i corti

    Simon thanked this post
    #200111 quote
    SimonSimon
    Participant
    New

    perfetto grazie, con la modifica esce correttamente

Viewing 9 posts - 1 through 9 (of 9 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

Trading System Macd


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Simon @simontemp Participant
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by SimonSimon
4 years, 1 month ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 09/02/2022
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...