STOR IN PARI

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #192023 quote
    Hary TradingHary Trading
    Participant
    New

    Buonasera,

    ho scritto questo semplice codice:

    SL=400

    if close[1] > open[1] then

    buy  1 contract  at high+150   stop

    ENDIF

    SET TARGET PROFIT 800

    SET STOP LOSS SL

    if close[1] < open[1] then

    sellshort 1 contract  at low-150   stop

    ENDIF

    SET TARGET PROFIT 800

    SET STOP LOSS SL

     

    Vorrei inserire una condizione per cui, arrivati a 400 pt di profit (quindi in questo caso il 50% del target), si inserisca lo stop in pari, in modo tale che se il prezzo dovesse tornare indietro non perdo più…grazie a chi vorrà aiutarmi

     

     

    Se possibile, e non chiedo troppo, vorrei anche sapere, in alternativa alla condizione scritta sopra, come poter inserire un trailing stop di 100 punti una volta arrivati a 400 pt di profit

    Grazie a chi vorrà aiutarmi

    #192033 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Aggiungi il codice di Nicolas (linee 17- 56 al link  https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/), che ho modificato per avere solo il pareggio. Questo è il codice completo:

    SL=400
    if close[1] > open[1] then
    buy  1 contract  at high+150   stop
    ENDIF
    SET TARGET PROFIT 800
    SET STOP LOSS SL
    if close[1] < open[1] then
    sellshort 1 contract  at low-150   stop
    ENDIF
    SET TARGET PROFIT 800
    SET STOP LOSS SL
    trailingstart = 400
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    IF LONGONMARKET THEN
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)
    ENDIF
    ENDIF
    IF SHORTONMARKET THEN
    IF newSL=0 AND tradeprice(1)-close<=trailingstart*pipsize THEN
    newSL = tradeprice(1)
    ENDIF
    ENDIF
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    #192038 quote
    Hary TradingHary Trading
    Participant
    New

    Grazie Sig. Roberto,

    Sempre molto disponibile.

    …ma temo di non aver capito cosa dovrei fare con il link che ha postato…mi scusi..

    Grazie

    #192041 quote
    Hary TradingHary Trading
    Participant
    New

    se io volessi solo spostare lo stop in pari dopo 400 punti ( su 800 di target), devo usare il suo codice cosi come lo ha scritto?

    grazie ancora

    #192043 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Il link rimanda al codice originale.

    Usa quello che ho postato io, fa quello che hai chiesto.

    #192058 quote
    Hary TradingHary Trading
    Participant
    New

    Perfetto

    grazie 1000

    buona giornata

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

STOR IN PARI


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Hary Trading @adtrader Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Hary TradingHary Trading
4 years, 5 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/21/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...