TS con Stop & reverse e 2 target

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #26979 quote
    gpecom1gpecom1
    Participant
    New

    Buonasera,

    sono alle prime armi con ProRealCode.

    Per imparare, sto cercando di programmare un TS semplice, che utilizzo quotidianamente nel trading discrezionale, e che ha le seguenti caratteristiche:

    1. entry al primo cambio di colore del supertrend, dopo le 8:00
    2. Target1 e Target2
    3. stop & reverse

    Ringrazio Nicolas, che in altro topic mi ha aiutato col supertrend šŸ˜‰

    Ora però ho difficoltĆ  con lo Stop & reverse: ho preso il codice da alcuni post ed ho cercato di adattarlo alle mie esigenze, ma ancora non funziona….

    DEFPARAM FlatAfter = 223000
    st = supertrend[3,10]
    CambioVerde = close[1] < st[1] AND close > st
    CambioRosso = close[1] > st[1] AND close < st
    ncontr=2
    
    if intradaybarindex=0 then
    traded=0
    reverse=0
    endif
    
    // ENTRY
    if traded=0 then
    //LONG
    IF NOT ONMARKET AND TIME > 075500 AND CambioVerde THEN
    BUY ncontr contracts AT MARKET
    traded=1
    reverse=1
    ENDIF
    //SHORT
    IF NOT ONMARKET AND TIME > 075500 AND CambioRosso THEN
    SELLSHORT ncontr contracts AT MARKET
    traded=2
    reverse=1
    ENDIF
    endif
    
    //Reverse
    if reverse=1 then
    if traded=1 AND NOT ONMARKET AND POSITIONPERF(1)<0 THEN
    SELLSHORT ncontr contracts AT MARKET
    reverse=0
    ENDIF
    IF traded=2 AND NOT ONMARKET AND POSITIONPERF(1)<0 THEN
    BUY ncontr contracts AT MARKET
    reverse=0
    ENDIF
    endif
    
    SET STOP pLOSS mystop
    SET TARGET pPROFIT mytarget
    

     

    Inoltre, sto cercando di capire come si potrebbero programmare e gestire 2 TARGET con prorealcode.

    Infatti, vorrei che questo TS entrasse con più contratti e liquidasse 1/2 posizione a target 1 e l’altra 1/2 posizione a target 2.

    Mi sembra, però, che i comandi “SET STOP LOSS….” e “SET TARGET PROFIT” chiudano l’intera posizione, senza permettere di distinguere tra più target. E’ cosƬ? E’ giusto?

    Se ĆØ cosƬ – spero di avere capito bene – immagino di dover definire, con apposita variabili, i livelli di entry, stop, target1 e target 2, per poi utilizzare sia gli ordini “stop” che quelli “market”. Ad esempio:

    ....
    IF condizioni THEN
    BUY 2 contracts AT MARKET
    entry=close
    target1=close+(15*pointsize)
    target2= close+(50*pointsize)
    mystop=close-(15*pointsize)
    ENDIF
    ..........
    .........
    SELL 1 contracts AT target1 STOP
    //(o anche...)
    IF condizioni AND high >= target2 THEN
    SELL 1 contracts AT MARKET
    //(o anche, per lo stop...)
    SET STOP pLOSS mystop
    

     

    Ringrazio anticipatamente tutti gli amici di questo Forum che volessero darmi indicazioni e suggerimenti.

    Gian Paolo

Viewing 1 post (of 1 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

TS con Stop & reverse e 2 target


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
gpecom1 @gpecom1 Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 03/02/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...