trasformare un indicatore in strategia

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #183001 quote
    emanuele81
    Participant
    Senior

    Buongiorno Roberto vorrei trasformare il tuo indicatore, magic trend in una strategia per ingressi long e short, mi puoi aiutare a fare questa cosa, sempre se possibile.

    Grazie

    #183085 quote
    robertogozzi
    Moderator
    Master

    Ti ho fatto questa semplice strategia che entra Long quando c’è un incrocio rialzista del prezzo con l’indicatore, ed entra Short quando c’è un incrocio ribassista.In Entrambi i casi NON fa lo Stop & Reverse, ma attende di non essere a mercato per entrare.

    Ho messo uno SL fisso in pips ed un moltiplicatore per il TP.

    DEFPARAM CumulateOrders = False
    ONCE SL = 200 * PipSize
    ONCE TP = SL * 3.0
    MT = CALL "Magic Trend custom"[20, 14, 1, 5]
    L1 = close CROSSES OVER  MT
    S1 = close CROSSES UNDER MT
    IF L1 AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
    ELSIF S1 AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET TARGET pPROFIT TP
    SET STOP   pLOSS   SL
    #183093 quote
    emanuele81
    Participant
    Senior

    grazie mille Roberto

    #183094 quote
    emanuele81
    Participant
    Senior

    Per rendere la strategia migliore dovrebbe qntrare long solo quando la media mobile 200 è in rialzo

    e short al contrario, come posso scrivere l codice per farle fare questa cosa?

    #183095 quote
    robertogozzi
    Moderator
    Master

    Eccolo:

    DEFPARAM CumulateOrders = False
    ONCE SL = 200 * PipSize
    ONCE TP = SL  * 3.0
    MT      = CALL "Magic Trend custom"[20, 14, 1, 5]
    Sma200  = average]200,0](close)
    Rialzo  = Sma200 > Sma200[1]
    Ribasso = Sma200 < Sma200[1]
    L1 = (close CROSSES OVER  MT) and Rialzo
    S1 = (close CROSSES UNDER MT) and Ribasso
    IF L1 AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
    ELSIF S1 AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET TARGET pPROFIT TP
    SET STOP   pLOSS   SL
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

trasformare un indicatore in strategia


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
emanuele81 @emanuele81 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 2 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 12/08/2021
Status: Active
Attachments: No files
Logo Logo
Loading...